Search path for GIR XML not consistent between C and Python code
Two parts of GObject-Introspection load GIR XML, and they have different search paths. If GIR XML is installed into a non-standard location, for example as part of a jhbuild-like system, then this could lead to the Python and C tools disagreeing on the contents of a particular library.
giscanner/transformer.py
loads this:
- Paths from the
g-ir-scanner --add-include-path
org-ir-doc-tool --add-include-path
option -
GIRDIR
, which is the compile-time$prefix/$gir_dir_prefix
, usually/usr/share
(without thegir-1.0
suffix, which seems odd) -
$dir/gir-1.0
for each$dir
in the$XDG_DATA_DIRS
- (intentionally left blank)
- Compile-time
$prefix/$datadir/gir-1.0
, usually/usr/share/gir-1.0
(even if$gir_dir_prefix
is different) - Hard-coded
/usr/share/gir-1.0
(even if$prefix
is different, and not on Windows)
An easy way to see the search path for the Python code is to copy some GIR XML (I used /usr/share/gir-1.0/Flatpak-1.0.gir
), edit it to add <include name="DoesNotExist" version="0"/>
, and run g-ir-doc-tool -o out Flatpak-1.0.gir
. The error message about inability to find DoesNotExist-0.gir
contains the search path that was in effect.
girepository/girparser.c
loads this:
- Paths from the
g-ir-compiler --includedir
option - (intentionally left blank)
-
$dir/gir-1.0
for each$dir
in the$XDG_DATA_DIRS
-
GIR_DIR
, which is the compile-time$prefix/$gir_dir_prefix/gir-1.0
, usually/usr/share/gir-1.0
- (intentionally left blank)
- (intentionally left blank)
A semi-easy way to see the search path for the C code is to run strace -enewfstatat g-ir-compiler -o out.typelib Flatpak-1.0.gir
(the syscall used to implement g_file_test
will vary in different glibc versions) with the modified GIR XML described above, and look at the sequence of newfstatat(AT_FDCWD, ".../DoesNotExist-0.gir", ...)
calls.
I think each of these should be consistent with the other one.