granite icon indicating copy to clipboard operation
granite copied to clipboard

granite should use native meson gir support

Open jameshilliard opened this issue 2 years ago • 7 comments

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

jameshilliard avatar Apr 18 '23 21:04 jameshilliard

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

tintou avatar Apr 19 '23 07:04 tintou

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.

jameshilliard avatar Apr 19 '23 08:04 jameshilliard

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

tintou avatar Apr 19 '23 08:04 tintou

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

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.

jameshilliard avatar Apr 19 '23 08:04 jameshilliard

Can you try with https://github.com/elementary/granite/commit/ecca06c52f09f6d931d6442800de0034322c9abe

tintou avatar Apr 19 '23 08:04 tintou

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.

jameshilliard avatar Apr 19 '23 09:04 jameshilliard

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,

jameshilliard avatar Apr 23 '23 12:04 jameshilliard