diff options
author | Simon McVittie <smcv@debian.org> | 2023-02-02 11:14:01 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2023-03-14 12:37:48 +0000 |
commit | 6b5987cf2b2b8fd7494ceb9100698eb0ee063eec (patch) | |
tree | ef72f04f25b241cda406c07ce7ae9b7f64bf9573 | |
parent | 1a4270d12cbcf2b6c95f3c6226a71eaadd065c8f (diff) | |
download | gobject-introspection-6b5987cf2b2b8fd7494ceb9100698eb0ee063eec.tar.gz |
giscanner: Search the same compile-time GIR_DIR used for the C code
The difference between DATADIR/gir-1.0 and this one is that this one
respects the -Dgir_dir_prefix build-time option.
Helps: #323, #455
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r-- | .flake8 | 2 | ||||
-rw-r--r-- | giscanner/transformer.py | 15 | ||||
-rw-r--r-- | tests/warn/warningtester.py | 1 | ||||
-rwxr-xr-x | tools/g-ir-tool-template.in | 7 | ||||
-rw-r--r-- | tools/meson.build | 1 |
5 files changed, 16 insertions, 10 deletions
@@ -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 e99743ee..545ce6cc 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -180,21 +180,18 @@ 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[:] from_env = os.getenv('GI_GIR_PATH', '') if from_env: searchdirs.extend(from_env.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 2edcdd0e..469af0ca 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 46b487e0..53698369 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]) |