[GN] Fix gn standalone build and add tests

Install Node.js, build ets_interop_js_napi, generate etsstdlib.an in gn standalone build. Create target for ets-func-tests.
Add script to download gn and build panda with it.

Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/IACEKA

Test: ninja ets_func_tests

Signed-off-by: Rokashevich Svetlana <rokashevich.svetlana1@huawei-partners.com>
This commit is contained in:
Rokashevich Svetlana 2024-07-05 14:46:42 +03:00
parent f6277abf1e
commit a167e29670
20 changed files with 268 additions and 58 deletions

View File

@ -241,7 +241,7 @@ if(PANDA_WITH_TOOLCHAIN)
add_subdirectory(${PANDA_THIRD_PARTY_CONFIG_DIR}/securec)
set(OPENSSL_ROOT ${PANDA_THIRD_PARTY_SOURCES_DIR}/openssl)
add_subdirectory(${PANDA_THIRD_PARTY_CONFIG_DIR}/openssl)
set(TOOLCHAIN_ROOT ${PANDA_THIRD_PARTY_SOURCES_DIR}/arkcompiler_toolchain)
set(TOOLCHAIN_ROOT ${PANDA_THIRD_PARTY_SOURCES_DIR}/arkcompiler/toolchain)
add_subdirectory(${PANDA_THIRD_PARTY_CONFIG_DIR}/toolchain_websocket)
add_subdirectory(libpandabase)

View File

