idlize

Форк
0
/
meson.build 
308 строк · 7.4 Кб
1
project('NativeBridge', 'c', 'cpp',
2
    version: '0.1',
3
    default_options: ['cpp_std=c++17', 'buildtype=release']
4
)
5

6
if get_option('source_set') != ''
7
source_set = get_option('source_set')
8
else
9
source_set = 'peers'
10
endif
11
use_libace = false
12
use_dummy_libace = true
13
if get_option('arkts')
14
is_arkts = true
15
else
16
is_arkts = false
17
endif
18

19
java_home = run_command('node', '-e', 'console.log(process.env.JAVA_HOME)').stdout().strip()
20

21
is_node = true
22
is_arkts = true
23
is_jni = java_home != 'undefined'
24

25
compile_events_test = get_option('events_test')
26

27
gen_dir = '../generated/' + source_set
28
arkoala_dir = gen_dir + '/koalaui/arkoala/native/src/generated'
29
libace_dir = gen_dir + '/libace'
30

31
cxx = meson.get_compiler('cpp')
32

33
cflags = []
34
ldflags = []
35

36
include_dirs = [
37
   arkoala_dir,
38
   arkoala_dir / 'legacy'
39
]
40

41
sources = [
42
    arkoala_dir + '/common-interop.cc',
43
    arkoala_dir + '/custom.cc',
44
    arkoala_dir + '/bridge_generated.cc',
45
    arkoala_dir + '/bridge_custom.cc',
46
    arkoala_dir + '/events.cc',
47
    arkoala_dir + '/all_events.cc',
48
    arkoala_dir + '/load-library.cc',
49
    arkoala_dir + '/library.cc',
50
]
51
if compile_events_test
52
    sources += [
53
        arkoala_dir + '/events_test.cc',
54
    ]
55
endif
56

57
is_msvc = meson.get_compiler('cpp').get_id() == 'msvc'
58
is_clang = not is_msvc
59

60
oses = { 'emscripten': 'wasm', 'darwin': 'macos' }  # rename meson default names to convienient ones
61
archs = { 'x86_64': 'x64', 'aarch64': 'arm64', 'wasm32': 'wasm', 'armv7a': 'arm' }
62
jni_oses = { 'windows': 'win32' }
63
os = target_machine.system()
64
os = oses.get(os, os)
65
arch = target_machine.cpu()
66
arch = archs.get(arch, arch)
67
jni_os = target_machine.system()
68
jni_os = jni_oses.get(jni_os, jni_os)
69
is_ohos = os == 'ohos'
70

71
if is_ohos
72
use_dummy_libace = false
73
is_arkts = false
74
use_libace = true
75
endif
76

77
if use_libace
78
libace_sources = []
79
libace_name = 'ace_compatible_mock'
80

81
if use_dummy_libace
82
libace_sources += [
83
    arkoala_dir + '/dummy_impl.cc',
84
]
85
else
86
libace_sources += [
87
    libace_dir + '/generated/interface/all_modifiers.cpp',
88
]
89
getModifierImplFiles = run_command('node', 'getModifierImplFiles.mjs', libace_dir + '/implementation')
90
modifier_impl_sources = getModifierImplFiles.stdout().strip().split(',')
91
libace_sources += modifier_impl_sources
92
endif
93
cflags += ['-DKOALA_USE_LIBACE=1']
94
else
95
sources += [
96
    arkoala_dir + '/dummy_impl.cc',
97
]
98
endif
99

100
node_library_name = 'NativeBridgeNapi'
101
arkts_library_name = 'NativeBridgeArk'
102
jni_library_name = 'NativeBridgeJni'
103
ohos_library_name = 'NativeBridge_ohos'
104

105
if is_clang
106
# TODO: remove all -Wno-* when generation is fixed.
107
cflags += ['-Wall', '-Werror', '-Wno-unused-variable', '-Wno-unused-but-set-variable', '-Wno-unused-function', '-Wno-extern-c-compat', '-Wno-error=deprecated-declarations', '-Wno-unknown-warning-option', '-Wno-parentheses-equality']
108
endif
109

110
if is_msvc
111
# Avoid using COMDAT to not exceed COFF file limits, see https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1128?view=msvc-170
112
cflags += ['/Gy-']
113
endif
114

115
node_cflags = ['-DKOALA_USE_NODE_VM', '-DKOALA_NAPI', '-DINTEROP_LIBRARY_NAME=' + node_library_name ]
116
node_include_dirs = [
117
    '../node_modules/node-api-headers/include',
118
    '../node_modules/node-addon-api',
119
    arkoala_dir / 'node'
120
]
121
node_sources = [
122
    arkoala_dir + '/node/convertors-node.cc'
123
]
124
if os == 'windows'
125
    cflags += ['-DKOALA_WINDOWS']
126
    node_sources += [ arkoala_dir / 'node' / 'win-dynamic-node.cc' ]
127
    panda_ldflags = []
128
endif
129
if os == 'linux'
130
    cflags += ['-DKOALA_LINUX']
131
    panda_ldflags = ['-ldl', '-lm']
132
endif
133
if os == 'macos'
134
    cflags += ['-DKOALA_MACOS']
135
    panda_ldflags = ['-ldl', '-lm']
136
endif
137

138
node_module_prefix = ''
139
node_module_suffix = 'node'
140

