# 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") 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_standalone_build) { deps += [ "$ark_es2panda_root/aot:ets2panda" ] } else { external_deps = [ "ets_frontend: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" ] 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") default_arktsconfig += "/arkcompiler/ets_frontend" write_file("$root_gen_dir/tools/es2panda/generated/arktsconfig.json", json_array, "list lines") write_file("$default_arktsconfig/arktsconfig.json", json_array, "list lines") sources = [ "stdlib/escompat/Array.sts", "stdlib/escompat/ArrayBuffer.sts", "stdlib/escompat/DataView.sts", "stdlib/escompat/Date.sts", "stdlib/escompat/Error.sts", "stdlib/escompat/Errors.sts", "stdlib/escompat/Map.sts", "stdlib/escompat/Math.sts", "stdlib/escompat/Number.sts", "stdlib/escompat/RegExp.sts", "stdlib/escompat/Set.sts", "stdlib/escompat/TypedArrays.sts", "stdlib/escompat/json.sts", "stdlib/std/containers/AVLTree.sts", "stdlib/std/containers/ArrayAsListInt.sts", "stdlib/std/containers/ArrayAsListObject.sts", "stdlib/std/containers/ListInt.sts", "stdlib/std/containers/ListObject.sts", "stdlib/std/core/Boolean.sts", "stdlib/std/core/Byte.sts", "stdlib/std/core/Char.sts", "stdlib/std/core/Comparable.sts", "stdlib/std/core/Console.sts", "stdlib/std/core/Double.sts", "stdlib/std/core/Exception.sts", "stdlib/std/core/Exceptions.sts", "stdlib/std/core/Field.sts", "stdlib/std/core/FinalizationRegistry.sts", "stdlib/std/core/Float.sts", "stdlib/std/core/GC.sts", "stdlib/std/core/Int.sts", "stdlib/std/core/Long.sts", "stdlib/std/core/Method.sts", "stdlib/std/core/Numeric.sts", "stdlib/std/core/Object.sts", "stdlib/std/core/Parameter.sts", "stdlib/std/core/Runtime.sts", "stdlib/std/core/Short.sts", "stdlib/std/core/StackTrace.sts", "stdlib/std/core/String.sts", "stdlib/std/core/StringBuilder.sts", "stdlib/std/core/System.sts", "stdlib/std/core/Type.sts", "stdlib/std/core/UnionCase.sts", "stdlib/std/core/Value.sts", "stdlib/std/core/WeakRef.sts", "stdlib/std/math/consts/consts.sts", "stdlib/std/math/math.sts", ] args = [ "--extension=sts", "--opt-level=2", "--gen-stdlib=true", "--output=" + rebase_path(outputs[0], root_build_dir), ] } }