@ -126,6 +126,15 @@ $ cmake -DQEMU_PREFIX=/opt/qemu-6.2.0 ...
## Building with GN
### Using bootstrap
Build `arkts_bin`, `ark_aot`, `es2panda`, `verifier_bin` and `ets_interop_js_napi` targets.
```
./scripts/build-panda-with-gn
```
### Mannually
1. Getting GN binary
```
@ -145,7 +154,7 @@ $ ninja -C out arkts_bin
When standard system, use
```
$ cd /path/to/panda/repository
$ /path/to/gn/repository/out/gn --args=-is_standard_system=true gen out
$ /path/to/gn/repository/out/gn --args=is_standard_system=true gen out
$ ninja -C out <target name>
```
To use LLVM Backend add the following arguments:

View File

@ -388,13 +388,17 @@ template("es2panda_gen") {
es2panda_root_out =
get_label_info("$ark_es2panda_root/aot:ets2panda(${host_toolchain})",
"root_out_dir")
script = es2panda_root_out + "/arkcompiler/ets_frontend/es2panda"
if (ark_standalone_build) {
deps = [ "$ark_es2panda_root/aot:ets2panda" ]
es2panda_bin = "/bin/es2panda"
} else {
external_deps = [ "ets_frontend:ets2panda(${host_toolchain})" ]
es2panda_bin = "/arkcompiler/ets_frontend/es2panda"
}
script = es2panda_root_out + es2panda_bin
inputs = invoker.inputs
outputs = invoker.outputs
sources = invoker.sources

View File

@ -35,6 +35,11 @@ if (enable_codegen) {
]
deps = []
defines = []
if (ark_standalone_build) {
deps += [ sdk_libc_secshared_dep ]
}
external_deps = [ sdk_libc_secshared_dep ]
if (target_cpu == "x86") {

View File

@ -18,19 +18,9 @@ template("ohos_executable") {
[
"install_images",
"part_name",
"external_deps",
])
if (defined(invoker.external_deps) && invoker.external_deps != []) {
if (!defined(invoker.deps)) {
invoker.deps = []
}
foreach(dep, invoker.external_deps) {
if (label_matches(dep, [ "//third_party/*" ])) {
invoker.deps += [ dep ]
}
}
}
executable("${target_name}") {
forward_variables_from(invoker,
"*",
@ -64,19 +54,9 @@ template("ohos_shared_library") {
[
"install_images",
"part_name",
"external_deps",
])
if (defined(invoker.external_deps) && invoker.external_deps != []) {
if (!defined(invoker.deps)) {
invoker.deps = []
}
foreach(dep, invoker.external_deps) {
if (label_matches(dep, [ "//third_party/*" ])) {
invoker.deps += [ dep ]
}
}
}
shared_library("${target_name}") {
forward_variables_from(invoker,
"*",
@ -108,18 +88,11 @@ template("ohos_shared_library") {
}
template("ohos_static_library") {
not_needed(invoker, [ "part_name" ])
if (defined(invoker.external_deps) && invoker.external_deps != []) {
if (!defined(invoker.deps)) {
invoker.deps = []
}
foreach(dep, invoker.external_deps) {
if (label_matches(dep, [ "//third_party/*" ])) {
invoker.deps += [ dep ]
}
}
}
not_needed(invoker,
[
"part_name",
"external_deps",
])
static_library("${target_name}") {
forward_variables_from(invoker,
@ -169,19 +142,9 @@ template("ohos_source_set") {
"public_external_deps",
"part_name",
"subsystem_name",
"external_deps",
])
if (defined(invoker.external_deps) && invoker.external_deps != []) {
if (!defined(invoker.deps)) {
invoker.deps = []
}
foreach(dep, invoker.external_deps) {
if (label_matches(dep, [ "//third_party/*" ])) {
invoker.deps += [ dep ]
}
}
}
source_set(target_name) {
forward_variables_from(invoker,
"*",

View File

@ -234,6 +234,10 @@ ohos_source_set("libarktsbase_static") {
deps = libarkbase_deps
if (ark_standalone_build) {
deps += [ sdk_libc_secshared_dep ]
}
external_deps = [ sdk_libc_secshared_dep ]
part_name = ark_part_name

View File

@ -30,12 +30,13 @@ ohos_source_set("libarktsziparchive_static") {
"$ark_root/libpandabase:arkbase_public_config",
]
deps = [ "$ark_root/libpandabase:libarktsbase" ]
if (ark_standalone_build) {
public_configs += [ zlib_public_config ]
deps += [ zlib_dep ]
}
deps = [ "$ark_root/libpandabase:libarktsbase" ]
external_deps = [
sdk_libc_secshared_dep,
zlib_dep,
@ -64,12 +65,16 @@ ohos_source_set("libarktsziparchive_frontend_set_static") {
"$ark_root/libpandabase:arkbase_public_config",
]
deps = [ "$ark_root/libpandabase:logger_enum_gen_h" ]
if (ark_standalone_build) {
public_configs += [ zlib_public_config ]
deps += [
sdk_libc_secshared_dep,
zlib_dep,
]
}
deps = [ "$ark_root/libpandabase:logger_enum_gen_h" ]
external_deps = [
sdk_libc_secshared_dep,
zlib_dep,

View File

@ -105,7 +105,11 @@ ark_isa_gen("isa_gen_ets_bytecodeopt") {
if (with_stdlib) {
es2panda_gen("etsstdlib") {
inputs = [ "stdlib" ]
outputs = [ "$target_gen_dir/etsstdlib.abc" ]
if (ark_standalone_build) {
outputs = [ "$root_build_dir/plugins/ets/etsstdlib.abc" ]
} else {
outputs = [ "$target_gen_dir/etsstdlib.abc" ]
}
abs_ark_root = rebase_path(ark_root)
json_array = [
"{",
@ -125,7 +129,12 @@ if (with_stdlib) {
default_arktsconfig =
get_label_info("$ark_es2panda_root/aot:ets2panda(${host_toolchain})",
"root_out_dir")
default_arktsconfig += "/arkcompiler/ets_frontend"
if (ark_standalone_build) {
default_arktsconfig += "/bin"
} else {
default_arktsconfig += "/arkcompiler/ets_frontend"
}
write_file("$root_gen_dir/tools/es2panda/generated/arktsconfig.json",
json_array,
@ -190,4 +199,25 @@ if (with_stdlib) {
"--output=" + rebase_path(outputs[0], root_build_dir),
]
}
action("ets-compile-stdlib-default") {
# Running ark_aot compilation for etsstdlib with default options
script = "$ark_root/plugins/ets/compiler/tools/paoc_compile_stdlib.sh"
outputs = [ "$root_build_dir/plugins/ets/etsstdlib.an" ]
deps = [
":etsstdlib",
"$ark_root/compiler/tools/paoc:ark_aot",
]
args = [
"--binary-dir=" + rebase_path(root_build_dir),
"-compiler-options=--compiler-check-final=true",
"-paoc-output=" + rebase_path(outputs[0], root_build_dir),
]
}
group("ets_func_tests") {
deps = [ "tests:ets_func_tests_int_jit_aot" ]
}
}

View File

@ -54,6 +54,11 @@ ohos_source_set("ets_interop_js_napi_static") {
"$ark_root/libpandabase:libarktsbase",
"$ark_root/runtime:libarkruntime",
]
if (ark_standalone_build) {
deps += [ ":install_nodejs" ]
}
if (is_ohos && is_standard_system) {
defines = [ "PANDA_USE_OHOS_LOG" ]
deps += [ ":etsstdlib_install" ]
@ -73,3 +78,20 @@ ohos_shared_library("ets_interop_js_napi") {
part_name = ark_part_name
subsystem_name = "$ark_subsystem_name"
}
action("install_nodejs") {
script = "$ark_root/scripts/install-third-party"
outputs = [ target_out_dir ]
args = [ "--node" ]
}
config("interop_js_public_config") {
if (ark_standalone_build) {
node_version = "v18.13.0"
distro = "linux-x64"
include_dirs = [ "$ark_root/third_party/nodejs/node-${node_version}-${distro}/include/node" ]
}
}

View File

@ -150,6 +150,8 @@ srcs_runtime = [
"stdlib/native/escompat/Process.cpp",
]
configs_runtime = []
if (ark_ets_interop_js) {
srcs_runtime += [
"runtime/interop_js/call/call_ets.cpp",
@ -183,6 +185,12 @@ if (ark_ets_interop_js) {
} else if (current_cpu == "arm") {
srcs_runtime += [ "runtime/interop_js/arch/arm32/call_bridge_arm32.S" ]
}
configs_runtime += [ "runtime/interop_js:interop_js_public_config" ]
if (ark_standalone_build) {
arkruntime_deps += [ "$ark_root/plugins/ets/runtime/interop_js:install_nodejs" ]
}
}
if (current_cpu == "amd64" || current_cpu == "x64" || current_cpu == "x86_64") {

View File

@ -0,0 +1,85 @@
# Copyright (c) 2024 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/runtime_core/static_core/ark_config.gni")
nproc = getenv("NPROC_PER_JOB")
if (nproc == "") {
nproc = 12
}
action("ets_func_tests_int_jit_aot") {
script = "/bin/bash"
outputs = [ "$target_out_dir/ets_func_tests" ]
deps = [
"$ark_root/compiler/tools/paoc:ark_aot",
"$ark_root/panda:arkts_bin",
"$ark_root/plugins/ets:ets-compile-stdlib-default",
"$ark_root/plugins/ets:etsstdlib",
"$ark_root/verification/verifier:verifier_bin",
]
if (ark_standalone_build) {
deps += [ "$ark_es2panda_root/aot:ets2panda" ]
} else {
external_deps = [ "ets_frontend:ets2panda(${host_toolchain})" ]
}
runner_path = rebase_path("$ark_root/tests/tests-u-runner/runner.sh")
args_common = [
"--ets-func-tests",
"--build-dir=" + rebase_path(root_build_dir),
"--force-generate",
"--es2panda-opt-level=2",
"--gc-type=g1-gc",
"--processes=$nproc",
]
args_int = [
"--timeout=30",
"--heap-verifier=fail_on_verification:pre:into:before_g1_concurrent:post",
]
args_jit = [
"--timeout=90",
"--heap-verifier=fail_on_verification:pre:into:post",
"--jit",
"--ark-args=--no-async-jit=true",
"--ark-args=--compiler-ignore-failures=false",
]
args_aot = [
"--timeout=30",
"--heap-verifier=fail_on_verification:pre:into:before_g1_concurrent:post",
"--aot",
"--ark-args=--compiler-check-final=true",
"--ark-args=--compiler-ignore-failures=false",
"--ark-args=--enable-an:force",
]
string_args_int = string_join(" ", args_common + args_int)
string_args_jit = string_join(" ", args_common + args_jit)
string_args_aot = string_join(" ", args_common + args_aot)
command_str = "$runner_path $string_args_int;$runner_path $string_args_jit;$runner_path $string_args_aot;"
if (is_asan) {
command_str = "$runner_path $string_args_int;"
}
args = [
"-c",
"$command_str",
]
}

View File

@ -151,6 +151,11 @@ foreach(plugin, ark_enabled_plugins) {
plugin_runtime_sources += [ "$_plugin_dir/$src" ]
}
}
if (defined(_plugin_vars.configs_runtime)) {
foreach(src, _plugin_vars.configs_runtime) {
plugin_runtime_configs += [ "$_plugin_dir/$src" ]
}
}
if (defined(_plugin_vars.srcs_verification)) {
foreach(src, _plugin_vars.srcs_verification) {
plugin_verifier_sources += [ "$_plugin_dir/$src" ]

View File

@ -358,6 +358,8 @@ ohos_source_set("libarkruntime_set_static") {
"$ark_root/runtime/asm_defines:asmdefines_public_config",
]
public_configs += plugin_runtime_configs
deps = [
":arkruntime_header_deps",
":arkruntime_interpreter_impl",
@ -373,6 +375,10 @@ ohos_source_set("libarkruntime_set_static") {
"$ark_root/runtime/asm_defines:asm_defines_generator",
]
if (ark_standalone_build) {
deps += [ icui18n_dep ]
}
external_deps = [
"napi:ace_napi",
icui18n_dep,

View File

@ -71,7 +71,7 @@ else()
)
list(APPEND ARKINSPECTOR_LINKED_LIBRARIES toolchain_websocket)
set(ARKINSPECTOR_INCLUDES
${PANDA_THIRD_PARTY_SOURCES_DIR}/arkcompiler_toolchain/
${PANDA_THIRD_PARTY_SOURCES_DIR}/arkcompiler/toolchain/
)
endif()

View File

@ -0,0 +1,26 @@
#!/bin/bash
# Copyright (c) 2024 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.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
ARK_ROOT=$SCRIPT_DIR/..
ARK_THIRD_PARTY_DIR=$ARK_ROOT/third_party
GN_PATH=$ARK_THIRD_PARTY_DIR/prebuilts/build-tools/linux-x86/bin/gn
if [ ! -d $GN_PATH ]; then
$SCRIPT_DIR/install-arkcompiler-toolchain-prebuilts
fi
cd $ARK_ROOT
$GN_PATH gen out --args="is_standard_system=true ark_ets_interop_js=true"
ninja -C out arkts_bin ark_aot ets2panda verifier_bin ets_interop_js_napi

View File

@ -315,6 +315,11 @@ def get_file_list(panda_dir: str, build_dir: str, filename_filter: str) -> list:
file_list = []
for cmd in cmds_json:
# this check is needed to exclude symlinks in third_party
file_path_raw = cmd["file"]
if need_to_ignore_file(file_path_raw, panda_dir, build_dir):
continue
file_path = str(os.path.realpath(cmd["file"]))
if need_to_ignore_file(file_path, panda_dir, build_dir):
continue

View File

@ -0,0 +1,27 @@
#!/bin/bash
# Copyright (c) 2024 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.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
ARK_ROOT=$SCRIPT_DIR/..
ARK_THIRD_PARTY_DIR=$ARK_ROOT/third_party
PREBUILTS_DOWNLOAD_SCRIPT=$ARK_THIRD_PARTY_DIR/prebuilts_download.sh
if [ ! -d "${ARK_THIRD_PARTY_DIR}/prebuilts" ]; then
if [ ! -f ${PREBUILTS_DOWNLOAD_SCRIPT} ]; then
ln -s ${ARK_THIRD_PARTY_DIR}/arkcompiler/toolchain/build/prebuilts_download/prebuilts_download.sh $PREBUILTS_DOWNLOAD_SCRIPT
fi
cd $ARK_THIRD_PARTY_DIR && $PREBUILTS_DOWNLOAD_SCRIPT
rm -rf $ARK_ROOT/openharmony_prebuilts
fi

View File

@ -245,7 +245,12 @@ if [[ "$ARK_INSTALL_NODE" == "yes" ]] ; then
fi
if [[ "$ARK_THIRD_PARTY_FORCE_CLONE" == "yes" ]] ; then
rm -rf "$ARK_THIRD_PARTY_DIR"
if [[ -L "$ARK_THIRD_PARTY_DIR/arkcompiler/toolchain" ]] ; then
# remove all folders in third_party except arkcompiler if arkcompiler/toolchain is symlink
cd "$ARK_THIRD_PARTY_DIR" && rm -rf `ls | grep -v arkcompiler`
else
rm -rf "$ARK_THIRD_PARTY_DIR"
fi
fi
if [[ -d "$ARK_THIRD_PARTY_DIR" && ${#REPOS[@]} -eq 0 ]] ; then

View File

@ -45,7 +45,7 @@ rapidcheck,https://github.com/emil-e/rapidcheck,commit,8fafda42e732164db58003e54
asio,https://github.com/chriskohlhoff/asio,tag,asio-1-18-1,no_patches,no_submodules
websocketpp,https://github.com/zaphoyd/websocketpp,tag,0.8.2,no_patches,no_submodules
openssl,https://gitee.com/openharmony/third_party_openssl,branch,OpenHarmony-4.0-Release,no_patches,no_submodules
arkcompiler_toolchain,https://gitee.com/openharmony/arkcompiler_toolchain,branch,master,no_patches,no_submodules
arkcompiler/toolchain,https://gitee.com/openharmony/arkcompiler_toolchain,branch,master,no_patches,no_submodules
# ARK plugins:
icu,https://gitee.com/openharmony/third_party_icu,branch,OpenHarmony-3.2-Beta3,no_patches,no_submodules

View File

@ -30,7 +30,8 @@ source "${ROOT_DIR}/scripts/python/venv-utils.sh"
activate_venv
set +e
echo "${RUNNER_OPTIONS}"
echo "RUNNER_OPTIONS=" "$RUNNER_OPTIONS"
echo "ALL OPTIONS:" "$@"
python3 -B "${RUNNER}" "$@"
EXIT_CODE=$?