Debian Codegraph @

src/meson.build

raw
1 libdex_sources = [
2 'dex-aio.c',
3 'dex-aio-backend.c',
4 'dex-async-pair.c',
5 'dex-async-result.c',
6 'dex-block.c',
7 'dex-cancellable.c',
8 'dex-channel.c',
9 'dex-delayed.c',
10 'dex-enums.c',
11 'dex-error.c',
12 'dex-fd.c',
13 'dex-fiber.c',
14 'dex-coroutine.c',
15 'dex-future.c',
16 'dex-future-list-model.c',
17 'dex-future-set.c',
18 'dex-gdbus.c',
19 'dex-gio.c',
20 'dex-init.c',
21 'dex-infinite.c',
22 'dex-limiter.c',
23 'dex-main-scheduler.c',
24 'dex-object.c',
25 'dex-platform.c',
26 'dex-posix-aio-backend.c',
27 'dex-posix-aio-future.c',
28 'dex-promise.c',
29 'dex-scheduler.c',
30 'dex-state-machine.c',
31 'dex-task-group.c',
32 'dex-semaphore.c',
33 'dex-socket-wait.c',
34 'dex-stack.c',
35 'dex-static-future.c',
36 'dex-test.c',
37 'dex-thread.c',
38 'dex-thread-pool.c',
39 'dex-thread-pool-scheduler.c',
40 'dex-thread-pool-worker.c',
41 'dex-thread-storage.c',
42 'dex-timeout.c',
43 'dex-version.c',
44 'dex-waiter.c',
45 'dex-watch.c',
46 'dex-work-queue.c',
47 'dex-work-stealing-queue.c',
48 ]
49
50 libdex_headers = [
51 'dex-aio.h',
52 'dex-async-pair.h',
53 'dex-async-result.h',
54 'dex-block.h',
55 'dex-cancellable.h',
56 'dex-channel.h',
57 'dex-closure.h',
58 'dex-delayed.h',
59 'dex-enums.h',
60 'dex-error.h',
61 'dex-fiber.h',
62 'dex-future.h',
63 'dex-coroutine.h',
64 'dex-future-list-model.h',
65 'dex-future-set.h',
66 'dex-gdbus.h',
67 'dex-gio.h',
68 'dex-init.h',
69 'dex-limiter.h',
70 'dex-main-scheduler.h',
71 'dex-object.h',
72 'dex-platform.h',
73 'dex-promise.h',
74 'dex-scheduler.h',
75 'dex-state-machine.h',
76 'dex-task-group.h',
77 'dex-static-future.h',
78 'dex-test.h',
79 'dex-thread.h',
80 'dex-thread-pool.h',
81 'dex-thread-pool-scheduler.h',
82 'dex-timeout.h',
83 'dex-version-macros.h',
84 'libdex.h',
85 ]
86
87 libdex_deps = [
88 glib_dep,
89 ]
90
91 features_conf = configuration_data()
92 features_conf.set10('HAVE_GDBUS_CODEGEN', have_gdbus_codegen)
93
94 pkgconfig_vars = []
95 libdex_dep_variables = {}
96
97 if have_gdbus_codegen
98 codegen_path = '@0@/libdex-@1@/dex-gdbus-codegen-extension.py'.format(get_option('libexecdir'), api_version)
99 pkgconfig_vars += ['gdbus_codegen_extension=${prefix}/@0@'.format(codegen_path)]
100 libdex_dep_variables += {'gdbus_codegen_extension': meson.current_source_dir() / 'dex-gdbus-codegen-extension.py'}
101
102 install_data(
103 sources: 'dex-gdbus-codegen-extension.py',
104 install_dir : get_option('libexecdir') / 'libdex-@0@'.format(api_version)
105 )
106 endif
107
108 if host_machine.system() != 'darwin' and cc.get_argument_syntax() != 'msvc'
109 libatomic_dep = cc.find_library('atomic')
110 if not cc.links('int main(){}', dependencies: [libatomic_dep])
111 error('libatomic dependency is missing!')
112 endif
113
114 if libatomic_dep.found()
115 libdex_deps += [libatomic_dep]
116 endif
117 endif
118
119 if liburing_dep.found()
120 libdex_sources += [
121 'dex-uring-aio-backend.c',
122 'dex-uring-future.c',
123 ]
124
125 libdex_deps += [liburing_dep]
126
127 liburing_version_split = liburing_dep.version().split('.')
128 liburing_version_conf = configuration_data()
129 liburing_version_conf.set('DEX_URING_VERSION', meson.project_version())
130 liburing_version_conf.set('DEX_URING_MAJOR_VERSION', liburing_version_split[0])
131 liburing_version_conf.set('DEX_URING_MINOR_VERSION', liburing_version_split[1])
132
133 configure_file(
134 input: 'dex-uring-version.h.in',
135 output: 'dex-uring-version.h',
136 configuration: liburing_version_conf,
137 )
138 endif
139
140 if host_machine.system() != 'windows'
141 # Not really used on Windows now, see also
142 # https://github.com/mesonbuild/meson/issues/4366
143 libdex_sources += [
144 'dex-unix-signal.c',
145 'dex-ucontext.c',
146 ]
147 if libucontext_dep.found()
148 libdex_deps += [libucontext_dep]
149 endif
150
151 # If we're on Linux and mips we might still need asm.S.
152 # But otherwise linux can do it all without any custom
153 # assembler. Failure to do this might result in CET being
154 # disabled for the process by GCC.
155 if host_machine.system() == 'linux' and host_machine.cpu_family() == 'x86_64'
156 libdex_sources += ['asm.S']
157 elif ((host_machine.system() != 'linux' or host_machine.cpu_family() == 'mips') and
158 host_machine.system() != 'darwin')
159 libdex_sources += ['asm.S']
160 endif
161
162 libdex_headers += ['dex-unix-signal.h']
163 endif
164
165 version_split = meson.project_version().split('.')
166 version_conf = configuration_data()
167 major_version = version_split[0]
168 minor_version = version_split[1]
169 micro_version = version_split[2]
170 if micro_version[0] in ['a', 'b', 'r']
171 micro_version = '0'
172 endif
173 version_conf.set('VERSION', meson.project_version())
174 version_conf.set('MAJOR_VERSION', major_version)
175 version_conf.set('MINOR_VERSION', minor_version)
176 version_conf.set('MICRO_VERSION', micro_version)
177
178 configure_file(
179 input: 'dex-version.h.in',
180 output: 'dex-version.h',
181 configuration: version_conf,
182 install: true,
183 install_dir: join_paths(get_option('includedir'), 'libdex-@0@'.format(api_version))
184 )
185
186 configure_file(
187 input: 'dex-features.h.in',
188 output: 'dex-features.h',
189 configuration: features_conf,
190 install: true,
191 install_dir: join_paths(get_option('includedir'), 'libdex-@0@'.format(api_version))
192 )
193
194 if get_option('sysprof')
195 libdex_deps += [libsysprof_capture_dep]
196 endif
197
198 libdex_c_args = [
199 deprecated_c_args,
200 release_args,
201 '-DG_LOG_DOMAIN="Dex"',
202 '-DDEX_COMPILATION',
203 ]
204
205 if host_machine.system() == 'darwin'
206 libdex_c_args += [
207 # needed for setcontext/makecontext/swapcontext
208 '-D_XOPEN_SOURCE',
209 ]
210 endif
211
212 libdex = library('dex-@0@'.format(api_version), libdex_sources,
213 dependencies: libdex_deps,
214 c_args: libdex_c_args,
215 install: true,
216 gnu_symbol_visibility: 'hidden',
217 version: '@[email protected]'.format(api_version),
218 darwin_versions: '1.0',
219 )
220
221 if get_option('default_library') == 'static'
222 if get_option('introspection').enabled()
223 error('introspection requires building a shared library!')
224 endif
225 libdex_static = libdex
226 elif get_option('default_library') == 'shared'
227 libdex_static = static_library('dex-internal-@0@'.format(api_version),
228 objects: libdex.extract_all_objects(recursive: false),
229 dependencies: libdex_deps,
230 gnu_symbol_visibility: 'hidden',
231 c_args: libdex_c_args,
232 )
233 else
234 libdex_static = libdex.get_static_lib()
235 endif
236
237 libdex_static_dep = declare_dependency(
238 link_whole: libdex_static,
239 include_directories: include_directories('.'),
240 dependencies: libdex_deps,
241 )
242
243 libdex_dep_sources = []
244
245 install_headers(libdex_headers, subdir: 'libdex-@0@'.format(api_version))
246
247 pkg_requires = ['gio-2.0']
248 if host_machine.system() != 'windows'
249 pkg_requires += ['gio-unix-2.0']
250 endif
251
252 pkg.generate(
253 description: 'Future-based programming for GLib-based applications and libraries',
254 libraries: libdex,
255 name: 'libdex',
256 filebase: 'libdex-' + api_version,
257 subdirs: 'libdex-@0@'.format(api_version),
258 requires: pkg_requires,
259 variables: pkgconfig_vars,
260 )
261
262 if get_option('introspection').enabled()
263 libdex_gir_includes = ['Gio-2.0']
264
265 if host_machine.system() != 'windows'
266 libdex_gir_includes += ['GioUnix-2.0']
267 endif
268
269 libdex_gir = gnome.generate_gir(libdex,
270 sources: [libdex_sources, libdex_headers],
271 nsversion: api_version,
272 namespace: 'Dex',
273 export_packages: 'libdex-@0@'.format(api_version),
274 symbol_prefix: 'dex',
275 identifier_prefix: 'Dex',
276 install_dir_gir: girdir,
277 install_dir_typelib: typelibdir,
278 includes: libdex_gir_includes,
279 install: true,
280 header: 'libdex.h',
281 extra_args: ['-DDEX_COMPILATION'],
282 )
283
284 libdex_dep_sources += [libdex_gir]
285
286 if get_option('vapi')
287 libdex_vapi_packages = ['gio-2.0']
288
289 if host_machine.system() != 'windows'
290 libdex_vapi_packages += ['gio-unix-2.0']
291 endif
292
293 dex_vapi = gnome.generate_vapi('libdex-@0@'.format(api_version),
294 sources: libdex_gir.get(0),
295 install: true,
296 install_dir: join_paths(datadir, 'vala', 'vapi'),
297 packages: libdex_vapi_packages,
298 )
299 endif
300
301 if get_option('pygobject')
302 python3 = import('python').find_installation('python3')
303
304 pygobject_override_dir = get_option('pygobject-override-dir')
305 pygobject_override_files = files('Dex.py')
306
307 if pygobject_override_dir == ''
308 pygobject_override_dir = 'gi/overrides'
309 else
310 # Emulate install_data behavior
311 pygobject_override_dir = join_paths(get_option('prefix'), pygobject_override_dir)
312 endif
313
314 python3.install_sources(pygobject_override_files,
315 pure: true,
316 subdir: pygobject_override_dir)
317 endif
318 endif
319
320 libdex_dep = declare_dependency(
321 link_with: libdex,
322 include_directories: include_directories('.'),
323 dependencies: libdex_deps,
324 sources: [libdex_dep_sources],
325 variables: libdex_dep_variables,
326 )
327
328 meson.override_dependency('libdex-' + api_version, libdex_dep)