-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmeson.build
More file actions
369 lines (320 loc) · 12 KB
/
meson.build
File metadata and controls
369 lines (320 loc) · 12 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
project(
'wirelog',
'c',
version: '0.30.0',
license: 'LGPL-3.0',
meson_version: '>=0.62.0',
default_options: [
'buildtype=release',
'optimization=s',
'b_lto=true',
'b_sanitize=none',
]
)
#Project metadata
project_name = meson.project_name()
project_version = meson.project_version()
project_license = 'LGPL-3.0'
project_url = 'https://github.com/semantic-reasoning/wirelog'
#Directories
wirelog_libdir = get_option('libdir')
wirelog_includedir = get_option('includedir')
wirelog_datadir = get_option('datadir') / project_name
#Build options (must be read before compiler settings for CRC-32 variant)
crc32_variant_option = get_option('crc32_variant')
#Compiler settings
cc = meson.get_compiler('c')
# CRC-32 variant define
crc32_defines = []
if crc32_variant_option == 'ethernet'
crc32_defines = ['-DCRC32_DEFAULT_VARIANT_ETHERNET']
elif crc32_variant_option == 'castagnoli'
crc32_defines = ['-DCRC32_DEFAULT_VARIANT_CASTAGNOLI']
endif
if cc.get_id() == 'msvc'
# MSVC C11 atomics are incomplete
# Define __STDC_NO_ATOMICS__ to skip C11 atomics declarations
add_project_arguments(
['/W3', '/D__STDC_NO_ATOMICS__'] + crc32_defines,
language: 'c'
)
else
# GCC/Clang: enforce C11 standard
add_project_arguments(
['-std=c11'] + crc32_defines,
language: 'c'
)
# GCC/Clang: add SIMD support flags for AVX2 and NEON optimization
simd_flags = []
if host_machine.cpu_family() == 'aarch64'
simd_flags = ['-march=armv8-a+simd'] # ARM64: enable NEON
elif host_machine.cpu_family() == 'x86_64'
simd_flags = ['-mavx2'] # x86-64: enable AVX2 (portable base)
endif
add_project_arguments(
[
'-Wall',
'-Wextra',
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
] + simd_flags,
language: 'c'
)
endif
#Platform detection
platform = host_machine.system()
is_embedded = get_option('embedded')
is_windows = platform == 'windows'
is_macos = platform == 'darwin'
is_linux = platform == 'linux'
#Build options
ipc_option = get_option('ipc')
threads_option = get_option('threads')
tests_option = get_option('tests')
docs_option = get_option('documentation')
# crc32_variant_option already defined earlier before compiler settings
io_plugin_dlopen_option = get_option('io_plugin_dlopen')
message('wirelog ' + project_version)
message(' Platform: ' + platform)
message(' Embedded: @0@'.format(is_embedded))
message(' IPC support: ' + ipc_option)
message(' Threading: ' + threads_option)
message(' CRC-32 variant: ' + crc32_variant_option)
message(' Plugin loader (dlopen): ' + io_plugin_dlopen_option)
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Dependencies
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#pthreads for threading
threads_dep = []
_td = dependency('threads', required: false)
if not _td.found()
_td = cc.find_library('pthread', required: false)
endif
if _td.found()
threads_dep = [_td]
endif
#Optional : zlib for IPC compression(future)
zlib_dep = []
if ipc_option == 'enabled'
_zd = dependency('zlib', required: false)
if _zd.found()
zlib_dep = [_zd]
endif
endif
#Phase 2A : nanoarrow for columnar backend(via meson wrap)
nanoarrow_proj = subproject('nanoarrow', default_options: ['tests=disabled', 'apps=disabled', 'ipc=disabled', 'device=disabled', 'testing=disabled'])
nanoarrow_dep = nanoarrow_proj.get_variable('nanoarrow_dep')
#Built-in functions : xxHash3 for hash() function
xxhash_proj = subproject('xxhash', default_options: [])
#Optional : mbedTLS for cryptographic functions (Issue #73)
mbedtls_option = get_option('mbedTLS')
mbedtls_dep = []
if mbedtls_option == 'auto'
_mbedtls = dependency('mbedtls', required: false)
if _mbedtls.found()
# mbedTLS has private dependencies on mbedx509 and tfpsacrypto for linking
_mbedx509 = dependency('mbedx509', required: false)
_tfpsacrypto = dependency('tfpsacrypto', required: false)
mbedtls_dep = [_mbedtls]
if _mbedx509.found()
mbedtls_dep += [_mbedx509]
endif
if _tfpsacrypto.found()
mbedtls_dep += [_tfpsacrypto]
endif
add_project_arguments('-DWL_MBEDTLS_ENABLED=1', language: 'c')
endif
elif mbedtls_option == 'enabled'
_mbedtls = dependency('mbedtls', required: true)
# mbedTLS has private dependencies on mbedx509 and tfpsacrypto for linking
_mbedx509 = dependency('mbedx509', required: false)
_tfpsacrypto = dependency('tfpsacrypto', required: false)
mbedtls_dep = [_mbedtls]
if _mbedx509.found()
mbedtls_dep += [_mbedx509]
endif
if _tfpsacrypto.found()
mbedtls_dep += [_tfpsacrypto]
endif
add_project_arguments('-DWL_MBEDTLS_ENABLED=1', language: 'c')
endif
xxhash_dep = xxhash_proj.get_variable('xxhash_dep')
# Math library for col_compute_worker_cap (Issue #409)
# On most POSIX systems libm is separate; on some (musl, glibc 2.38+) it is
# part of libc and find_library may return not-found. Fall back to a raw
# -lm link_args which is harmless when libm is folded into libc.
_math_lib = cc.find_library('m', required: false)
if _math_lib.found()
math_dep = [_math_lib]
else
math_dep = [declare_dependency(link_args: '-lm')]
endif
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Configuration
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
config_h = configuration_data()
config_h.set_quoted('WIRELOG_VERSION', project_version)
config_h.set_quoted('WIRELOG_PLATFORM', platform)
config_h.set('WIRELOG_EMBEDDED', is_embedded)
config_h.set('WIRELOG_IPC', ipc_option == 'enabled')
config_h.set('WIRELOG_THREADS', true)
#Generate config header
config_h_file = configure_file(
input: 'config.h.in',
output: 'wirelog-config.h',
configuration: config_h,
install_dir: wirelog_includedir / 'wirelog'
)
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Include directories
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
wirelog_inc = include_directories('.')
wirelog_src_inc = include_directories('wirelog')
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Source files
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Collect source files for each module
subdir('wirelog')
#Combine all sources
wirelog_sources = []
wirelog_sources += wirelog_parser_src
wirelog_sources += wirelog_ir_src
wirelog_sources += wirelog_optimizer_src
wirelog_sources += wirelog_arena_src
wirelog_sources += wirelog_thread_src
wirelog_sources += wirelog_backend_src
wirelog_sources += wirelog_workqueue_src
wirelog_sources += wirelog_io_src
wirelog_sources += wirelog_string_ops_src
wirelog_sources += wirelog_wl_easy_src
#Public headers
wirelog_public_headers = [
'wirelog/wirelog.h',
'wirelog/wirelog-types.h',
'wirelog/wirelog-parser.h',
'wirelog/wirelog-ir.h',
'wirelog/wirelog-optimizer.h',
'wirelog/wirelog-export.h',
'wirelog/wl_easy.h',
]
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Build targets
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Shared library
wirelog_lib = library(
'wirelog',
wirelog_sources,
config_h_file,
include_directories: [wirelog_inc, wirelog_src_inc],
c_args: ['-DWIRELOG_BUILDING'],
dependencies: [threads_dep, zlib_dep, nanoarrow_dep, xxhash_dep, mbedtls_dep, math_dep],
install: true,
version: project_version,
)
#Static library(optional)
wirelog_static_lib = static_library(
'wirelog_static',
wirelog_sources,
config_h_file,
include_directories: [wirelog_inc, wirelog_src_inc],
c_args: ['-DWIRELOG_BUILDING'],
dependencies: [threads_dep, zlib_dep, nanoarrow_dep, xxhash_dep, mbedtls_dep, math_dep],
install: false, # Not installed by default
)
#Install public headers
install_headers(
wirelog_public_headers,
subdir: 'wirelog'
)
install_headers(
'wirelog/io/io_adapter.h',
subdir: 'wirelog/io'
)
#pkg - config file
pkg = import('pkgconfig')
pkg.generate(
wirelog_lib,
name: project_name,
description: 'Embedded-to-Enterprise Datalog Engine',
version: project_version,
filebase: project_name,
)
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#CLI Driver
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
# Optional plugin loader via dlopen (Issue #461)
# Excluded from Windows builds (no dlopen); Android/iOS excluded via option default.
cli_plugin_src = []
cli_plugin_deps = []
cli_plugin_args = []
if io_plugin_dlopen_option == 'enabled' and not is_windows
_dl_dep = cc.find_library('dl', required: false)
if _dl_dep.found()
cli_plugin_deps += [_dl_dep]
endif
cli_plugin_src = files('wirelog/cli/plugin_loader.c')
cli_plugin_args = ['-DWL_HAVE_PLUGIN_LOADER']
endif
#Build wirelog-cli executable (wirelog_cli_src defined in wirelog/meson.build)
#Include all wirelog sources to ensure proper linking with LTO
wirelog_cli = executable(
'wirelog_cli',
wirelog_cli_src,
cli_plugin_src,
wirelog_sources,
config_h_file,
include_directories: [wirelog_inc, wirelog_src_inc],
c_args: cli_plugin_args,
dependencies: [threads_dep, zlib_dep, nanoarrow_dep, xxhash_dep, mbedtls_dep, math_dep] + cli_plugin_deps,
install: true,
)
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Benchmarks
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
subdir('bench')
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Tests
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
if tests_option
subdir('tests')
endif
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Examples
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
subdir('examples/08-delta-queries')
subdir('examples/09-retraction-basics')
subdir('examples/10-recursive-under-update')
subdir('examples/11-time-evolution')
subdir('examples/12-snapshot-vs-delta')
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Documentation
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
if docs_option
#Documentation build(optional, not yet implemented)
message('Documentation: enabled (not yet implemented)')
endif
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Git Hooks Setup
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
# Setup uncrustify pre-commit hook (optional, non-blocking)
python3 = find_program('python3', required: false)
if python3.found()
run_command(
python3,
'scripts/setup_uncrustify_hook.py',
check: false # Don't fail build if hook setup has issues
)
endif
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
#Summary
#== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
message('')
message('wirelog ' + project_version + ' Configuration:')
message(' Library: ' + wirelog_libdir)
message(' Headers: ' + wirelog_includedir / 'wirelog')
message(' Embedded mode: @0@'.format(is_embedded))
message(' IPC support: ' + ipc_option)
message(' Threading: ' + threads_option)
message(' Tests: @0@'.format(tests_option))
message('')
message('Git Hooks: uncrustify pre-commit hook configured')