# Copyright (c) 2021-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") if (ark_standalone_build) { import("$build_root/ark.gni") } else { import("//build/ohos.gni") } # NB! Standard library is built only if the front-end is available. with_stdlib = false foreach(plugin, ark_enabled_plugins) { if (plugin == "ecmascript" || plugin == "ets") { with_stdlib = true } } group("ark_packages") { deps = [ "runtime/napi/etsnative:etsnative" ] if (ark_static_standalone_build) { deps += [ "$ark_es2panda_root/aot:ets2panda" ] } if (with_stdlib) { deps += [ ":etsstdlib" ] } if (ark_ets_interop_js) { deps += [ "runtime/interop_js:ets_interop_js_napi" ] } } group("ark_host_linux_tools_packages") { } group("ark_host_windows_tools_packages") { # Required, but empty: nothing to add currently } group("ark_host_mac_tools_packages") { # Required, but empty: nothing to add currently } config("ark_config") { defines = [ "PANDA_WITH_ETS" ] if (ark_ets_interop_js) { defines += [ "PANDA_ETS_INTEROP_JS" ] } } # TODO(nsizov): Fix and clean after PR480 is merged group("assembler_deps") { deps = [ ":ark_asm_ets_meta_gen_h" ] } config("assembler") { include_dirs = [ "$ark_root/plugins/ets/assembler/extension", "$target_gen_dir", ] } ark_gen_file("ark_asm_ets_meta_gen_h") { template_file = "$ark_root/assembler/templates/meta_gen.cpp.erb" data = [ "$ark_root/plugins/ets/assembler/extension/metadata.yaml" ] api = [ "$ark_root/assembler/asm_metadata.rb" ] output_file = "$target_gen_dir/ets_meta_gen.h" } config("runtime") { include_dirs = [ "$ark_root/plugins/ets/runtime" ] configs = [ "$ark_es2panda_root:libes2panda_public_config", "$ark_root/assembler:arkassembler_public_config", "$ark_root/libpandafile:arkfile_public_config", ] } config("runtime_interpreter_impl") { # Required, but empty: nothing to add currently } config("bytecodeopt") { include_dirs = [ "$ark_root/plugins/ets/bytecode_optimizer/", "$target_gen_dir", ] } ark_isa_gen("isa_gen_ets_bytecodeopt") { template_files = [ "ets_codegen_intrinsics_gen.inc.erb" ] sources = "$ark_root/plugins/ets/bytecode_optimizer/templates/" destination = "$target_gen_dir/" requires = [ "$ark_root/assembler/asm_isapi.rb" ] } if (with_stdlib) { es2panda_gen("etsstdlib") { inputs = [ "stdlib" ] if (ark_static_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 = [ "{", " \"compilerOptions\": {", " \"baseUrl\": \"$abs_ark_root\",", " \"paths\": {", " \"std\": [\"$abs_ark_root" + "/plugins/ets/stdlib/std\"],", " \"escompat\": [\"$abs_ark_root" + "/plugins/ets/stdlib/escompat\"],", " \"import_tests\": [\"$abs_ark_root" + "$ark_es2panda_root/test/parser/ets/import_tests\"]", " }", " }", "}", ] default_arktsconfig = get_label_info("$ark_es2panda_root/aot:ets2panda(${host_toolchain})", "root_out_dir") if (ark_static_standalone_build) { default_arktsconfig += "/bin" } else { default_arktsconfig += "/arkcompiler/ets_frontend" } write_file("$root_build_dir/tools/es2panda/generated/arktsconfig.json", json_array, "list lines") write_file("$default_arktsconfig/arktsconfig.json", json_array, "list lines") args = [ "--extension=sts", "--opt-level=2", "--gen-stdlib=true", "--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" ] } }