girepository: Search the same paths as the Python code

The Python code historically always searched DATADIR/gir-1.0 (always)
and /usr/share/gir-1.0 (only on Unix); since the previous commit, they
are searched after the GIR_DIR. Do the same here, to make the C and
Python search paths match up.

With the default gir_dir_prefix, searching both GIR_DIR and
DATADIR/gir-1.0 is redundant. However, if gir_dir_prefix is changed to
something else, for example -Dgir_dir_prefix=lib64, always searching
DATADIR/gir-1.0 provides backwards compatibility with pre-existing GIR
that might already be stored in DATADIR/gir-1.0.

Resolves: #455 (in conjunction with previous commit)
Helps: #323
Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2021-02-10 12:01:44 +00:00 committed by Simon McVittie
parent 19f14589d3
commit 4758e1ee19

View File

@ -342,6 +342,20 @@ locate_gir (GIrParser *parser,
return g_steal_pointer (&path); return g_steal_pointer (&path);
g_clear_pointer (&path, g_free); g_clear_pointer (&path, g_free);
path = g_build_filename (GOBJECT_INTROSPECTION_DATADIR, GIR_SUFFIX, girname, NULL);
g_debug ("Trying %s from DATADIR", path);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
return g_steal_pointer (&path);
g_clear_pointer (&path, g_free);
#ifdef G_OS_UNIX
path = g_build_filename ("/usr/share", GIR_SUFFIX, girname, NULL);
g_debug ("Trying %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
return g_steal_pointer (&path);
g_clear_pointer (&path, g_free);
#endif
g_debug ("Did not find %s", girname); g_debug ("Did not find %s", girname);
return NULL; return NULL;
} }