Skip to content

Commit

Permalink
fix generate_gir with BothLibraries dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bruchar1 committed Oct 30, 2024
1 parent db82c2d commit 5de578f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def _get_dependencies_flags_raw(
cflags.update(dep.get_compile_args())
cflags.update(state.get_include_args(dep.include_directories))
for lib in dep.libraries:
if isinstance(lib, build.BothLibraries):
lib = lib.get('auto')
if isinstance(lib, build.SharedLibrary):
_ld, depends = self._get_link_args(state, lib, depends, include_rpath)
internal_ldflags.update(_ld)
Expand Down
7 changes: 7 additions & 0 deletions test cases/frameworks/38 gir both_libraries/bar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "bar.h"
#include "foo.h"

int bar_func(void)
{
return foo_func() + 42;
}
1 change: 1 addition & 0 deletions test cases/frameworks/38 gir both_libraries/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int bar_func(void);
6 changes: 6 additions & 0 deletions test cases/frameworks/38 gir both_libraries/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "foo.h"

int foo_func(void)
{
return 42;
}
1 change: 1 addition & 0 deletions test cases/frameworks/38 gir both_libraries/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int foo_func(void);
43 changes: 43 additions & 0 deletions test cases/frameworks/38 gir both_libraries/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
project('gir both libraries', 'c')

gir = dependency('gobject-introspection-1.0', required: false)
if not gir.found()
error('MESON_SKIP_TEST gobject-introspection not found.')
endif

if host_machine.system() == 'cygwin'
# FIXME: g-ir-scanner seems broken on cygwin:
# ERROR: can't resolve libraries to shared libraries: foo++
error('MESON_SKIP_TEST g-ir-scanner is broken on cygwin.')
endif

gnome = import('gnome')

# Regression test simulating how GStreamer generate its GIRs.
# Generated gobject-introspection binaries for every GStreamer libraries must
# first call gst_init() defined in the main libgstreamer, which means they need
# to link on that lib.
# A regression caused by https://github.com/mesonbuild/meson/pull/12632 made
# Meson not link the binary generated for bar with libfoo in the case it uses
# both_libraries().

libfoo = both_libraries('foo', 'foo.c')
foo_gir = gnome.generate_gir(libfoo,
namespace: 'foo',
nsversion: '1.0',
sources: ['foo.c', 'foo.h'],
)
foo_dep = declare_dependency(
link_with: libfoo,
#link_with: libfoo.get_shared_lib(),
sources: foo_gir,
)

libbar = both_libraries('bar', 'bar.c', dependencies: foo_dep)
gnome.generate_gir(libbar,
namespace: 'bar',
nsversion: '1.0',
sources: ['bar.c', 'bar.h'],
extra_args: '--add-init-section=extern void foo_func(void);foo_func();',
dependencies: foo_dep,
)
3 changes: 3 additions & 0 deletions test cases/frameworks/38 gir both_libraries/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"expect_skip_on_jobname": ["azure", "macos", "msys2", "cygwin"]
}

0 comments on commit 5de578f

Please sign in to comment.