From 6533edbf20499f64a0e8ed31dab12e3c1f0291b1 Mon Sep 17 00:00:00 2001 From: lordwithcc Date: Fri, 28 Oct 2022 14:26:00 +0800 Subject: [PATCH] Adapts to ts2abc for ark_standalone_build Signed-off-by: lordwithcc --- build/compile_script/ark.py | 4 +- build/config/BUILD.gn | 7 +- build/core/gn/BUILD.gn | 1 + .../prebuilts_download/prebuilts_download.py | 14 ++++ .../prebuilts_download_config.json | 13 +++ build/third_party_gn/jsoncpp/BUILD.gn | 81 +++++++++++++++++++ 6 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 build/third_party_gn/jsoncpp/BUILD.gn diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index c27a5db..5553f39 100644 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -197,8 +197,8 @@ def RunTest(template): test = template[5] test_dir = arch + "." + mode test262_code = '''cd arkcompiler/ets_frontend - python3 test262/run_test262.py --es2021 all --timeout 180000 --libs-dir ../../out/%s/clang_x64/thirdparty/icu:../../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, test_dir) + 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) if ("test262" == test): print("=== come to test ===") return _Call(test262_code) diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn index 07964f1..2ca5eca 100644 --- a/build/config/BUILD.gn +++ b/build/config/BUILD.gn @@ -16,7 +16,6 @@ config("complier_defaults") { cflags = [ "-fPIC", "-pthread", - "-fno-rtti", ] } } @@ -27,11 +26,7 @@ config("executable_ldconfig") { "-Wl,-rpath=\$ORIGIN/", "-Wl,-rpath-link=", "-fPIE", - "-ldl", - "-lpthread", - "-lrt", - "-lc++", - "-latomic", + "-pthread", ] } } diff --git a/build/core/gn/BUILD.gn b/build/core/gn/BUILD.gn index 6de68cc..77b0c0d 100644 --- a/build/core/gn/BUILD.gn +++ b/build/core/gn/BUILD.gn @@ -48,5 +48,6 @@ group("ets_frontend") { deps = [ "//arkcompiler/ets_frontend/es2panda:es2panda", "//arkcompiler/ets_frontend/merge_abc:merge_abc", + "//arkcompiler/ets_frontend/ts2panda:ts2abc_build", ] } diff --git a/build/prebuilts_download/prebuilts_download.py b/build/prebuilts_download/prebuilts_download.py index 31d2b5c..90f4e43 100644 --- a/build/prebuilts_download/prebuilts_download.py +++ b/build/prebuilts_download/prebuilts_download.py @@ -179,6 +179,19 @@ def _npm_install(args, code_dir, unzip_dir, unzip_filename): if proc.returncode: raise Exception(err.decode()) +def _node_modules_copy(config, code_dir): + for config_info in config: + src_dir = os.path.join(code_dir, config_info.get('src')) + dest_dir = os.path.join(code_dir, config_info.get('dest')) + use_symlink = config_info.get('use_symlink') + if os.path.exists(os.path.dirname(dest_dir)): + shutil.rmtree(os.path.dirname(dest_dir)) + if use_symlink == 'True': + os.makedirs(os.path.dirname(dest_dir)) + os.symlink(src_dir, dest_dir) + else: + shutil.copytree(src_dir, dest_dir, symlinks=True) + def _file_handle(config, code_dir): for config_info in config: src_dir = ''.join([code_dir, config_info.get('src')]) @@ -238,6 +251,7 @@ def main(): copy_config.extend(darwin_copy_config) _hwcloud_download(args, copy_config, args.bin_dir, args.code_dir) _file_handle(file_handle_config, args.code_dir) + _node_modules_copy(node_modules_copy_config, args.code_dir) if __name__ == '__main__': sys.exit(main()) diff --git a/build/prebuilts_download/prebuilts_download_config.json b/build/prebuilts_download/prebuilts_download_config.json index adda45a..216e2a8 100644 --- a/build/prebuilts_download/prebuilts_download_config.json +++ b/build/prebuilts_download/prebuilts_download_config.json @@ -1,5 +1,13 @@ { "prebuilts_download_dir": "../OpenHarmony_canary_prebuilts", + "npm_install_path": ["arkcompiler/ets_frontend/ts2panda"], + "node_modules_copy": [ + { + "src": "arkcompiler/ets_frontend/ts2panda/node_modules", + "dest": "prebuilts/build-tools/common/ts2abc/node_modules", + "use_symlink": "True" + } + ], "file_handle_config": [ { "src": "/prebuilts/clang/ohos/linux-x86_64/clang_linux-x86_64-942740-20220927", @@ -25,6 +33,11 @@ "unzip_dir": "prebuilts/ark_tools", "file_path": "/openharmony/compiler/llvm_prebuilt_libs/ark_js_prebuilts_20220923.tar.gz", "unzip_filename": "ark_js_prebuilts" + }, + { + "unzip_dir": "prebuilts/build-tools/common/nodejs", + "file_path": "/nodejs/v12.18.4/node-v12.18.4-linux-x64.tar.gz", + "unzip_filename": "node-v12.18.4-linux-x64" } ], "linux_copy_config": [ diff --git a/build/third_party_gn/jsoncpp/BUILD.gn b/build/third_party_gn/jsoncpp/BUILD.gn new file mode 100644 index 0000000..1455494 --- /dev/null +++ b/build/third_party_gn/jsoncpp/BUILD.gn @@ -0,0 +1,81 @@ +# Copyright (c) 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("config_static") { + cflags = [ + "-std=c++17", + "-Wno-error=implicit-fallthrough", + "-Wno-deprecated-declarations", + ] + visibility = [ ":*" ] + include_dirs = [ "//third_party/jsoncpp/include" ] +} + +config("jsoncpp_config") { + cflags = [ + "-std=c++17", + "-Wno-error=implicit-fallthrough", + "-Wno-deprecated-declarations", + ] +} + +config("flag_config") { + cflags_cc = [ "-fexceptions" ] +} + +config("jsoncpp_public_config") { + include_dirs = [ "//third_party/jsoncpp/include/" ] +} + +ohos_shared_library("jsoncpp") { + visibility = [ "*" ] + sources = [ + "//third_party/jsoncpp/src/lib_json/json_reader.cpp", + "//third_party/jsoncpp/src/lib_json/json_value.cpp", + "//third_party/jsoncpp/src/lib_json/json_writer.cpp", + ] + use_exceptions = true + configs = [ ":jsoncpp_config" ] + include_dirs = [ + "//third_party/jsoncpp/include/json/", + "//third_party/jsoncpp/include/", + ] + public_configs = [ ":jsoncpp_public_config" ] + part_name = "jsoncpp" + subsystem_name = "thirdparty" +} + +ohos_static_library("jsoncpp_static") { + sources = [ + "//third_party/jsoncpp/src/lib_json/json_reader.cpp", + "//third_party/jsoncpp/src/lib_json/json_value.cpp", + "//third_party/jsoncpp/src/lib_json/json_writer.cpp", + ] + use_exceptions = true + configs = [ ":config_static" ] + public_configs = [ ":jsoncpp_public_config" ] + include_dirs = [ + "//third_party/jsoncpp/include/json/", + "//third_party/jsoncpp/include/", + ] + cflags_cc = [ + "-DJSON_USE_EXCEPTION=0", + "-Wall", + "-Werror", + "-Wno-implicit-fallthrough", + ] + part_name = "jsoncpp" + subsystem_name = "thirdparty" +}