• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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/ets_frontend/es2panda/es2abc_config.gni")
15import("//arkcompiler/ets_frontend/ets2panda/ets2abc_config.gni")
16import("//arkcompiler/runtime_core/ark_config.gni")
17import("//arkcompiler/runtime_core/libabckit/abckit_config.gni")
18
19template("expand_merge_rel_file") {
20  assert(defined(invoker.input_file), "input_file is required!")
21  assert(defined(invoker.output_file), "output_file is required!")
22  assert(defined(invoker.app_src_dir), "app_src_dir is required!")
23
24  action(target_name) {
25    script = "$abckit_root/scripts/rebase_merge_file.sh"
26
27    args = [
28      rebase_path(invoker.input_file),
29      rebase_path(invoker.output_file),
30      rebase_path(invoker.app_src_dir),
31    ]
32
33    print(script, string_join(" ", args))
34
35    extra_dependencies = []
36    forward_variables_from(invoker, [ "extra_dependencies" ])
37    deps = extra_dependencies
38
39    inputs = [ invoker.input_file ]
40
41    outputs = [ invoker.output_file ]
42  }
43}
44
45template("app_intts_to_abc") {
46  assert(defined(invoker.app), "app is required!")
47  assert(defined(invoker.apps_root), "apps_root is required!")
48
49  # _src_dir_ = invoker.app_src_dir
50  _src_dir_ = "${invoker.apps_root}/${invoker.app}"
51  _app_merge_rel_ = "${_src_dir_}/filesInfo.rel.txt"
52
53  _app_merge_ = "${target_out_dir}/${invoker.app}_filesInfo.txt"
54  _app_abc_ = "${target_out_dir}/${invoker.app}.abc"
55
56  expand_merge_rel_file("app_${invoker.app}_merge") {
57    input_file = "$_app_merge_rel_"
58    output_file = "$_app_merge_"
59    app_src_dir = "$_src_dir_"
60  }
61
62  es2abc_gen_abc(target_name) {
63    extra_visibility = [ ":*" ]
64
65    extra_dependencies = [ ":app_${invoker.app}_merge" ]
66
67    src_js = "@" + rebase_path(_app_merge_)
68    dst_file = rebase_path(_app_abc_)
69    extra_args = [
70      "--module",
71      "--merge-abc",
72      "--enable-annotations",
73    ]
74
75    extension = "ts"
76    in_puts = [ _app_merge_ ]
77    out_puts = [ _app_abc_ ]
78  }
79}
80
81template("stress_test_action") {
82  assert(defined(invoker.input_abc), "input_abc should be defined!")
83
84  _out_abc_ = "${target_out_dir}/${target_name}/stress.abc"
85  _host_test_target_ = ":${target_name}(${host_toolchain})"
86  _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
87
88  _abckit_binary_path_ =
89      rebase_path(_root_out_dir_) + "/arkcompiler/runtime_core/abckit"
90  _plugin_path_ = rebase_path(_root_out_dir_) +
91                  "/arkcompiler/runtime_core/libabckit_stress_plugin.so"
92  _abckit_binary_args_ = [
93    "--plugin-path",
94    _plugin_path_,
95    "--input-file",
96    rebase_path(invoker.input_abc),
97    "--output-file",
98    rebase_path(_out_abc_),
99  ]
100  _ld_library_paths_ = [
101    rebase_path(_root_out_dir_) + "/arkcompiler/runtime_core:",
102    rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:",
103    rebase_path(_root_out_dir_) + "/thirdparty/icu:",
104    rebase_path(_root_out_dir_) + "/thirdparty/zlib:",
105  ]
106
107  action(target_name) {
108    testonly = true
109
110    deps = [
111      "$abckit_root/abckit:abckit(${host_toolchain})",
112      "$abckit_root/tests/stress/abckit_plugin:abckit_stress_plugin(${host_toolchain})",
113    ]
114
115    if (defined(invoker.extra_dependencies)) {
116      deps += invoker.extra_dependencies
117    }
118
119    script = "$abckit_root/scripts/run_script.sh"
120
121    args = [
122      "--ret-code=0",
123      "--env=" + "LD_LIBRARY_PATH=" + string_join(":", _ld_library_paths_),
124      "--script=" + _abckit_binary_path_,
125      "--script-args=" + string_join(" ", _abckit_binary_args_),
126    ]
127
128    if (abckit_with_sanitizers) {
129      args += [ "--env=ASAN_OPTIONS=verify_asan_link_order=0" ]
130      args +=
131          [ "--env=LSAN_OPTIONS=suppressions=" + rebase_path("$abckit_root") +
132            "/tests/sanitizers/ignored_leaks.supp" ]
133    }
134
135    print(script, string_join(" ", args))
136
137    inputs = [ invoker.input_abc ]
138    outputs = [ _out_abc_ ]
139  }
140}
141
142template("stress_test_app_action") {
143  assert(defined(invoker.app), "app should be defined!")
144  forward_variables_from(invoker, [ "extra_dependencies" ])
145  _app_abc_ = "${target_out_dir}/${invoker.app}.abc"
146
147  stress_test_action(target_name) {
148    input_abc = _app_abc_
149  }
150}
151