-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
407 lines (339 loc) · 9.55 KB
/
meson.build
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
project(
'libcon4m',
'c',
default_options: ['c_std=c2x', 'default_library=static'],
version: '0.1.0',
license: 'MIT',
)
cc = meson.get_compiler('c')
incdir = include_directories('include')
using_osx = false
glibc_check = '''
#include <stdio.h>
#ifndef __GLIBC__
#error NO GLIBC
#endif
'''
if cc.compiles(glibc_check)
using_glibc = true
else
using_glibc = false
endif
render_width = get_option('minimum_render_width').to_string()
c_args = [
'-Wextra',
'-g',
'-Wno-unused-parameter',
'-Wno-cast-function-type',
'-fno-omit-frame-pointer',
'-DHATRACK_PER_INSTANCE_AUX',
'-DC4M_MIN_RENDER_WIDTH=' + render_width,
]
if (host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'clang')
c_args = c_args + ['-Wno-atomic-alignment']
endif
if (host_machine.system() == 'darwin')
using_osx = true
link_args = ['-target', 'arm64-apple-macos14', '-framework', 'Security']
if not get_option('use_frame_intrinsic').disabled()
c_args = c_args + ['-DC4M_USE_FRAME_INTRINSIC']
endif
libcurl = dependency('curl')
else
using_osx = false
link_args = []
c_args = c_args + ['-D_GNU_SOURCE']
# This doesn't seem to always work right on Linux so don't use it by default.
if get_option('use_frame_intrinsic').enabled()
c_args = c_args + ['-DC4M_USE_FRAME_INTRINSIC']
endif
libcurl = cc.find_library('curl')
endif
if get_option('forkless_tests').enabled()
c_args = c_args + ['-DC4M_TEST_WITHOUT_FORK']
endif
if not get_option('static_ffi_binding').disabled()
c_args = c_args + ['-DC4M_STATIC_FFI_BINDING']
endif
backtrace = cc.find_library('backtrace', required: false)
if backtrace.found()
c_args = c_args + ['-DC4M_BACKTRACE_SUPPORTED']
endif
if get_option('show_preprocessor_config').enabled()
c_args = c_args + ['-DC4M_SHOW_PREPROC_CONFIG']
endif
fpty_code = '''
#include <stddef.h>
#include <pty.h>
int main(void) { forkpty(NULL, NULL, NULL, NULL); return 0; }
'''
if cc.links(fpty_code, name: 'forkpty_check')
add_project_arguments('-DHAVE_PTY_H', language: 'c')
endif
if get_option('buildtype') == 'release'
c_args = c_args + ['-Ofast', '-flto']
link_args = link_args + ['-flto']
endif
if not get_option('use_gc_ptr_hooks').disabled()
c_args = c_args + ['-DC4M_USE_GC_HOOKS']
endif
if get_option('keep_alloc_locations') == true and get_option('dev_mode') == false
c_args = c_args + ['-DHATRACK_ALLOC_PASS_LOCATION']
endif
if get_option('dev_mode') == true
c_args = c_args + ['-DC4M_DEV']
if not get_option('exception_traces').disabled()
c_args = c_args + ['-DC4M_DEBUG']
endif
if get_option('use_asan').enabled()
c_args = c_args + ['-fsanitize=address', '-fsanitize-recover=all']
link_args = link_args + ['-fsanitize=address', '-fsanitize-recover=all']
endif
if get_option('use_ubsan').enabled()
c_args = c_args + [
'-fsanitize=undefined',
'-fno-sanitize=function',
'-fsanitize-recover=all',
]
link_args = link_args + [
'-fsanitize=undefined',
'-fsanitize-recover=all',
]
endif
memcheck = get_option('use_memcheck')
if not (memcheck == 'off')
c_args = c_args + [
'-DC4M_FULL_MEMCHECK',
'-DHATRACK_ALLOC_PASS_LOCATION',
]
if memcheck == 'strict'
c_args = c_args + ['-DC4M_STRICT_MEMCHECK']
endif
show_count = get_option('memcheck_show_allocs')
if show_count != 0
as_str = show_count.to_string()
c_args = c_args + ['-DC4M_SHOW_NEXT_ALLOCS=' + as_str]
endif
endif
if get_option('show_gc_stats').enabled()
c_args = c_args + ['-DC4M_GC_STATS', '-DHATRACK_ALLOC_PASS_LOCATION']
endif
vm_debug = get_option('vm_debug')
if vm_debug != 'always off'
c_args = c_args + ['-DC4M_VM_DEBUG']
endif
if vm_debug == 'default on'
c_args = c_args + ['-DC4M_VM_DEBUG_DEFAULT=true']
endif
if get_option('warn_on_zero_allocs') == true
c_args = c_args + ['-DC4M_WARN_ON_ZERO_ALLOCS']
endif
gctrace = get_option('gc_tracing')
if gctrace != 'off'
c_args = c_args + ['-DC4M_GC_FULL_TRACE']
endif
if gctrace == 'full'
c_args = c_args + ['-DC4M_GC_FULL_TRACE', '-DC4M_GC_ALL_ON']
endif
endif
exe_link_args = link_args + ['-flto', '-w']
exe_c_args = c_args + ['-flto', '-DHATRACK_REFERENCE_ALGORITHMS']
c4m_c_args = c_args
c4m_core = [
'src/core/init.c',
'src/core/gcbase.c',
'src/core/collect.c',
'src/core/kargs.c',
'src/core/exceptions.c',
'src/core/types.c',
'src/core/typestore.c',
'src/core/marshal.c',
'src/core/literals.c',
'src/core/attrstore.c',
'src/core/vm.c',
'src/core/vmmarshal.c',
'src/core/ffi.c',
'src/core/object.c',
]
c4m_adts = [
'src/adts/string.c',
'src/adts/buffer.c',
'src/adts/dict.c',
'src/adts/set.c',
'src/adts/hatlists.c',
'src/adts/list.c',
'src/adts/grid.c',
'src/adts/tree.c',
'src/adts/numbers.c',
'src/adts/mixed.c',
'src/adts/tuple.c',
'src/adts/ipaddr.c',
'src/adts/datetime.c',
'src/adts/size.c',
'src/adts/duration.c',
'src/adts/callback.c',
'src/adts/streams.c',
'src/adts/flags.c',
'src/adts/box.c',
]
c4m_io = [
'src/io/ansi.c',
'src/io/switchboard.c',
'src/io/subproc.c',
'src/io/term.c',
'src/io/http.c',
'src/io/file.c',
]
c4m_compiler = [
'src/compiler/compile.c',
'src/compiler/module.c',
'src/compiler/lex.c',
'src/compiler/parse.c',
'src/compiler/errors.c',
'src/compiler/scope.c',
'src/compiler/specs.c',
'src/compiler/cfg_build.c',
'src/compiler/cfg.c',
'src/compiler/ast_utils.c',
'src/compiler/decl_pass.c',
'src/compiler/check_pass.c',
'src/compiler/memory_layout.c',
'src/compiler/codegen.c',
'src/compiler/disasm.c',
'src/compiler/objgen.c',
]
c4m_util = [
'src/util/style.c',
'src/util/styledb.c',
'src/util/colors.c',
'src/util/breaks.c',
'src/util/hex.c',
'src/util/tree_pattern.c',
'src/util/conststr.c',
'src/util/richlit.c',
'src/util/format.c',
'src/util/fptostr.c',
'src/util/path.c',
'src/util/watch.c',
'src/util/wrappers.c',
'src/util/ctrace.c',
'src/util/static_config.c',
]
c4m_crypto = ['src/crypto/sha.c']
c4m_src = c4m_core + c4m_adts + c4m_io + c4m_compiler + c4m_util + c4m_crypto
hat_primary = [
'src/hatrack/support/hatrack_common.c',
'src/hatrack/support/mmm.c',
'src/hatrack/support/counters.c',
'src/hatrack/support/malloc.c',
'src/hatrack/hash/crown.c',
'src/hatrack/hash/dict.c',
'src/hatrack/hash/xxhash.c',
'src/hatrack/hash/set.c',
'src/hatrack/hash/woolhat.c',
'src/hatrack/array/flexarray.c',
'src/hatrack/array/zeroarray.c',
'src/hatrack/queue/queue.c',
'src/hatrack/queue/hatring.c',
'src/hatrack/queue/stack.c',
'src/hatrack/queue/debug.c',
'src/hatrack/queue/logring.c',
]
hat_hashref = [
'src/hatrack/hash/ballcap.c',
'src/hatrack/hash/duncecap.c',
'src/hatrack/hash/hihat-a.c',
'src/hatrack/hash/hihat.c',
'src/hatrack/hash/lohat-a.c',
'src/hatrack/hash/lohat.c',
'src/hatrack/hash/newshat.c',
'src/hatrack/hash/oldhat.c',
'src/hatrack/hash/refhat.c',
'src/hatrack/hash/swimcap.c',
'src/hatrack/hash/tiara.c',
'src/hatrack/hash/tophat.c',
'src/hatrack/hash/witchhat.c',
]
hash_test_src = hat_hashref + [
'src/harness/hash/test.c',
'src/harness/hash/default.c',
'src/harness/hash/performance.c',
'src/harness/hash/config.c',
'src/harness/hash/functional.c',
'src/harness/hash/rand.c',
'src/harness/hash/testhat.c',
]
if not using_osx and not using_glibc
target = build_machine.cpu_family()
quark_files = ['src/quark/quark.c', 'src/quark' / target + '.s']
hat_primary = hat_primary + quark_files
endif
lib_src = c4m_src + hat_primary
test_src = [
'src/harness/con4m_base/test.c',
'src/harness/con4m_base/scan.c',
'src/harness/con4m_base/run.c',
'src/harness/con4m_base/validation.c',
'src/harness/con4m_base/results.c',
]
threads = dependency('threads')
math = cc.find_library('m', required: false)
ffi = cc.find_library(
'ffi',
required: true
)
crypto = cc.find_library('crypto')
ssl = cc.find_library('ssl')
unibreak = dependency('libunibreak')
utf8proc = dependency('libutf8proc')
deps = [unibreak, utf8proc, threads, ffi, ssl, crypto, backtrace, libcurl]
opts = [math]
if using_glibc
opts = opts + [cc.find_library('atomic')]
endif
all_deps = deps + opts
libc4m = static_library(
'con4m',
lib_src,
include_directories: incdir,
dependencies: all_deps,
c_args: c4m_c_args,
link_args: link_args,
)
if get_option('build_con4m_dll').enabled()
library(
'con4m-dll',
lib_src,
include_directories: incdir,
dependencies: all_deps,
c_args: c4m_c_args,
link_args: link_args,
)
endif
executable(
'c4test',
test_src,
include_directories: incdir,
dependencies: [all_deps],
c_args: c_args,
link_args: exe_link_args,
link_with: libc4m,
)
if get_option('build_hatrack').enabled()
libhat = static_library(
'hatrack',
lib_src,
include_directories: incdir,
c_args: c_args,
link_args: link_args,
)
executable(
'hash',
hash_test_src,
include_directories: incdir,
dependencies: all_deps,
link_args: exe_link_args,
link_with: libhat,
c_args: exe_c_args,
)
endif