From 90ed83d7e9b6cc4cf291cf91dc4addd1dc24a0ce Mon Sep 17 00:00:00 2001 From: lordwithcc Date: Tue, 13 Dec 2022 18:22:55 +0800 Subject: [PATCH] Unify ut and test262 Signed-off-by: lordwithcc --- BUILD.gn | 16 +++++++----- build/compile_script/ark.py | 13 +++++++--- build/config/compiler/BUILD.gn | 1 + build/core/gn/BUILD.gn | 2 +- build/templates/cxx/cxx.gni | 2 ++ build/third_party_gn/cJSON/BUILD.gn | 34 +++++++++++++++++++++++++ build/third_party_gn/icu/icu4c/BUILD.gn | 4 +-- tooling/BUILD.gn | 14 +++++++--- websocket/BUILD.gn | 12 +++++---- 9 files changed, 76 insertions(+), 22 deletions(-) create mode 100644 build/third_party_gn/cJSON/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 454b5cb4..60e15896 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -124,8 +124,10 @@ group("ark_toolchain_packages") { deps += [ "//arkcompiler/toolchain/inspector:ark_debugger", "//arkcompiler/toolchain/tooling:libark_ecma_debugger", - "//third_party/libuv:uv", ] + if (!ark_standalone_build) { + deps += [ "//third_party/libuv:uv" ] + } } } @@ -133,10 +135,10 @@ group("ark_toolchain_unittest") { testonly = true deps = [] if (host_os != "mac") { - deps += [ - "//arkcompiler/toolchain/tooling/test:unittest", - "//third_party/libuv:uv", - ] + deps += [ "//arkcompiler/toolchain/tooling/test:unittest" ] + if (!ark_standalone_build) { + deps += [ "//third_party/libuv:uv" ] + } if (is_ohos && is_standard_system) { deps += [ "//arkcompiler/toolchain/test/fuzztest:fuzztest" ] } @@ -157,6 +159,8 @@ group("ark_js_host_unittest") { deps = [ "//arkcompiler/ets_runtime:ark_runtime_host_unittest", "//arkcompiler/toolchain:ark_toolchain_host_unittest", - "//third_party/libuv:uv", ] + if (!ark_standalone_build) { + deps += [ "//third_party/libuv:uv" ] + } } diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 893cae8c..1ab06cd6 100644 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -29,9 +29,9 @@ ARCHES = ["x64", "arm", "arm64"] DEFAULT_ARCHES = "x64" MODES = ["release", "debug"] DEFAULT_MODES = "release" -TARGETS = ["ets_runtime", "ets_frontend", "default", "unittest_packages", "all"] +TARGETS = ["ets_runtime", "ets_frontend", "default", "all"] DEFAULT_TARGETS = "default" -TARGETS_TEST = ["test262"] +TARGETS_TEST = ["test262", "unittest"] USER_ARGS_TEMPLATE = """\ @@ -51,7 +51,7 @@ for example , python ark.py x64.release clean: clear your data in output dir [test] test262: run test262 - unittest_packages: run unittest + unittest: run unittest """ def PrintHelp(): @@ -194,13 +194,18 @@ def RunTest(template): arch = template[0] mode = template[1] test = template[5] + path = GetPath(arch, mode) test_dir = arch + "." + mode test262_code = '''cd arkcompiler/ets_frontend python3 test262/run_test262.py --es2021 all --timeout 180000 --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/%s/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/%s/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/%s/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda '''%(test_dir, test_dir, test_dir) + unittest_code = "./prebuilts/build-tools/linux-x86/bin/ninja -C %s unittest_packages"%(path) if ("test262" == test): - print("=== come to test ===") + print("=== come to test262 ===") return _Call(test262_code) + elif ("unittest" == test): + print("=== come to unittest ===") + return _Call(unittest_code) else: print("=== nothing to test ===") return 0 diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 6c5d75d8..fbab7536 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -160,6 +160,7 @@ config("default_warnings") { # which happens in several places in code. Not sure if # this is worth fixing. "-Wno-c++11-narrowing", + "-Wno-c++17-extensions", "-Wno-unneeded-internal-declaration", ] if (use_musl) { diff --git a/build/core/gn/BUILD.gn b/build/core/gn/BUILD.gn index 659c12c5..5758dc46 100644 --- a/build/core/gn/BUILD.gn +++ b/build/core/gn/BUILD.gn @@ -45,7 +45,7 @@ group("linux_packages") { group("unittest_packages") { testonly = true if (host_os != "mac") { - deps = [ "//arkcompiler/ets_runtime:ark_js_unittest" ] + deps = [ "//arkcompiler/toolchain:ark_js_host_unittest" ] } } diff --git a/build/templates/cxx/cxx.gni b/build/templates/cxx/cxx.gni index 5a5c78cf..a9e00df5 100755 --- a/build/templates/cxx/cxx.gni +++ b/build/templates/cxx/cxx.gni @@ -133,6 +133,8 @@ template("ohos_source_set") { "license_file", "license_as_sources", "use_exceptions", + "subsystem_name", + "part_name", ]) } } diff --git a/build/third_party_gn/cJSON/BUILD.gn b/build/third_party_gn/cJSON/BUILD.gn new file mode 100644 index 00000000..23b7342d --- /dev/null +++ b/build/third_party_gn/cJSON/BUILD.gn @@ -0,0 +1,34 @@ +#Copyright (c) 2019-2021 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("$build_root/ark.gni") +config("cJSON_config") { + include_dirs = [ "//third_party/cJSON" ] + defines = [ "CJSON_NESTING_LIMIT=(128)" ] +} +ohos_static_library("cjson_static") { + sources = [ "//third_party/cJSON/cJSON.c" ] + public_configs = [ ":cJSON_config" ] + part_name = "cjson" + subsystem_name = "thirdparty" +} +ohos_shared_library("cjson") { + deps = [ ":cjson_static" ] + public_configs = [ ":cJSON_config" ] + part_name = "cjson" + subsystem_name = "thirdparty" + install_images = [ + "system", + "updater", + ] +} diff --git a/build/third_party_gn/icu/icu4c/BUILD.gn b/build/third_party_gn/icu/icu4c/BUILD.gn index b9ee6215..14daaf88 100644 --- a/build/third_party_gn/icu/icu4c/BUILD.gn +++ b/build/third_party_gn/icu/icu4c/BUILD.gn @@ -522,7 +522,7 @@ ohos_shared_library("shared_icuuc") { "-shared", "-lm", ] - if (is_standard_system) { + if (is_standard_system || ark_standalone_build) { part_name = "icu" subsystem_name = "thirdparty" } else { @@ -573,7 +573,7 @@ ohos_shared_library("shared_icui18n") { cflags_cc += [ "-fPIC" ] ldflags += [ "-ldl" ] } - if (is_standard_system) { + if (is_standard_system || ark_standalone_build) { part_name = "icu" subsystem_name = "thirdparty" } else { diff --git a/tooling/BUILD.gn b/tooling/BUILD.gn index e2d5c16d..d2a4b900 100644 --- a/tooling/BUILD.gn +++ b/tooling/BUILD.gn @@ -60,7 +60,7 @@ source_set("libark_ecma_debugger_set") { deps = [ "$ark_root/libpandafile:arkfile_header_deps", - "//third_party/cJSON:cjson_static", + "$ark_third_party_root/cJSON:cjson_static", ] if (is_mingw || is_mac) { @@ -98,8 +98,10 @@ ohos_shared_library("libark_ecma_debugger") { deps = [ ":libark_ecma_debugger_set", "//arkcompiler/ets_runtime:libark_jsruntime", - "//third_party/libuv:uv", ] + if (!ark_standalone_build) { + deps += [ "//third_party/libuv:uv" ] + } install_enable = true @@ -137,7 +139,7 @@ source_set("libark_ecma_debugger_test_set") { deps = [ "$ark_root/libpandafile:arkfile_header_deps", - "//third_party/cJSON:cjson_static", + "$ark_third_party_root/cJSON:cjson_static", ] } @@ -145,8 +147,12 @@ ohos_shared_library("libark_ecma_debugger_test") { deps = [ ":libark_ecma_debugger_test_set", "//arkcompiler/ets_runtime:libark_jsruntime_test", - "//third_party/libuv:uv", ] + if (!ark_standalone_build) { + deps += [ "//third_party/libuv:uv" ] + } else { + ldflags = [ "-luv" ] + } if (is_ohos && is_standard_system) { if (enable_hilog) { diff --git a/websocket/BUILD.gn b/websocket/BUILD.gn index 84faa5f4..fa75be49 100644 --- a/websocket/BUILD.gn +++ b/websocket/BUILD.gn @@ -83,11 +83,13 @@ ohos_source_set("websocket") { sources = [ "websocket.cpp" ] - deps += [ - "//third_party/openssl:libcrypto_static", - "//third_party/openssl:ssl_source", - sdk_libc_secshared_dep, - ] + deps += [ sdk_libc_secshared_dep ] + if (!ark_standalone_build) { + deps += [ + "//third_party/openssl:libcrypto_static", + "//third_party/openssl:ssl_source", + ] + } configs += [ ":websocket_config", -- Gitee