-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson-both_libraries-dependency.patch
132 lines (130 loc) · 5 KB
/
meson-both_libraries-dependency.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 5b72845511338dfa4bbb40cb3c6ad6ef2f2b9b99 Mon Sep 17 00:00:00 2001
From: Charles Brunet <[email protected]>
Date: Tue, 29 Oct 2024 16:51:36 -0400
Subject: [PATCH] fix generate_gir with BothLibraries dependency
Co-authored-by: Xavier Claessens <[email protected]>
---
mesonbuild/modules/gnome.py | 2 +
.../frameworks/38 gir both_libraries/bar.c | 7 ++++
.../frameworks/38 gir both_libraries/bar.h | 1 +
.../frameworks/38 gir both_libraries/foo.c | 6 +++
.../frameworks/38 gir both_libraries/foo.h | 1 +
.../38 gir both_libraries/meson.build | 42 +++++++++++++++++++
.../38 gir both_libraries/test.json | 3 ++
7 files changed, 62 insertions(+)
create mode 100644 test cases/frameworks/38 gir both_libraries/bar.c
create mode 100644 test cases/frameworks/38 gir both_libraries/bar.h
create mode 100644 test cases/frameworks/38 gir both_libraries/foo.c
create mode 100644 test cases/frameworks/38 gir both_libraries/foo.h
create mode 100644 test cases/frameworks/38 gir both_libraries/meson.build
create mode 100644 test cases/frameworks/38 gir both_libraries/test.json
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index e0c1214d0851..4d2bd19416b3 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -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)
diff --git a/test cases/frameworks/38 gir both_libraries/bar.c b/test cases/frameworks/38 gir both_libraries/bar.c
new file mode 100644
index 000000000000..4cb41f798294
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/bar.c
@@ -0,0 +1,7 @@
+#include "bar.h"
+#include "foo.h"
+
+int bar_func(void)
+{
+ return foo_func() + 42;
+}
diff --git a/test cases/frameworks/38 gir both_libraries/bar.h b/test cases/frameworks/38 gir both_libraries/bar.h
new file mode 100644
index 000000000000..d22827b837f7
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/bar.h
@@ -0,0 +1 @@
+int bar_func(void);
diff --git a/test cases/frameworks/38 gir both_libraries/foo.c b/test cases/frameworks/38 gir both_libraries/foo.c
new file mode 100644
index 000000000000..b88aa91dabb4
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/foo.c
@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int foo_func(void)
+{
+ return 42;
+}
diff --git a/test cases/frameworks/38 gir both_libraries/foo.h b/test cases/frameworks/38 gir both_libraries/foo.h
new file mode 100644
index 000000000000..2a0867249307
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/foo.h
@@ -0,0 +1 @@
+int foo_func(void);
diff --git a/test cases/frameworks/38 gir both_libraries/meson.build b/test cases/frameworks/38 gir both_libraries/meson.build
new file mode 100644
index 000000000000..cb9cdd31f3ed
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/meson.build
@@ -0,0 +1,42 @@
+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,
+ 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,
+)
diff --git a/test cases/frameworks/38 gir both_libraries/test.json b/test cases/frameworks/38 gir both_libraries/test.json
new file mode 100644
index 000000000000..82ac42a293b3
--- /dev/null
+++ b/test cases/frameworks/38 gir both_libraries/test.json
@@ -0,0 +1,3 @@
+{
+ "expect_skip_on_jobname": ["azure", "macos", "msys2", "cygwin"]
+}
\ No newline at end of file