Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split packages from cmake_modules when adding them as buildreqs #853

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions autospec/buildreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def parse_cmake(self, filename, cmake_modules, conf32):
"""Scan a .cmake or CMakeLists.txt file for what's it's actually looking for."""
findpackage = re.compile(r"^[^#]*find_package\((\w+)\b.*\)", re.I)
findpackage_multiline = re.compile(r"^[^#]*find_package\((\w+)\b.*", re.I)
pkgconfig = re.compile(r"^[^#]*pkg_check_modules\s*\(\w+ (.*)\)", re.I)
pkgconfig = re.compile(r"^[^#]*pkg_check_modules\s*\([\w\-]+ (.*)\)", re.I)
pkg_search_modifiers = {'REQUIRED', 'QUIET', 'NO_CMAKE_PATH',
'NO_CMAKE_ENVIRONMENT_PATH', 'IMPORTED_TARGET'}
extractword = re.compile(r'(?:"([^"]+)"|(\S+))(.*)')
Expand All @@ -518,8 +518,13 @@ def parse_cmake(self, filename, cmake_modules, conf32):
for line in lines:
if match := findpackage.search(line):
module = match.group(1)
if pkg := cmake_modules.get(module):
self.add_buildreq(pkg)
if pkgs := cmake_modules.get(module):
# Some of the entries in cmake_modules list multiple packages, space-separated, so we need to split.
# Otherwise, anything in buildreq_ban would have to match the entire string, not just a single package name.
# For example: Png2Ico, extra-cmake-modules png2ico
# buildreq_ban would have to contain "extra-cmake-modules png2ico" to match, instead of just "png2ico"
for pkg in pkgs.split():
self.add_buildreq(pkg)
elif findpackage_multiline.search(line):
self.findpackage_parse_lines(line, lines, cmake_modules)

Expand Down
Loading