141
arkts_cflags = ['-DKOALA_USE_ARK_VM', '-DKOALA_USE_ARK_VM_WITH_ETS', '-DKOALA_ETS_NAPI']
142
arkts_include_dirs = [
143
    arkoala_dir / 'arkts'
144
]
145
arkts_sources = [
146
    arkoala_dir / 'arkts/convertors-ark.cc',
147
    arkoala_dir / 'arkts/convertors-ets.cc',
148
]
149

150
if is_jni
151
    jni_cflags = ['-DKOALA_USE_JAVA_VM', '-DKOALA_JNI']
152
    jni_include_dirs = [
153
        java_home / 'include',
154
        java_home / 'include' / jni_os,
155
        arkoala_dir / 'jni'
156
    ]
157
    jni_sources = [
158
        arkoala_dir / 'jni' / 'convertors-jni.cc',
159
    ]
160
endif
161

162
if is_node
163
node_ldflags = []
164
# TODO: support v8 on arm32 board.
165
if get_option('is_ohos_v8') and arch == 'arm64'
166
node_ldflags += [
167
    '-lnode'
168
]
169
endif
170
if is_ohos
171
node_cflags += [
172
    '-DKOALA_OHOS',
173
]
174
endif
175
shared_library(node_library_name,
176
    sources + node_sources,
177
    override_options: [
178
        'b_lundef=false',
179
    ],
180
    install: true,
181
    name_prefix: node_module_prefix,
182
    name_suffix: node_module_suffix,
183
    include_directories: include_dirs + node_include_dirs,
184
    install_dir: meson.current_source_dir(),
185
    cpp_args: cflags + node_cflags,
186
    link_args: ldflags + node_ldflags,
187
    dependencies: []
188
)
189
if use_libace
190
shared_library(libace_name,
191
    libace_sources,
192
    override_options: [
193
        'b_lundef=false',
194
    ],
195
    install: true,
196
    name_prefix: node_module_prefix,
197
    name_suffix: 'dll',
198
    include_directories: include_dirs + node_include_dirs,
199
    install_dir: meson.current_source_dir(),
200
    cpp_args: cflags + node_cflags,
201
    link_args: ldflags + node_ldflags,
202
    dependencies: []
203
)
204
endif
205
endif
206

207
if is_arkts
208
shared_library(arkts_library_name,
209
    sources + arkts_sources,
210
    override_options: [
211
        'b_lundef=false',
212
    ],
213
    install: true,
214
    include_directories: include_dirs + arkts_include_dirs,
215
    install_dir: meson.current_source_dir(),
216
    cpp_args: cflags + arkts_cflags,
217
    link_args: ldflags,
218
    dependencies: []
219
)
220
endif
221

222
if is_jni
223
shared_library(jni_library_name,
224
    sources + jni_sources,
225
    override_options: [
226
        'b_lundef=false',
227
    ],
228
    install: true,
229
    include_directories: include_dirs + jni_include_dirs,
230
    install_dir: meson.current_source_dir(),
231
    cpp_args: cflags + jni_cflags,
232
    link_args: ldflags,
233
    dependencies: []
234
)
235
endif
236

237
if is_ohos
238
ohos_library_name = ohos_library_name + '_' + arch
239
module_prefix = 'lib'
240
module_suffix = 'so'
241
ohos_cflags = [ '-DINTEROP_LIBRARY_NAME=' + ohos_library_name ]
242
ohos_cflags += [
243
    '-DKOALA_NAPI',
244
    '-DKOALA_USE_ARK_VM=1',
245
    '-DKOALA_USE_ARK_VM_WITH_JS=1',
246
    '-DKOALA_OHOS',
247
    '-D__MUSL__',
248
]
249

250
ohos_ldflags = [
251
    '-lhilog_ndk.z',
252
    '-lace_napi.z',
253
]
254

255
ohos_include_dirs = [
256
    '../node_modules/node-addon-api',
257
    arkoala_dir / 'node',
258
    arkoala_dir / 'arkts'
259
]
260

261
ohos_sources = [
262
    arkoala_dir + '/node/convertors-node.cc'
263
]
264

265
shared_library(ohos_library_name,
266
    sources + ohos_sources,
267
    override_options: [
268
        'b_lundef=false',
269
    ],
270
    install: true,
271
    name_prefix: module_prefix,
272
    name_suffix: module_suffix,
273
    include_directories: include_dirs + ohos_include_dirs,
274
    install_dir: meson.current_source_dir(),
275
    cpp_args: cflags + ohos_cflags,
276
    link_args: ldflags + ohos_ldflags
277
)
278
if use_libace
279
shared_library(libace_name,
280
    libace_sources,
281
    override_options: [
282
        'b_lundef=false',
283
    ],
284
    install: true,
285
    name_prefix: module_prefix,
286
    name_suffix: module_suffix,
287
    include_directories: include_dirs + ohos_include_dirs,
288
    install_dir: meson.current_source_dir(),
289
    cpp_args: cflags + ohos_cflags,
290
    link_args: ldflags + ohos_ldflags
291
)
292
endif
293
endif
294

295
# TODO: fix on Windows as well
296
if os != 'windows'
297
executable('test_arkoala_api',
298
    arkoala_dir / 'api_test.c',
299
    c_args: cflags,
300
    include_directories: include_dirs
301
)
302
executable('test_arkoala_compat',
303
    arkoala_dir / 'compat_test.cc',
304
    cpp_args: cflags,
305
    include_directories: include_dirs
306
)
307

308
endif
309

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.