1
project('NativeBridge', 'c', 'cpp',
3
default_options: ['cpp_std=c++17', 'buildtype=release']
6
if get_option('source_set') != ''
7
source_set = get_option('source_set')
12
use_dummy_libace = true
19
java_home = run_command('node', '-e', 'console.log(process.env.JAVA_HOME)').stdout().strip()
23
is_jni = java_home != 'undefined'
25
compile_events_test = get_option('events_test')
27
gen_dir = '../generated/' + source_set
28
arkoala_dir = gen_dir + '/koalaui/arkoala/native/src/generated'
29
libace_dir = gen_dir + '/libace'
31
cxx = meson.get_compiler('cpp')
38
arkoala_dir / 'legacy'
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',
53
arkoala_dir + '/events_test.cc',
57
is_msvc = meson.get_compiler('cpp').get_id() == 'msvc'
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()
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)
72
use_dummy_libace = false
79
libace_name = 'ace_compatible_mock'
83
arkoala_dir + '/dummy_impl.cc',
87
libace_dir + '/generated/interface/all_modifiers.cpp',
89
getModifierImplFiles = run_command('node', 'getModifierImplFiles.mjs', libace_dir + '/implementation')
90
modifier_impl_sources = getModifierImplFiles.stdout().strip().split(',')
91
libace_sources += modifier_impl_sources
93
cflags += ['-DKOALA_USE_LIBACE=1']
96
arkoala_dir + '/dummy_impl.cc',
100
node_library_name = 'NativeBridgeNapi'
101
arkts_library_name = 'NativeBridgeArk'
102
jni_library_name = 'NativeBridgeJni'
103
ohos_library_name = 'NativeBridge_ohos'
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']
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
115
node_cflags = ['-DKOALA_USE_NODE_VM', '-DKOALA_NAPI', '-DINTEROP_LIBRARY_NAME=' + node_library_name ]
117
'../node_modules/node-api-headers/include',
118
'../node_modules/node-addon-api',
122
arkoala_dir + '/node/convertors-node.cc'
125
cflags += ['-DKOALA_WINDOWS']
126
node_sources += [ arkoala_dir / 'node' / 'win-dynamic-node.cc' ]
130
cflags += ['-DKOALA_LINUX']
131
panda_ldflags = ['-ldl', '-lm']
134
cflags += ['-DKOALA_MACOS']
135
panda_ldflags = ['-ldl', '-lm']
138
node_module_prefix = ''
139
node_module_suffix = 'node'
141
arkts_cflags = ['-DKOALA_USE_ARK_VM', '-DKOALA_USE_ARK_VM_WITH_ETS', '-DKOALA_ETS_NAPI']
142
arkts_include_dirs = [
143
arkoala_dir / 'arkts'
146
arkoala_dir / 'arkts/convertors-ark.cc',
147
arkoala_dir / 'arkts/convertors-ets.cc',
151
jni_cflags = ['-DKOALA_USE_JAVA_VM', '-DKOALA_JNI']
153
java_home / 'include',
154
java_home / 'include' / jni_os,
158
arkoala_dir / 'jni' / 'convertors-jni.cc',
164
# TODO: support v8 on arm32 board.
165
if get_option('is_ohos_v8') and arch == 'arm64'
175
shared_library(node_library_name,
176
sources + node_sources,
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,
190
shared_library(libace_name,
196
name_prefix: node_module_prefix,
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,
208
shared_library(arkts_library_name,
209
sources + arkts_sources,
214
include_directories: include_dirs + arkts_include_dirs,
215
install_dir: meson.current_source_dir(),
216
cpp_args: cflags + arkts_cflags,
223
shared_library(jni_library_name,
224
sources + jni_sources,
229
include_directories: include_dirs + jni_include_dirs,
230
install_dir: meson.current_source_dir(),
231
cpp_args: cflags + jni_cflags,
238
ohos_library_name = ohos_library_name + '_' + arch
241
ohos_cflags = [ '-DINTEROP_LIBRARY_NAME=' + ohos_library_name ]
244
'-DKOALA_USE_ARK_VM=1',
245
'-DKOALA_USE_ARK_VM_WITH_JS=1',
256
'../node_modules/node-addon-api',
257
arkoala_dir / 'node',
258
arkoala_dir / 'arkts'
262
arkoala_dir + '/node/convertors-node.cc'
265
shared_library(ohos_library_name,
266
sources + ohos_sources,
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
279
shared_library(libace_name,
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
295
# TODO: fix on Windows as well
297
executable('test_arkoala_api',
298
arkoala_dir / 'api_test.c',
300
include_directories: include_dirs
302
executable('test_arkoala_compat',
303
arkoala_dir / 'compat_test.cc',
305
include_directories: include_dirs