From 7dd071ff67a76c2cddb2d6cbe8030aa230e7f6d1 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Wed, 28 May 2025 13:48:44 +0300 Subject: [PATCH] Build for arm64 Signed-off-by: Nikolay Igotti --- ui2abc/libarkts/native/meson.build | 178 +++++++++++++++++------------ ui2abc/libarkts/package.json | 4 +- 2 files changed, 105 insertions(+), 77 deletions(-) diff --git a/ui2abc/libarkts/native/meson.build b/ui2abc/libarkts/native/meson.build index 5d1725f35..df365b1d0 100644 --- a/ui2abc/libarkts/native/meson.build +++ b/ui2abc/libarkts/native/meson.build @@ -1,75 +1,103 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -project( - 'es2panda_interop', - 'cpp', - version: '1.0', - default_options: [ - 'cpp_std=c++17', - 'buildtype=debug', - ], -) - -sources = [ - './src/common.cc', - './src/bridges.cc', - './src/generated/bridges.cc', - get_option('interop_src_dir') / 'common-interop.cc', - get_option('interop_src_dir') / 'callback-resource.cc', - get_option('interop_src_dir') / 'interop-logging.cc', - get_option('interop_src_dir') / 'napi/convertors-napi.cc', -] - -cflags = [ - '-DKOALA_INTEROP_MODULE=NativeModule', - '-DINTEROP_LIBRARY_NAME=' + get_option('lib_name'), - '-DKOALA_USE_NODE_VM', - '-DKOALA_NAPI', -] - -if (target_machine.system() == 'windows') - cflags += ['-DKOALA_WINDOWS'] - if (meson.get_compiler('cpp').get_id() == 'msvc') - # apply node.exe symbol loading hook - sources += [ - get_option('interop_src_dir') / 'napi/win-dynamic-node.cc' - ] - endif -else - cflags += ['-DKOALA_LINUX'] -endif - -shared_library( - get_option('lib_name'), - sources, - override_options: [ - 'b_lundef=false', - ], - install: true, - name_prefix: '', - name_suffix: 'node', - include_directories: [ - './src/', - get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', - get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', - get_option('interop_src_dir'), - get_option('interop_src_dir') / 'types', - get_option('interop_src_dir') / 'napi', - get_option('node_modules_dir') / 'node-api-headers/include', - get_option('node_modules_dir') / 'node-addon-api', - ], - cpp_args: cflags, - link_args: [], - dependencies: [] -) +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +project( + 'es2panda_interop', + 'cpp', + version: '1.0', + default_options: [ + 'cpp_std=c++17', + 'buildtype=debug', + ], +) + +sources = [ + './src/common.cc', + './src/bridges.cc', + './src/generated/bridges.cc', + get_option('interop_src_dir') / 'common-interop.cc', + get_option('interop_src_dir') / 'callback-resource.cc', + get_option('interop_src_dir') / 'interop-logging.cc', + get_option('interop_src_dir') / 'napi/convertors-napi.cc', +] + +cflags = [ + '-DKOALA_INTEROP_MODULE=NativeModule', + '-DINTEROP_LIBRARY_NAME=' + get_option('lib_name'), + '-DKOALA_USE_NODE_VM', + '-DKOALA_NAPI', +] + +if (target_machine.system() == 'windows') + cflags += ['-DKOALA_WINDOWS'] + if (meson.get_compiler('cpp').get_id() == 'msvc') + # apply node.exe symbol loading hook + sources += [ + get_option('interop_src_dir') / 'napi/win-dynamic-node.cc' + ] + endif +else + cflags += ['-DKOALA_LINUX'] +endif + +cflags_x64 = '--target=x86_64-linux-gnu' +cflags_arm64 = '--target=aarch64-linux-gnu' + +# sudo apt install g++-aarch64-linux-gnu binutils-aarch64-linux-gnu +shared_library( + get_option('lib_name') + '_x64', + sources, + override_options: [ + 'b_lundef=false', + ], + install: true, + name_prefix: '', + name_suffix: 'node', + include_directories: [ + './src/', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', + get_option('interop_src_dir'), + get_option('interop_src_dir') / 'types', + get_option('interop_src_dir') / 'napi', + get_option('node_modules_dir') / 'node-api-headers/include', + get_option('node_modules_dir') / 'node-addon-api', + ], + cpp_args: cflags + cflags_x64, + link_args: [cflags_x64], + dependencies: [] +) + +shared_library( + get_option('lib_name') + '_arm64', + sources, + override_options: [ + 'b_lundef=false', + ], + install: true, + name_prefix: '', + name_suffix: 'node', + include_directories: [ + './src/', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', + get_option('interop_src_dir'), + get_option('interop_src_dir') / 'types', + get_option('interop_src_dir') / 'napi', + get_option('node_modules_dir') / 'node-api-headers/include', + get_option('node_modules_dir') / 'node-addon-api', + ], + cpp_args: cflags + cflags_arm64, + link_args: [cflags_arm64], + dependencies: [] +) diff --git a/ui2abc/libarkts/package.json b/ui2abc/libarkts/package.json index d5fab99c2..bd44dca93 100644 --- a/ui2abc/libarkts/package.json +++ b/ui2abc/libarkts/package.json @@ -39,8 +39,8 @@ "clean": "rimraf build native/build* ./.rollup.cache tsconfig.tsbuildinfo lib", "clean:plugins": "rimraf plugins/build", "compile:koala:interop": "npm run --prefix ../../interop compile", - "compile:meson": "cd native && meson setup build && meson compile -C build", - "copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda.node ./build/native/build", + "compile:meson": "cd native && CXX=clang++ meson setup build && CXX=clang++ meson compile -C build", + "copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda_*.node ./build/native/build", "compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node", "compile:src": "npx ets-tsc -p ./tsconfig.json", "compile": "npm run compile:native && npm run compile:js", -- Gitee