[gobject-introspection/wip/smcv/search-paths: 4/6] giscanner: Search the same hard-coded GIR_DIR used for the C code
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/smcv/search-paths: 4/6] giscanner: Search the same hard-coded GIR_DIR used for the C code
- Date: Fri, 12 Feb 2021 10:54:26 +0000 (UTC)
commit 58d64592c65654ae7e7a304bcd0f5a42ba290492
Author: Simon McVittie <smcv debian org>
Date: Wed Feb 10 11:59:05 2021 +0000
giscanner: Search the same hard-coded GIR_DIR used for the C code
Unlike DATADIR/gir-1.0, this respects -Dgir_dir_prefix.
Signed-off-by: Simon McVittie <smcv debian org>
Gbp-Pq: Name giscanner-Search-the-same-hard-coded-GIR_DIR-used-for-the.patch
.flake8 | 2 +-
giscanner/transformer.py | 15 ++++++---------
tests/warn/warningtester.py | 1 +
tools/g-ir-tool-template.in | 7 +++++++
tools/meson.build | 1 +
5 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/.flake8 b/.flake8
index 4ce80256..851e40d2 100644
--- a/.flake8
+++ b/.flake8
@@ -1,4 +1,4 @@
[flake8]
ignore=E127,E402,E501,E731,E128,W503,E741,W504
exclude=misc,subprojects
-builtins=DATADIR
+builtins=DATADIR,GIR_DIR
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 58176a6f..8ac6e265 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -180,19 +180,16 @@ None."""
# Private
- def _get_gi_data_dirs(self):
- data_dirs = utils.get_system_data_dirs()
- data_dirs.append(DATADIR)
- if os.name != 'nt':
- # For backwards compatibility, was always unconditionally added to the list.
- data_dirs.append('/usr/share')
- return data_dirs
-
def _find_include(self, include):
searchdirs = self._includepaths[:]
searchdirs.extend(os.getenv('GI_GIR_PATH', '').split(os.pathsep))
- for path in self._get_gi_data_dirs():
+ for path in utils.get_system_data_dirs():
searchdirs.append(os.path.join(path, 'gir-1.0'))
+ searchdirs.append(GIR_DIR)
+ searchdirs.append(os.path.join(DATADIR, 'gir-1.0'))
+ if os.name != 'nt':
+ # For backwards compatibility, was always unconditionally added to the list.
+ searchdirs.append('/usr/share/gir-1.0')
girname = '%s-%s.gir' % (include.name, include.version)
for d in searchdirs:
diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
index 2dc462c9..acb271f2 100644
--- a/tests/warn/warningtester.py
+++ b/tests/warn/warningtester.py
@@ -9,6 +9,7 @@ sys.path.insert(0, path)
# Not correct, but enough to get the tests going uninstalled
builtins.__dict__['DATADIR'] = path
+builtins.__dict__['GIR_DIR'] = path
from giscanner.annotationparser import GtkDocCommentBlockParser
from giscanner.ast import Include, Namespace
diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in
index 7fc4de5b..eadabda1 100755
--- a/tools/g-ir-tool-template.in
+++ b/tools/g-ir-tool-template.in
@@ -53,6 +53,13 @@ if not os.path.isdir(os.path.join(datadir, 'gir-1.0')):
builtins.__dict__['DATADIR'] = datadir
+gir_dir = os.path.abspath(os.path.join(filedir, '..', '@gir_dir_prefix@', 'gir-1.0'))
+# Fallback to hard-coded paths if the relocatable paths are wrong
+if not os.path.isdir(gir_dir):
+ gir_dir = "@GIR_DIR@"
+
+builtins.__dict__['GIR_DIR'] = gir_dir
+
# Again, relative paths first so that the installation prefix is relocatable
pylibdir = os.path.abspath(os.path.join(filedir, '..', 'lib', 'gobject-introspection'))
diff --git a/tools/meson.build b/tools/meson.build
index f272c955..4107f99c 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -21,6 +21,7 @@ foreach tool : tools
tools_conf.set('libdir', libdir_abs)
tools_conf.set('datarootdir', datadir_abs)
tools_conf.set('gir_dir_prefix', gir_dir_prefix)
+ tools_conf.set('GIR_DIR', girdir)
tools_conf.set('PYTHON_CMD', python_cmd)
tools_conf.set('TOOL_MODULE', tool[1])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]