• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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")
15
16if (ark_standalone_build) {
17  import("$build_root/ark.gni")
18} else {
19  import("//build/ohos.gni")
20}
21
22# NB! Standard library is built only if the front-end is available.
23with_stdlib = false
24foreach(plugin, ark_enabled_plugins) {
25  if (plugin == "ecmascript" || plugin == "ets") {
26    with_stdlib = true
27  }
28}
29
30group("ark_packages") {
31  deps = [ "runtime/napi/etsnative:etsnative" ]
32
33  if (ark_static_standalone_build) {
34    deps += [ "$ark_es2panda_root/aot:ets2panda" ]
35  }
36  if (with_stdlib) {
37    deps += [ ":etsstdlib" ]
38  }
39  if (ark_ets_interop_js) {
40    deps += [ "runtime/interop_js:ets_interop_js_napi" ]
41  }
42}
43
44group("ark_host_linux_tools_packages") {
45}
46
47group("ark_host_windows_tools_packages") {
48  # Required, but empty: nothing to add currently
49}
50
51group("ark_host_mac_tools_packages") {
52  # Required, but empty: nothing to add currently
53}
54
55config("ark_config") {
56  defines = [ "PANDA_WITH_ETS" ]
57
58  if (ark_ets_interop_js) {
59    defines += [ "PANDA_ETS_INTEROP_JS" ]
60  }
61}
62
63# TODO(nsizov): Fix and clean after PR480 is merged
64group("assembler_deps") {
65  deps = [ ":ark_asm_ets_meta_gen_h" ]
66}
67config("assembler") {
68  include_dirs = [
69    "$ark_root/plugins/ets/assembler/extension",
70    "$target_gen_dir",
71  ]
72}
73ark_gen_file("ark_asm_ets_meta_gen_h") {
74  template_file = "$ark_root/assembler/templates/meta_gen.cpp.erb"
75  data = [ "$ark_root/plugins/ets/assembler/extension/metadata.yaml" ]
76  api = [ "$ark_root/assembler/asm_metadata.rb" ]
77  output_file = "$target_gen_dir/ets_meta_gen.h"
78}
79
80config("runtime") {
81  include_dirs = [ "$ark_root/plugins/ets/runtime" ]
82  configs = [
83    "$ark_es2panda_root:libes2panda_public_config",
84    "$ark_root/assembler:arkassembler_public_config",
85    "$ark_root/libpandafile:arkfile_public_config",
86  ]
87}
88
89config("runtime_interpreter_impl") {
90  # Required, but empty: nothing to add currently
91}
92
93config("bytecodeopt") {
94  include_dirs = [
95    "$ark_root/plugins/ets/bytecode_optimizer/",
96    "$target_gen_dir",
97  ]
98}
99
100ark_isa_gen("isa_gen_ets_bytecodeopt") {
101  template_files = [ "ets_codegen_intrinsics_gen.inc.erb" ]
102  sources = "$ark_root/plugins/ets/bytecode_optimizer/templates/"
103  destination = "$target_gen_dir/"
104  requires = [ "$ark_root/assembler/asm_isapi.rb" ]
105}
106
107if (with_stdlib) {
108  es2panda_gen("etsstdlib") {
109    inputs = [ "stdlib" ]
110    if (ark_static_standalone_build) {
111      outputs = [ "$root_build_dir/plugins/ets/etsstdlib.abc" ]
112    } else {
113      outputs = [ "$target_gen_dir/etsstdlib.abc" ]
114    }
115    abs_ark_root = rebase_path(ark_root)
116    json_array = [
117      "{",
118      "  \"compilerOptions\": {",
119      "    \"baseUrl\": \"$abs_ark_root\",",
120      "    \"paths\": {",
121      "      \"std\": [\"$abs_ark_root" + "/plugins/ets/stdlib/std\"],",
122      "      \"escompat\": [\"$abs_ark_root" +
123          "/plugins/ets/stdlib/escompat\"],",
124      "      \"import_tests\": [\"$abs_ark_root" +
125          "$ark_es2panda_root/test/parser/ets/import_tests\"]",
126      "    }",
127      "  }",
128      "}",
129    ]
130    default_arktsconfig =
131        get_label_info("$ark_es2panda_root/aot:ets2panda(${host_toolchain})",
132                       "root_out_dir")
133
134    if (ark_static_standalone_build) {
135      default_arktsconfig += "/bin"
136    } else {
137      default_arktsconfig += "/arkcompiler/ets_frontend"
138    }
139
140    write_file("$root_build_dir/tools/es2panda/generated/arktsconfig.json",
141               json_array,
142               "list lines")
143    write_file("$default_arktsconfig/arktsconfig.json",
144               json_array,
145               "list lines")
146
147    args = [
148      "--extension=sts",
149      "--opt-level=2",
150      "--gen-stdlib=true",
151      "--output=" + rebase_path(outputs[0], root_build_dir),
152    ]
153  }
154
155  action("ets-compile-stdlib-default") {
156    # Running ark_aot compilation for etsstdlib with default options
157    script = "$ark_root/plugins/ets/compiler/tools/paoc_compile_stdlib.sh"
158    outputs = [ "$root_build_dir/plugins/ets/etsstdlib.an" ]
159
160    deps = [
161      ":etsstdlib",
162      "$ark_root/compiler/tools/paoc:ark_aot",
163    ]
164
165    args = [
166      "--binary-dir=" + rebase_path(root_build_dir),
167      "-compiler-options=--compiler-check-final=true",
168      "-paoc-output=" + rebase_path(outputs[0], root_build_dir),
169    ]
170  }
171
172  group("ets_func_tests") {
173    deps = [ "tests:ets_func_tests_int_jit_aot" ]
174  }
175}
176