gtkd-developers / gir-to-d

Create D bindings from GObject introspection files
GNU Lesser General Public License v3.0
23 stars 13 forks source link

Please search the same paths for GIR XML that GObject-Introspection does #44

Open smcv opened 10 months ago

smcv commented 10 months ago

It looks as though cppgir searches for GIR XML (.gir files) in these locations (on Unix), highest-priority first:

  1. directories explicitly given as command-line options
  2. 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:

  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 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: