granite should use native meson gir support
What Happened?
There is a build failure due to granite using a custom g-ir-compiler target rather than the native meson gir support. See discussion here.
Steps to Reproduce
granite is not using meson's native gir support
Expected Behavior
granite should use meson's native gir support for improved cross compilation compatibility
OS Version
Other Linux
Software Version
Latest release (I have run all updates)
Log Output
[51/275] Generating lib/Granite-1.0.typelib with a custom command
FAILED: lib/Granite-1.0.typelibi
/home/ymorin/dev/buildroot/O/master/per-package/granite/host/riscv32-buildroot-linux-gnu/sysroot/usr/bin/g-ir-compiler --shared-library libgranite.so.6.0.0 --output lib/Granite-1.0.typelib /home/ymorin/dev/buildroot/O/master/build/granite-6.0.0/build/lib/Granite-1.0.gir
Could not find GIR file 'GLib-2.0.gir'; check XDG_DATA_DIRS or use --includedir
error parsing file /home/ymorin/dev/buildroot/O/master/build/granite-6.0.0/build/lib/Granite-1.0.gir:
Failed to parse included gir GLib-2.0
If the above error message is about missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the .mk file should help.
Typically like this: PKG_MAKE_ENV += GIR_EXTRA_LIBS_PATH="$(@D)/.libs"
ninja: build stopped: subcommand failed.
make[1]: *** [package/pkg-generic.mk:293: /home/ymorin/dev/buildroot/O/master/build/granite-6.0.0/.stamp_built] Error 1
gnome.generate_gir is only for C, here we are using vala so we are only getting a .gir from valac so we need to use g-ir-compiler manually
gnome.generate_gir is only for C, here we are using vala so we are only getting a .gir from valac so we need to use g-ir-compiler manually
Weird, any idea why vala is not supported there? Even stranger is that the gnome module has vala support for stuff like gnome.generate_vapi.
Because gnome.generate_gir is made for C, for vala the compiler natively outputs a .gir file so one only need to create the typelib
Because
gnome.generate_giris made for C, for vala the compiler natively outputs a .gir file so one only need to create the typelib
Hmm, maybe there should be a variant for the g-ir-compiler stage of gnome.generate_gir?
It appears the custom_target command isn't properly setting the include directories.
Can you try with https://github.com/elementary/granite/commit/ecca06c52f09f6d931d6442800de0034322c9abe
Can you try with ecca06c
Haven't tested but from a quick review that's probably going to cause issues, when cross compiling we have to override the default g-ir-compiler with a special wrapper script that runs g-ir-compiler under qemu.
Something like this seems to work:
diff --git a/lib/meson.build b/lib/meson.build
index 1716cf7e..a937928b 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -106,6 +106,14 @@ install_data(
if get_option('introspection')
# typelib generation isn't automated yet
g_ir_compiler = find_program('g-ir-compiler')
+ sysroot = meson.get_external_property('sys_root', '/')
+ gi_dep = dependency('gobject-introspection-1.0')
+ prefix = gi_dep.get_variable(pkgconfig: 'prefix')
+ if prefix[0] == '/'
+ prefix = prefix.substring(1)
+ endif
+ prefix = join_paths(sysroot, prefix)
+ girdir = gi_dep.get_variable(pkgconfig: 'girdir', pkgconfig_define: ['prefix', prefix])
custom_target(
granite_typelib,
command: [
@@ -115,6 +123,8 @@ if get_option('introspection')
'--output',
'@OUTPUT@',
join_paths(meson.current_build_dir(), granite_gir),
+ '--includedir',
+ girdir,
],
input: libgranite,
output: granite_typelib,