Skip to content

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, highest-priority first:

  1. directories explicitly given as command-line options
  2. each colon-delimited path in $GI_GIR
  3. d + /gir-1.0 for each colon-delimited d in $XDG_DATA_DIRS, but without the fallback to /usr/local/share:/usr/share specified in the XDG basedir spec

GObject-Introspection since 1.78.x (https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/258) searches more directories than that:

  1. directories explicitly given as command-line options
  2. each colon-delimited path in $GI_GIR_PATH (semicolon-delimited on Windows)
  3. g_get_user_data_dir() + /gir-1.0 as per the XDG basedir spec
  4. d + /gir-1.0 for each colon-delimited d in g_get_system_data_dirs() as per the XDG basedir spec
  5. 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
  6. $datadir/gir-1.0
  7. 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 cppgir should match GObject-Introspection's behaviour (although it would be fine to reimplement the XDG basedir spec in preference to using GLib's g_get_user_data_dir() and g_get_system_data_dirs() if a compile-time dependency on GLib is undesirable, and it would be fine to continue to check $GI_GIR for backwards-compatibility, perhaps immediately before or after $GI_GIR_PATH).

For (5), probably the best way would be for cppgir 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++ code via -D. Some distributions will want to override this.

If it's difficult to implement some of these search paths, then the next best thing would be for cppgir 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:

Edited by Simon McVittie