1# Copyright (c) 2021-2024 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//arkcompiler/runtime_core/static_core/ark_config.gni") 15import("//build/ohos.gni") 16 17# NB! Standard library is built only if the front-end is available. 18with_stdlib = false 19foreach(plugin, ark_enabled_plugins) { 20 if (plugin == "ecmascript" || plugin == "ets") { 21 with_stdlib = true 22 } 23} 24 25group("ark_packages") { 26 deps = [ "runtime/napi/etsnative:etsnative" ] 27 28 if (ark_standalone_build) { 29 deps += [ "$ark_es2panda_root/aot:ets2panda" ] 30 } else { 31 external_deps = [ "ets_frontend:ets2panda" ] 32 } 33 34 if (with_stdlib) { 35 deps += [ ":etsstdlib" ] 36 } 37 if (ark_ets_interop_js) { 38 deps += [ "runtime/interop_js:ets_interop_js_napi" ] 39 } 40} 41 42group("ark_host_linux_tools_packages") { 43} 44 45group("ark_host_windows_tools_packages") { 46 # Required, but empty: nothing to add currently 47} 48 49group("ark_host_mac_tools_packages") { 50 # Required, but empty: nothing to add currently 51} 52 53config("ark_config") { 54 defines = [ "PANDA_WITH_ETS" ] 55 56 if (ark_ets_interop_js) { 57 defines += [ "PANDA_ETS_INTEROP_JS" ] 58 } 59} 60 61# TODO(nsizov): Fix and clean after PR480 is merged 62group("assembler_deps") { 63 deps = [ ":ark_asm_ets_meta_gen_h" ] 64} 65config("assembler") { 66 include_dirs = [ 67 "$ark_root/plugins/ets/assembler/extension", 68 "$target_gen_dir", 69 ] 70} 71ark_gen_file("ark_asm_ets_meta_gen_h") { 72 template_file = "$ark_root/assembler/templates/meta_gen.cpp.erb" 73 data = [ "$ark_root/plugins/ets/assembler/extension/metadata.yaml" ] 74 api = [ "$ark_root/assembler/asm_metadata.rb" ] 75 output_file = "$target_gen_dir/ets_meta_gen.h" 76} 77 78config("runtime") { 79 include_dirs = [ "$ark_root/plugins/ets/runtime" ] 80 configs = [ 81 "$ark_es2panda_root:libes2panda_public_config", 82 "$ark_root/assembler:arkassembler_public_config", 83 "$ark_root/libpandafile:arkfile_public_config", 84 ] 85} 86 87config("runtime_interpreter_impl") { 88 # Required, but empty: nothing to add currently 89} 90 91config("bytecodeopt") { 92 include_dirs = [ 93 "$ark_root/plugins/ets/bytecode_optimizer/", 94 "$target_gen_dir", 95 ] 96} 97 98ark_isa_gen("isa_gen_ets_bytecodeopt") { 99 template_files = [ "ets_codegen_intrinsics_gen.inc.erb" ] 100 sources = "$ark_root/plugins/ets/bytecode_optimizer/templates/" 101 destination = "$target_gen_dir/" 102 requires = [ "$ark_root/assembler/asm_isapi.rb" ] 103} 104 105if (with_stdlib) { 106 es2panda_gen("etsstdlib") { 107 inputs = [ "stdlib" ] 108 outputs = [ "$target_gen_dir/etsstdlib.abc" ] 109 abs_ark_root = rebase_path(ark_root) 110 json_array = [ 111 "{", 112 " \"compilerOptions\": {", 113 " \"baseUrl\": \"$abs_ark_root\",", 114 " \"paths\": {", 115 " \"std\": [\"$abs_ark_root" + "/plugins/ets/stdlib/std\"],", 116 " \"escompat\": [\"$abs_ark_root" + 117 "/plugins/ets/stdlib/escompat\"],", 118 " \"import_tests\": [\"$abs_ark_root" + 119 "$ark_es2panda_root/test/parser/ets/import_tests\"]", 120 " }", 121 " }", 122 "}", 123 ] 124 125 default_arktsconfig = 126 get_label_info("$ark_es2panda_root/aot:ets2panda(${host_toolchain})", 127 "root_out_dir") 128 default_arktsconfig += "/arkcompiler/ets_frontend" 129 130 write_file("$root_gen_dir/tools/es2panda/generated/arktsconfig.json", 131 json_array, 132 "list lines") 133 write_file("$default_arktsconfig/arktsconfig.json", 134 json_array, 135 "list lines") 136 sources = [ 137 "stdlib/escompat/Array.sts", 138 "stdlib/escompat/ArrayBuffer.sts", 139 "stdlib/escompat/DataView.sts", 140 "stdlib/escompat/Date.sts", 141 "stdlib/escompat/Error.sts", 142 "stdlib/escompat/Errors.sts", 143 "stdlib/escompat/Map.sts", 144 "stdlib/escompat/Math.sts", 145 "stdlib/escompat/Number.sts", 146 "stdlib/escompat/RegExp.sts", 147 "stdlib/escompat/Set.sts", 148 "stdlib/escompat/TypedArrays.sts", 149 "stdlib/escompat/json.sts", 150 "stdlib/std/containers/AVLTree.sts", 151 "stdlib/std/containers/ArrayAsListInt.sts", 152 "stdlib/std/containers/ArrayAsListObject.sts", 153 "stdlib/std/containers/ListInt.sts", 154 "stdlib/std/containers/ListObject.sts", 155 "stdlib/std/core/Boolean.sts", 156 "stdlib/std/core/Byte.sts", 157 "stdlib/std/core/Char.sts", 158 "stdlib/std/core/Comparable.sts", 159 "stdlib/std/core/Console.sts", 160 "stdlib/std/core/Double.sts", 161 "stdlib/std/core/Exception.sts", 162 "stdlib/std/core/Exceptions.sts", 163 "stdlib/std/core/Field.sts", 164 "stdlib/std/core/FinalizationRegistry.sts", 165 "stdlib/std/core/Float.sts", 166 "stdlib/std/core/GC.sts", 167 "stdlib/std/core/Int.sts", 168 "stdlib/std/core/Long.sts", 169 "stdlib/std/core/Method.sts", 170 "stdlib/std/core/Numeric.sts", 171 "stdlib/std/core/Object.sts", 172 "stdlib/std/core/Parameter.sts", 173 "stdlib/std/core/Runtime.sts", 174 "stdlib/std/core/Short.sts", 175 "stdlib/std/core/StackTrace.sts", 176 "stdlib/std/core/String.sts", 177 "stdlib/std/core/StringBuilder.sts", 178 "stdlib/std/core/System.sts", 179 "stdlib/std/core/Type.sts", 180 "stdlib/std/core/UnionCase.sts", 181 "stdlib/std/core/Value.sts", 182 "stdlib/std/core/WeakRef.sts", 183 "stdlib/std/math/consts/consts.sts", 184 "stdlib/std/math/math.sts", 185 ] 186 args = [ 187 "--extension=sts", 188 "--opt-level=2", 189 "--gen-stdlib=true", 190 "--output=" + rebase_path(outputs[0], root_build_dir), 191 ] 192 } 193} 194