-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeson.build
75 lines (63 loc) · 2.89 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
project('spidermonkey-embedding-examples', 'cpp', version: 'esr115',
meson_version: '>= 0.43.0',
default_options: ['cpp_std=c++20', 'warning_level=3'])
cxx = meson.get_compiler('cpp')
args = []
zlib = dependency('zlib') # (is already a SpiderMonkey dependency)
spidermonkey = dependency('mozjs-115')
readline = cxx.find_library('readline')
# Check if SpiderMonkey was compiled with --enable-debug. If this is the case,
# you must compile all your sources with -DDEBUG=1.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1261161
nondebug_spidermonkey = cxx.compiles('''
#include <js-config.h>
#ifdef JS_DEBUG
#error debug yes, if we did not already error out due to DEBUG not being defined
#endif
''',
args: args, dependencies: spidermonkey,
name: 'SpiderMonkey is a non-debug build')
if not nondebug_spidermonkey
args += '-DDEBUG=1'
endif
# Check if a minimal SpiderMonkey program compiles, links, and runs. If not,
# it's most likely the case that SpiderMonkey was configured incorrectly, for
# example by building mozglue as a shared library.
minimal_program = cxx.run('''
#include <js/Initialization.h>
int main(void) {
if (!JS_Init()) return 1;
JS_ShutDown();
return 0;
}
''',
args: args, dependencies: spidermonkey,
name: 'SpiderMonkey sanity check')
if not minimal_program.compiled() or minimal_program.returncode() != 0
error('''
A minimal SpiderMonkey program could not be compiled, linked, or run. Most
likely you should build it with a different configuration. Check the recommended
configuration in this repository.''')
endif
add_project_arguments(args, language: 'cpp')
if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang'
test_warning_args = [
# it's useful not to have to initialize all struct fields when defining a
# JSClass, since some of them are padding.
'-Wno-missing-field-initializers',
# we use argument names in some cases for explanatory purposes
'-Wno-unused-parameter',
]
else
test_warning_args = []
endif
add_project_arguments(cxx.get_supported_arguments(test_warning_args),
language: 'cpp')
executable('hello', 'examples/hello.cpp', 'examples/boilerplate.cpp', dependencies: spidermonkey)
executable('cookbook', 'examples/cookbook.cpp', 'examples/boilerplate.cpp', dependencies: spidermonkey)
executable('repl', 'examples/repl.cpp', 'examples/boilerplate.cpp', dependencies: [spidermonkey, readline])
executable('tracing', 'examples/tracing.cpp', 'examples/boilerplate.cpp', dependencies: spidermonkey)
executable('resolve', 'examples/resolve.cpp', 'examples/boilerplate.cpp', dependencies: [spidermonkey, zlib])
executable('modules', 'examples/modules.cpp', 'examples/boilerplate.cpp', dependencies: [spidermonkey])
executable('weakref', 'examples/weakref.cpp', 'examples/boilerplate.cpp', dependencies: spidermonkey)
executable('worker', 'examples/worker.cpp', 'examples/boilerplate.cpp', dependencies: spidermonkey)