summaryrefslogtreecommitdiff
path: root/girepository/girparser.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2021-02-10 12:01:44 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2023-03-14 12:37:48 +0000
commita15ae089e49c110a4d4e19fac0ab9d135a119e5f (patch)
tree9651666c696a5f417134136d0fbe41c8d3cd2c3f /girepository/girparser.c
parent6b5987cf2b2b8fd7494ceb9100698eb0ee063eec (diff)
downloadgobject-introspection-a15ae089e49c110a4d4e19fac0ab9d135a119e5f.tar.gz
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>
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r--girepository/girparser.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c
index f50ddb97..2b7c4ede 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -345,6 +345,20 @@ locate_gir (GIrParser *parser,
return path;
g_free (path);
+ 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 path;
+ g_free (path);
+
+#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 path;
+ g_free (path);
+#endif
+
g_debug ("Did not find %s", girname);
return NULL;
}