[jhbuild/feature/regex-based-include-searching] sysdeps: support regex in altdeps
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/feature/regex-based-include-searching] sysdeps: support regex in altdeps
- Date: Fri, 14 May 2021 14:10:44 +0000 (UTC)
commit 5c12d0fa933467d2e5941791c8c52172da1e6075
Author: Sebastian Geiger <sbastig gmx net>
Date: Fri May 14 16:09:50 2021 +0200
sysdeps: support regex in altdeps
This adds support for using regex in altdeps by adding a new attribute 'regex'
to the deps and altdeps entries.
We also add /usr/lib to the searched directories. This change is
needed because clang installs its headers into /usr/lib/llvm-*/include/clang
rather than putting them into /usr/include/llvm-*.
When resolving altdeps we now check if an altdep is specified
via a regex and then try find a matching header in
the list of search include directories.
jhbuild/commands/sysdeps.py | 10 +++++-----
jhbuild/modtypes/__init__.py | 3 ++-
jhbuild/modtypes/systemmodule.py | 6 +++---
jhbuild/moduleset.py | 2 +-
jhbuild/utils/systeminstall.py | 27 +++++++++++++++++++--------
modulesets/gnome-sysdeps-latest.modules | 16 +---------------
6 files changed, 31 insertions(+), 33 deletions(-)
---
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
index 5e46cb33..e9ed5524 100644
--- a/jhbuild/commands/sysdeps.py
+++ b/jhbuild/commands/sysdeps.py
@@ -87,9 +87,9 @@ class cmd_sysdeps(cmd_build):
print('pkgconfig:{0}'.format(module.pkg_config[:-3])) # remove .pc
if module.systemdependencies is not None:
- for dep_type, value, altdeps in module.systemdependencies:
+ for dep_type, value, regex, altdeps in module.systemdependencies:
sys.stdout.write('{0}:{1}'.format(dep_type, value))
- for dep_type, value, empty in altdeps:
+ for dep_type, value, regex, empty in altdeps:
sys.stdout.write(',{0}:{1}'.format(dep_type, value))
sys.stdout.write('\n')
@@ -123,9 +123,9 @@ class cmd_sysdeps(cmd_build):
print('pkgconfig:{0}'.format(module.pkg_config[:-3])) # remove .pc
if module.systemdependencies is not None:
- for dep_type, value, altdeps in module.systemdependencies:
+ for dep_type, value, regex, altdeps in module.systemdependencies:
sys.stdout.write('{0}:{1}'.format(dep_type, value))
- for dep_type, value, empty in altdeps:
+ for dep_type, value, regex, empty in altdeps:
sys.stdout.write(',{0}:{1}'.format(dep_type, value))
sys.stdout.write('\n')
@@ -168,7 +168,7 @@ class cmd_sysdeps(cmd_build):
if module.pkg_config is not None:
uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc
elif module.systemdependencies is not None:
- for dep_type, value, altdeps in module.systemdependencies:
+ for dep_type, value, regex, altdeps in module.systemdependencies:
uninstalled.append((module.name, dep_type, value))
if len(uninstalled) == 0:
print(_(' (none)'))
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 2919a9f9..bb842fe7 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -95,10 +95,11 @@ def get_dependencies(node):
{'node_name' : 'dep',
'module_name' : node.getAttribute('id'),
'attribute' : 'name'})
+ regex = dep.getAttribute('regex')
altdeps = []
if dep.childNodes:
add_to_system_dependencies(altdeps, dep, 'altdep')
- lst.append((typ, name, altdeps))
+ lst.append((typ, name, regex, altdeps))
for childnode in node.childNodes:
if childnode.nodeType != childnode.ELEMENT_NODE:
diff --git a/jhbuild/modtypes/systemmodule.py b/jhbuild/modtypes/systemmodule.py
index 92b64838..6c08134d 100644
--- a/jhbuild/modtypes/systemmodule.py
+++ b/jhbuild/modtypes/systemmodule.py
@@ -26,14 +26,14 @@ __all__ = [ 'SystemModule' ]
class SystemModule(Package):
@classmethod
- def create_virtual(cls, name, branch, deptype, value):
- return cls(name, branch=branch, systemdependencies=[(deptype, value, [])])
+ def create_virtual(cls, name, branch, deptype, value, regex):
+ return cls(name, branch=branch, systemdependencies=[(deptype, value, regex, [])])
def parse_systemmodule(node, config, uri, repositories, default_repo):
instance = SystemModule.parse_from_xml(node, config, uri, repositories,
default_repo)
- if any(deptype == 'xml' for deptype, value, altdeps in instance.systemdependencies):
+ if any(deptype == 'xml' for deptype, value, regex, altdeps in instance.systemdependencies):
instance.dependencies += ['xmlcatalog']
return instance
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 12208992..a0a4bc2a 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -378,7 +378,7 @@ def load(config, uri=None):
if name in ms.modules:
continue
- virtual = SystemModule.create_virtual(name, virtual_branch, 'path', name)
+ virtual = SystemModule.create_virtual(name, virtual_branch, 'path', name, '')
ms.add(virtual)
return ms
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 610be80d..f3f4c678 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -135,7 +135,7 @@ def systemdependencies_met(module_name, sysdeps, config):
except (EnvironmentError, subprocess.CalledProcessError):
multiarch = None
# search /usr/include and its multiarch subdir (if any) by default
- paths = [ os.path.join(os.sep, 'usr', 'include')]
+ paths = [ os.path.join(os.sep, 'usr', 'include'), os.path.join(os.sep, 'usr', 'lib')]
if multiarch:
paths += [ os.path.join(paths[0], multiarch) ]
paths += extract_path_from_cflags(os.environ.get('CPPFLAGS', ''))
@@ -154,7 +154,7 @@ def systemdependencies_met(module_name, sysdeps, config):
return paths
c_include_search_paths = None
- for dep_type, value, altdeps in sysdeps:
+ for dep_type, value, is_regex, altdeps in sysdeps:
dep_met = True
if dep_type.lower() == 'path':
if os.path.split(value)[0]:
@@ -174,8 +174,20 @@ def systemdependencies_met(module_name, sysdeps, config):
c_include_search_paths = get_c_include_search_paths(config)
found = False
for path in c_include_search_paths:
- filename = os.path.join(path, value)
- if os.path.isfile(filename):
+ filename = os.path.normpath(os.path.join(path, value))
+
+ # check if the value is a regex
+ if is_regex:
+ matches = []
+ regex = re.compile(filename)
+ # value is a regex, do a tree walk and see if we can find a matching include
+ for root, dirs, files in os.walk(path):
+ for file in files:
+ if regex.match(os.path.join(root, file)):
+ matches.append(file)
+ if matches:
+ found = True
+ elif os.path.isfile(filename):
found = True
break
if not found:
@@ -448,12 +460,11 @@ class AptSystemInstall(SystemInstall):
ret_value += "|.*/" + re.escape(path)
return ret_value
- def _name_match_exact(self, exact_path_to_match, apt_file_result, native_packages):
+ def _name_match_exact(self, exact_path_to_match, apt_file_result):
for name, path in apt_file_result:
if path == exact_path_to_match:
- native_packages.append(name)
- return True
- return False
+ return name
+ return None
def _append_native_packages_or_warn_pkgconfig(self, pkgconfigs, native_packages):
if len(pkgconfigs) == 0:
diff --git a/modulesets/gnome-sysdeps-latest.modules b/modulesets/gnome-sysdeps-latest.modules
index 9d0af442..b06d7fd7 100644
--- a/modulesets/gnome-sysdeps-latest.modules
+++ b/modulesets/gnome-sysdeps-latest.modules
@@ -532,21 +532,7 @@
<systemdependencies>
<dep type="c_include" name="clang-c/Index.h">
<!-- Debian. FIXME: This is definitely broken. https://bugzilla.gnome.org/show_bug.cgi?id=781872 -->
- <altdep type="c_include" name="../lib/llvm-12/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-11/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-10/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-9/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-8/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-7/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-6.0/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-5.0/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-4.0/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.9/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.8/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.7/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.6/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.5/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../lib/llvm-3.4/include/clang-c/Index.h"/>
+ <altdep type="c_include" name="../lib/llvm-.*/include/clang-c/Index.h" regex="true" />
<!-- FreeBSD -->
<altdep type="c_include" name="../llvm90/include/clang-c/Index.h"/>
<altdep type="c_include" name="../llvm80/include/clang-c/Index.h"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]