Please search the same paths for GIR XML that GObject-Introspection does
Vala.CodeContext
(used in valadoc and vapigen) searches for GIR XML (.gir
files) in these locations, highest-priority first:
- directories explicitly given as command-line options
-
d +
/gir-1.0
for each colon-delimited d ing_get_system_data_dirs()
GObject-Introspection since 1.78.x (gobject-introspection!258 (merged)) searches more directories than that:
- directories explicitly given as command-line options
- each colon-delimited path in
$GI_GIR_PATH
(semicolon-delimited on Windows) -
g_get_user_data_dir()
+/gir-1.0
as per the XDG basedir spec -
d +
/gir-1.0
for each colon-delimited d ing_get_system_data_dirs()
- a path specified when GObject-Introspection was compiled, which defaults to
$datadir/gir-1.0
but is something architecture-dependent like$libdir/gir-1.0
in some OS distributions $datadir/gir-1.0
- on Unix only, a hard-coded fallback to
/usr/share/gir-1.0
All the tools in the GObject-Introspection ecosystem should agree on which directories to search, so I think Vala should match GObject-Introspection's behaviour. Sorry, I don't know the Vala language well enough to propose a concrete merge request.
For (5), probably the best way would be for Vala to have an AC_ARG_WITH([girdir])
that defaults to either '${datadir}/gir-1.0'
or $($PKG_CONFIG --variable=girdir gobject-introspection-1.0)
, and then pass that into the build of the Vala code via -D
. Some distributions will want to override this.
If it's difficult to implement some of these search paths, then it would be better than nothing for valadoc/vapigen to implement some of them, and leave the others (for example (5)) for distributions to patch in if they find that they need to.
References:
- in C: https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/1.78.1/girepository/girparser.c?ref_type=tags#L293
- in Python: https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/1.78.1/giscanner/transformer.py?ref_type=tags#L183
- in Python (alternative, (5) and (6) are missing): https://gitlab.gnome.org/GNOME/gi-docgen/-/blob/2023.3/gidocgen/utils.py?ref_type=tags#L802