diff --git a/build/common/musl/BUILD.gn b/build/common/musl/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ab5cbdd96798a499d004caa36d48cfb0b9637808 --- /dev/null +++ b/build/common/musl/BUILD.gn @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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 + +import("//arkcompiler/ets_runtime/js_runtime_config.gni") +import("$ark_third_party_root/musl/musl_config.gni") +import("$build_root/config/clang/clang.gni") +group("musl_install") { + deps = [ + ":ld-musl-arm.so.1", + ":musl-libcxx.so", + ] +} + +ohos_prebuilt_shared_library("ld-musl-arm.so.1") { + deps = [ "$ark_third_party_root/musl:soft_create_linker" ] + if (is_asan) { + asan = "-asan" + } else { + asan = "" + } + _musl_linker_so = + "${root_out_dir}/common/common/libc/./ld-musl-${musl_arch}${asan}.so.1" + source = _musl_linker_so + output = "packages/lib/ld-musl-${musl_arch}.so.1" +} + +ohos_prebuilt_shared_library("musl-libcxx.so") { + if (target_cpu == "arm") { + source = "${clang_base_path}/lib/arm-linux-ohos/libc++.so" + } else if (target_cpu == "arm64") { + source = "${clang_base_path}/lib/aarch64-linux-ohos/libc++.so" + } else if (target_cpu == "x86_64" || target_cpu == "x64") { + source = "${clang_base_path}/lib/x86_64-linux-ohos/libc++.so" + } else { + source = "" + } + output = "packages/lib/libc++.so" +} diff --git a/build/core/gn/BUILD.gn b/build/core/gn/BUILD.gn index 3e809522cb8898463e397d70092634c2b520c75d..52c8b90acf0a76853c34c3a1ac2a75112bcad1f9 100644 --- a/build/core/gn/BUILD.gn +++ b/build/core/gn/BUILD.gn @@ -40,8 +40,32 @@ group("default") { group("unittest_packages") { testonly = true + deps = [] if (host_os != "mac") { - deps = [ "//arkcompiler/toolchain:ark_js_host_unittest" ] + if (is_ohos) { + deps += [ + "//arkcompiler/ets_runtime/ecmascript/base/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/builtins/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/containers/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/debugger/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/dfx/hprof/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/ic/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/jobs/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/jspandafile/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/module/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/napi/test:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/pgo_profiler/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/regexp/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/require/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/snapshot/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/tests:host_unittest", + "//arkcompiler/ets_runtime/ecmascript/ts_types/tests:host_unittest", + "//arkcompiler/toolchain/tooling/test:host_unittest", + "//arkcompiler/toolchain/websocket/test:host_unittest", + ] + } else { + deps += [ "//arkcompiler/toolchain:ark_js_host_unittest" ] + } } } diff --git a/build/templates/cxx/prebuilt.gni b/build/templates/cxx/prebuilt.gni index d6034a979fc1b037e7e5f6ac5be8f60108970483..04e59a9d8c7d0d81499b1f61d665cc24bd6580f6 100644 --- a/build/templates/cxx/prebuilt.gni +++ b/build/templates/cxx/prebuilt.gni @@ -32,3 +32,22 @@ template("ohos_prebuilt_etc") { outputs = [ _copy_output ] } } + +template("ohos_prebuilt_shared_library") { + assert(defined(invoker.source), "source must be defined for ${target_name}.") + + if (defined(invoker.output)) { + _copy_output = "$root_out_dir/${invoker.output}" + } else { + _copy_output = "$root_out_dir/${invoker.source}" + } + ohos_copy(target_name) { + forward_variables_from(invoker, + [ + "deps", + "outputs", + ]) + sources = [ invoker.source ] + outputs = [ _copy_output ] + } +} diff --git a/test/test_helper.gni b/test/test_helper.gni index 13fd66a802a59087a96131e289906aaee5822c63..5dc23ac85836cd5bd58e6cec52319f1e4aca36e6 100644 --- a/test/test_helper.gni +++ b/test/test_helper.gni @@ -12,6 +12,7 @@ # limitations under the License. import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") +import("$ark_third_party_root/musl/musl_config.gni") import("$build_root/test.gni") import("../toolchain.gni") @@ -36,34 +37,59 @@ template("host_unittest_action") { # unittest for running on host action("${_target_name_}Action") { testonly = true + deps = [] - _host_test_target_ = ":${_target_name_}(${host_toolchain})" - _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir") + # Non-host artifacts run host in standalone build + if (ark_standalone_build && is_ohos) { + _host_test_target_ = ":${_target_name_}" + _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir") + deps += [ "//arkcompiler/toolchain/build/common/musl:musl_install" ] - deps = [ _host_test_target_ ] + args = [ + "--script-file", + "qemu-${musl_arch} -L ", + "--script-args", + rebase_path(_root_out_dir_) + + "/tests/unittest/${_module_out_path_}/${_target_name_}", + "--script-options", + rebase_path(_root_out_dir_) + "/packages", + "--expect-output", + "0", + "--env-path", + rebase_path(_root_out_dir_) + "/test/test:" + + rebase_path(_root_out_dir_) + "/${_icu_path_}:" + + rebase_path(_root_out_dir_) + "/thirdparty/libuv:" + + rebase_path(_root_out_dir_) + "/thirdparty/cjson:" + + rebase_path(_root_out_dir_) + "/security/huks:" + + rebase_path(_root_out_dir_) + + "/thirdparty/bounds_checking_function:", + "--timeout-limit", + "1200", + ] + } else { + _host_test_target_ = ":${_target_name_}(${host_toolchain})" + _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir") + + args = [ + "--script-file", + rebase_path(_root_out_dir_) + + "/tests/unittest/${_module_out_path_}/${_target_name_}", + "--expect-output", + "0", + "--env-path", + rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" + + rebase_path(_root_out_dir_) + "/test/test:" + + rebase_path(_root_out_dir_) + "/${_icu_path_}:" + + rebase_path(_root_out_dir_) + "/thirdparty/zlib:" + + rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"), + "--timeout-limit", + "1200", + ] + } script = "//arkcompiler/ets_runtime/script/run_ark_executable.py" - args = [ - "--script-file", - rebase_path(_root_out_dir_) + - "/tests/unittest/${_module_out_path_}/${_target_name_}", - "--expect-output", - "0", - "--env-path", - rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" + - rebase_path(_root_out_dir_) + "/test/test:" + - rebase_path(_root_out_dir_) + "/${_icu_path_}:" + - rebase_path(_root_out_dir_) + "/thirdparty/cjson:" + - rebase_path(_root_out_dir_) + "/thirdparty/libuv:" + - rebase_path(_root_out_dir_) + - "/thirdparty/bounds_checking_function:" + - rebase_path(_root_out_dir_) + "/security/huks:" + - rebase_path(_root_out_dir_) + "/thirdparty/zlib:" + - rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"), - "--timeout-limit", - "1200", - ] + deps += [ _host_test_target_ ] inputs = [ "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",