gir-to-d
gir-to-d copied to clipboard
Please search the same paths for GIR XML that GObject-Introspection does
It looks as though cppgir searches for GIR XML (.gir
files) in these locations (on Unix), highest-priority first:
- directories explicitly given as command-line options
-
d +
/gir-1.0
for each colon-delimited d in$XDG_DATA_DIRS
, with fallback as per the XDG basedir spec
with some alternatives to (2) on Windows and macOS.
GObject-Introspection since 1.78.x (https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/258) 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()
as per the XDG basedir spec - 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 gir-to-d should match GObject-Introspection's behaviour (although it would be fine to continue to implement the XDG basedir spec locally).
For (5), the way I would do it in C/C++ code would be to have a compile-time option 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 C/C++ code via -D
- but I don't know the D language, so I don't know what is its equivalent, if any. Some distributions will want to override this path at build-time, so it's important for that to be possible.
If it's difficult to implement some of these search paths, then the next best thing would be for gir-to-d 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 (simpler alternative, (5) and (6) are missing): https://gitlab.gnome.org/GNOME/gi-docgen/-/blob/2023.3/gidocgen/utils.py?ref_type=tags#L802