forked from frida/quickjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
145 lines (122 loc) · 3.04 KB
/
Copy pathmeson.build
File metadata and controls
145 lines (122 loc) · 3.04 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
project('quickjs', 'c',
version: '2024-01-13-fork',
)
cc = meson.get_compiler('c')
have_msvc = cc.get_id() == 'msvc'
have_emscripten = cc.get_define('EMSCRIPTEN') != ''
if meson.is_subproject() and not have_msvc
add_project_arguments('-w', language: 'c')
endif
threads_dep = dependency('threads')
dl_dep = cc.find_library('dl', required: false)
m_dep = cc.find_library('m', required: false)
inline_define_generic = 'inline'
inline_define_gnulike = 'inline __attribute__((always_inline))'
if get_option('stack_mode') == 'optimize'
add_project_arguments(
'-fno-inline',
'-fno-inline-functions',
language: 'c',
)
inline_define_gnulike = 'inline'
endif
quickjs_h = configure_file(
input: 'quickjs.h.in',
output: 'quickjs.h',
configuration: {
'inline_define_generic': inline_define_generic,
'inline_define_gnulike': inline_define_gnulike,
},
)
headers = [
quickjs_h,
]
sources = [
'quickjs.c',
'libregexp.c',
'libunicode.c',
'cutils.c',
'libbf.c',
]
cdata = configuration_data()
cdata.set_quoted('CONFIG_VERSION', meson.project_version())
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif
platform_headers = [
'malloc.h',
'unistd.h',
]
foreach h : platform_headers
if cc.has_header(h)
cdata.set('HAVE_' + h.underscorify().to_upper(), 1)
endif
endforeach
if cc.has_function('malloc_usable_size')
cdata.set('HAVE_MALLOC_USABLE_SIZE', 1)
endif
if get_option('libc')
headers += 'quickjs-libc.h'
sources += 'quickjs-libc.c'
endif
cdata.set('CONFIG_BIGNUM', get_option('bignum'))
atomics = false
opt = get_option('atomics')
if not opt.disabled()
supported = not (have_msvc or have_emscripten)
if opt.auto()
atomics = supported
elif supported
atomics = true
else
error('Atomics support was requested but is not available')
endif
endif
cdata.set('CONFIG_ATOMICS', atomics)
stack_check = false
opt = get_option('stack_check')
if not opt.disabled()
supported = not (have_msvc or have_emscripten)
if opt.auto()
stack_check = supported
elif supported
stack_check = true
else
error('Stack limitation was requested but is not available')
endif
endif
cdata.set('CONFIG_STACK_CHECK', stack_check)
install_headers(headers, subdir: 'quickjs')
configure_file(
output: 'config.h',
configuration: cdata,
)
add_project_arguments(
have_msvc ? '/FI' : '-include', meson.current_build_dir() / 'config.h',
'-D_GNU_SOURCE=1',
language: 'c',
)
quickjs = library('quickjs', sources,
dependencies: [threads_dep, dl_dep, m_dep],
install: true,
)
quickjs_dep = declare_dependency(
link_with: quickjs,
include_directories: include_directories('.'),
)
pkg = import('pkgconfig')
pkg.generate(quickjs,
name: 'quickjs',
description: 'Small and embeddable JavaScript engine',
url: 'https://bellard.org/quickjs/',
subdirs: ['quickjs'],
)
meson.override_dependency('quickjs', quickjs_dep)
qjs = executable('qjs', 'qjs.c', 'repl.c', 'qjscalc.c',
dependencies: quickjs_dep,
install: true,
)
qjsc = executable('qjsc', 'qjsc.c',
dependencies: quickjs_dep,
install: true,
)