Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

granite should use native meson gir support #645

Open
jameshilliard opened this issue Apr 18, 2023 · 7 comments
Open

granite should use native meson gir support #645

jameshilliard opened this issue Apr 18, 2023 · 7 comments

Comments

@jameshilliard
Copy link

jameshilliard commented Apr 18, 2023

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
@tintou
Copy link
Member

tintou commented Apr 19, 2023

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

@jameshilliard
Copy link
Author

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.

@tintou
Copy link
Member

tintou commented Apr 19, 2023

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

@jameshilliard
Copy link
Author

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.

@tintou
Copy link
Member

tintou commented Apr 19, 2023

Can you try with ecca06c

@jameshilliard
Copy link
Author

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
Copy link
Author

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants