[jhbuild/feature/regex-based-include-searching: 3/3] sysdeps: c_include_glob in altdeps
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/feature/regex-based-include-searching: 3/3] sysdeps: c_include_glob in altdeps
- Date: Sun, 16 May 2021 09:07:13 +0000 (UTC)
commit 3d5aa0cfb61d168f57db828324e41390c658d427
Author: Sebastian Geiger <sbastig gmx net>
Date: Fri May 14 16:09:50 2021 +0200
sysdeps: c_include_glob in altdeps
This adds support for a new `c_include_glob` type in the
`deps` and `altdeps` elements that can be used to search
for C include files using shell glob expressions
(i.e, `*` and `?`).
The path specified in the name field can be relative
or absolute. If the path is absolute it will be evaluated
directly using pythons `glob.glob` function. If the path
is relative, it will be evaluated relative to all the
configured include paths using pythons `fnmatch.fnmatch`
function.
This change is needed because clang installs its headers
into non-standard locations. For example on Debian into
`/usr/lib/llvm-*/include/clang-c` rather than putting them
into `/usr/include/llvm-*/clang-c`.
jhbuild/utils/systeminstall.py | 21 +++++++++++++++++++++
modulesets/gnome-sysdeps-latest.modules | 32 +++-----------------------------
2 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 610be80d..19075661 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -19,6 +19,7 @@
from __future__ import print_function
+import glob
import os
import sys
import logging
@@ -27,6 +28,7 @@ import subprocess
import textwrap
import time
import re
+import fnmatch
from .compat import TextIO
from . import cmds
@@ -180,6 +182,25 @@ def systemdependencies_met(module_name, sysdeps, config):
break
if not found:
dep_met = False
+ elif dep_type.lower() == 'c_include_glob':
+ if c_include_search_paths is None:
+ c_include_search_paths = get_c_include_search_paths(config)
+
+ if os.path.isabs(value):
+ matches = glob.glob(value)
+ if matches:
+ return True
+
+ for path in c_include_search_paths:
+ filename_glob = os.path.normpath(os.path.join(path, value))
+
+ for root, dirs, files in os.walk(path):
+ for file in files:
+ candidate_filepath = os.path.join(root, file)
+ if fnmatch.fnmatch(candidate_filepath, filename_glob):
+ return True
+
+ dep_met = False
elif dep_type in ('python2', 'python3'):
command = dep_type
diff --git a/modulesets/gnome-sysdeps-latest.modules b/modulesets/gnome-sysdeps-latest.modules
index 9d0af442..5eeeb552 100644
--- a/modulesets/gnome-sysdeps-latest.modules
+++ b/modulesets/gnome-sysdeps-latest.modules
@@ -531,36 +531,10 @@
<branch repo="system"/>
<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"/>
+ <!-- Debian -->
+ <altdep type="c_include_glob" name="/usr/lib/llvm-*/include/clang-c/Index.h"/>
<!-- FreeBSD -->
- <altdep type="c_include" name="../llvm90/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm80/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm70/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm60/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm50/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm40/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm39/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm38/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm37/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm36/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm35/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm34/include/clang-c/Index.h"/>
- <altdep type="c_include" name="../llvm-devel/include/clang-c/Index.h"/>
+ <altdep type="c_include" name="/usr/lib/llvm*/include/clang-c/Index.h"/>
</dep>
</systemdependencies>
</systemmodule>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]