-
Notifications
You must be signed in to change notification settings - Fork 45
/
meson.build
220 lines (183 loc) · 5.64 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
project('frida-cycript', 'c', 'cpp',
version: '2.0.5',
default_options: ['cpp_std=c++11'],
)
host_os_family = host_machine.system()
host_os = host_os_family
host_arch = host_machine.cpu_family()
if host_arch == 'aarch64'
host_arch = 'arm64'
endif
c_languages = ['c']
cpp_languages = ['cpp']
if host_os_family == 'darwin'
c_languages += 'objc'
cpp_languages += 'objcpp'
add_languages('objc', 'objcpp')
endif
languages = c_languages + cpp_languages
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
target_conditionals_prefix = '#include <TargetConditionals.h>'
is_macos_src = target_conditionals_prefix + '''
#if !TARGET_OS_OSX
# error Not macOS
#endif
'''
if cc.compiles(is_macos_src, name: 'compiling for macOS')
host_os = 'macos'
endif
is_ios_src = target_conditionals_prefix + '''
#if !TARGET_OS_IOS
# error Not iOS
#endif
'''
if cc.compiles(is_ios_src, name: 'compiling for iOS')
host_os = 'ios'
endif
if cc.has_header('android/api-level.h')
host_os = 'android'
endif
if host_os == 'macos'
add_global_arguments('-mmacosx-version-min=10.9', language: languages)
add_global_link_arguments('-mmacosx-version-min=10.9', language: languages)
endif
compiler_id = cc.get_id()
if compiler_id == 'gcc'
add_global_arguments('-static-libgcc', language: languages)
add_global_link_arguments('-static-libgcc', language: languages)
add_global_arguments('-static-libstdc++', language: cpp_languages)
add_global_link_arguments('-static-libstdc++', language: cpp_languages)
endif
if compiler_id == 'clang'
add_global_arguments('-stdlib=libc++', language: cpp_languages)
add_global_link_arguments('-stdlib=libc++', language: cpp_languages)
endif
optimization_compile_args = []
optimization_link_args = []
buildtype = get_option('buildtype')
if buildtype == 'release' or buildtype == 'minsize'
if host_os_family == 'darwin'
optimization_link_args += '-Wl,-dead_strip'
endif
if host_os_family == 'linux'
optimization_compile_args += [
'-ffunction-sections',
'-fdata-sections',
]
optimization_link_args += '-Wl,--gc-sections'
endif
endif
add_global_arguments(optimization_compile_args, language: languages)
add_global_link_arguments(optimization_link_args, language: languages)
python3 = import('python').find_installation()
if build_machine.system() == 'windows'
flex = find_program(files('ext/toolchain/usr/bin/flex.exe'))
else
flex = find_program('flex')
endif
bison = find_program(files('ext/toolchain/usr/bin/bison.py'))
cdata = configuration_data()
host_os_id = '1'
cdata.set_quoted('CY_SYSTEM', host_os_id)
enable_objc = true
cdata.set10('CY_OBJECTIVEC', enable_objc)
enable_java = true
cdata.set10('CY_JAVA', enable_java)
enable_ruby = true
cdata.set10('CY_RUBY', enable_ruby)
if get_option('enable_engine')
cdata.set('CY_EXECUTE', 1)
endif
thread_dep = dependency('threads')
extra_libs = []
analyze_extra_includes = []
if get_option('enable_engine')
npm = find_program('npm')
if not cc.has_header('sqlite3.h')
error('sqlite3 is required when engine is enabled')
endif
extra_libs += ['-lsqlite3']
python = get_option('with-python')
if python != 'no'
enable_python = true
result = run_command(python, '-c',
'from distutils import sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())')
if result.returncode() != 0
error('Unable to detect Python include directory: ' + result.stdout() + result.stderr())
endif
python_incdir = result.stdout()
analyze_extra_includes += '-I' + python_incdir
else
enable_python = false
endif
if build_machine.system() == 'darwin'
result = run_command('scripts/detect-xcode-clang-libdir')
clang_libdir = result.stdout().strip()
clang_dep = cc.find_library('clang', dirs: clang_libdir)
else
clang_libdir = ''
clang_dep = cc.find_library('clang')
endif
else
enable_python = false
endif
cdata.set10('CY_PYTHON', enable_python)
if get_option('enable_console')
readline = subproject('readline')
readline_dep = readline.get_variable('readline_static_dep')
if cc.has_function('cur_term', args: ['-ltermcap'])
termcap_libs = ['-ltermcap']
elif cc.has_function('cur_term', args: ['-lncurses'])
termcap_libs = ['-lncurses']
else
error('termcap or ncurses is required')
endif
endif
configure_file(output: 'config.h',
configuration: cdata)
if compiler_id == 'msvc'
add_project_arguments('/FI', join_paths(meson.current_build_dir(), 'config.h'), language: languages)
else
add_project_arguments('-include', 'config.h', language: languages)
endif
if compiler_id == 'msvc'
warning_suppression_flags = [
'/wd4005',
'/wd4244',
'/wd4291',
'/wd4715',
]
add_project_arguments(warning_suppression_flags, language: languages)
elif compiler_id == 'gcc' or compiler_id == 'clang'
add_project_arguments('-fvisibility=hidden', language: languages)
candidate_c_flags = [
## XXX: this one is used to support GNU Objective-C struct objc_method
'-Wno-deprecated-declarations',
'-Wno-dangling-else',
'-Wno-empty-body',
'-Wno-parentheses',
'-Wno-tautological-undefined-compare',
'-Wno-unneeded-internal-declaration',
'-Wno-inconsistent-missing-override',
]
extra_c_args = []
foreach flag : candidate_c_flags
if cc.has_argument(flag)
extra_c_args += [flag]
endif
endforeach
add_project_arguments(extra_c_args, language: languages)
candidate_cpp_flags = [
'-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual',
]
extra_cpp_args = []
foreach flag : candidate_cpp_flags
if cpp.has_argument(flag)
extra_cpp_args += [flag]
endif
endforeach
add_project_arguments(extra_cpp_args, language: cpp_languages)
endif
subdir('src')