• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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_runtime/js_runtime_config.gni")
16import("$build_root/test.gni")
17if (!ark_standalone_build) {
18  import("//arkcompiler/ets_frontend/ts2panda/ts2abc_config.gni")
19}
20
21if (is_standard_system || ark_standalone_build) {
22  _icu_path_ = "thirdparty/icu"
23} else {
24  _icu_path_ = "global/i18n"
25}
26
27template("host_unittest_action") {
28  _target_name_ = "${target_name}"
29
30  # unittest for phone running
31  ohos_unittest(_target_name_) {
32    resource_config_file =
33        "//arkcompiler/ets_runtime/test/resource/js_runtime/ohos_test.xml"
34    forward_variables_from(invoker, "*")
35  }
36
37  if (ark_standalone_build) {
38    _module_out_path_ = ""
39  } else {
40    _module_out_path_ = invoker.module_out_path
41  }
42
43  # unittest for host running
44  action("${_target_name_}Action") {
45    testonly = true
46
47    _host_test_target_ = ":${_target_name_}(${host_toolchain})"
48    _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
49
50    deps = [ _host_test_target_ ]
51
52    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
53
54    args = [
55      "--script-file",
56      rebase_path(_root_out_dir_) +
57          "/tests/unittest/${_module_out_path_}/${_target_name_}",
58      "--expect-output",
59      "0",
60      "--env-path",
61      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
62          rebase_path(_root_out_dir_) + "/test/test:" +
63          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
64          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
65          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
66      "--timeout-limit",
67      "1200",
68    ]
69
70    inputs = [
71      "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
72    ]
73    outputs = [ "$target_out_dir/${_target_name_}/" ]
74  }
75}
76
77template("host_moduletest_action") {
78  _target_name_ = "${target_name}"
79  _deps_ = invoker.deps
80  _is_module_ = false
81  if (defined(invoker.is_module) && invoker.is_module) {
82    _is_module_ = true
83  }
84  _is_commonjs_ = false
85  if (defined(invoker.is_commonjs) && invoker.is_commonjs) {
86    _is_commonjs_ = true
87  }
88  _is_merge_ = false
89  if (defined(invoker.is_merge) && invoker.is_merge) {
90    _is_merge_ = true
91  }
92  _is_json_ = false
93  if (defined(invoker.is_json) && invoker.is_json) {
94    _is_json_ = true
95  }
96  _timeout_ = "120"
97  if (defined(invoker.timeout)) {
98    _timeout_ = invoker.timeout
99  }
100
101  _test_js_path_ = "./${_target_name_}.js"
102  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
103  _test_expect_path_ = "./expect_output.txt"
104
105  if (_is_json_) {
106    merge_file_raw = "./${_target_name_}.txt"
107    merge_file = "$target_out_dir/${_target_name_}.txt"
108    merge_file_prefix =
109        "//arkcompiler/ets_runtime/test/moduletest/${_target_name_}/"
110
111    action("gen_${_target_name_}_merge_file") {
112      script = "../../quickfix/generate_merge_file.py"
113      args = [
114        "--input",
115        rebase_path(merge_file_raw),
116        "--output",
117        rebase_path(merge_file),
118        "--prefix",
119        rebase_path(merge_file_prefix),
120      ]
121
122      inputs = [ merge_file_raw ]
123      outputs = [ merge_file ]
124    }
125  }
126
127  es2abc_gen_abc("gen_${_target_name_}_abc") {
128    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
129    extra_dependencies = _deps_
130    src_js = rebase_path(_test_js_path_)
131    dst_file = rebase_path(_test_abc_path_)
132    extra_args = []
133    if (_is_module_) {
134      extra_args += [ "--module" ]
135    }
136    if (_is_commonjs_) {
137      extra_args += [ "--commonjs" ]
138    }
139    if (_is_merge_) {
140      extra_args += [ "--merge-abc" ]
141    }
142    if (_is_json_) {
143      extra_dependencies = [ ":gen_${_target_name_}_merge_file" ]
144      src_js = "@" + rebase_path(merge_file)
145      in_puts = [
146        _test_expect_path_,
147        merge_file,
148      ]
149    } else {
150      in_puts = [
151        _test_expect_path_,
152        _test_js_path_,
153      ]
154    }
155    out_puts = [ _test_abc_path_ ]
156  }
157
158  _extra_modules_ = []
159  if (defined(invoker.extra_modules)) {
160    foreach(module, invoker.extra_modules) {
161      _extra_modules_ += [ "$target_out_dir/${module}.abc" ]
162    }
163  }
164  if (defined(invoker.entry_point)) {
165    _script_args_ = invoker.entry_point
166    _script_args_ += " " + rebase_path(_test_abc_path_)
167  } else {
168    _script_args_ = rebase_path(_test_abc_path_)
169  }
170  foreach(extra_module, _extra_modules_) {
171    _script_args_ += ":" + rebase_path(extra_module)
172  }
173
174  action("${_target_name_}Action") {
175    testonly = true
176
177    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
178    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
179    deps = [
180      ":gen_${_target_name_}_abc",
181      _host_jsvm_target_,
182    ]
183    deps += _deps_
184
185    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
186
187    js_vm_options = " --asm-interpreter=false"
188    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
189        invoker.is_set_maxNonmovableSpaceCapacity) {
190      js_vm_options += " --maxNonmovableSpaceCapacity=524288"  # 0.5M
191    }
192
193    if (defined(invoker.is_enable_enableArkTools) &&
194        invoker.is_enable_enableArkTools) {
195      js_vm_options += " --enable-ark-tools=true"
196      js_vm_options += " --enable-force-gc=false"
197    }
198
199    args = [
200      "--script-file",
201      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
202      "--script-options",
203      js_vm_options,
204      "--script-args",
205      _script_args_,
206      "--timeout-limit",
207      "${_timeout_}",
208      "--expect-file",
209      rebase_path(_test_expect_path_),
210      "--env-path",
211      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
212          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
213          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
214          rebase_path(_root_out_dir_) +
215          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
216    ]
217
218    inputs = [ _test_abc_path_ ]
219    inputs += _extra_modules_
220
221    outputs = [ "$target_out_dir/${_target_name_}/" ]
222  }
223
224  action("${_target_name_}AsmAction") {
225    testonly = true
226
227    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
228    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
229    deps = [
230      ":gen_${_target_name_}_abc",
231      _host_jsvm_target_,
232    ]
233    deps += _deps_
234
235    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
236
237    _asm_run_options_ = " --asm-interpreter=true"
238    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
239        invoker.is_set_maxNonmovableSpaceCapacity) {
240      _asm_run_options_ += " --maxNonmovableSpaceCapacity=524288"  # 0.5M
241    }
242
243    if (defined(invoker.is_enable_enableArkTools) &&
244        invoker.is_enable_enableArkTools) {
245      _asm_run_options_ += " --enable-ark-tools=true"
246      _asm_run_options_ += " --enable-force-gc=false"
247    }
248
249    args = [
250      "--script-file",
251      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
252      "--script-options",
253      _asm_run_options_,
254      "--script-args",
255      _script_args_,
256      "--timeout-limit",
257      "${_timeout_}",
258      "--expect-file",
259      rebase_path(_test_expect_path_),
260      "--env-path",      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
261          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
262          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
263          rebase_path(_root_out_dir_) +
264          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
265    ]
266
267    inputs = [ _test_abc_path_ ]
268    inputs += _extra_modules_
269
270    outputs = [ "$target_out_dir/${_target_name_}Asm/" ]
271  }
272
273  action("${_target_name_}AsmSingleStepAction") {
274    testonly = true
275
276    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
277    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
278    deps = [
279      ":gen_${_target_name_}_abc",
280      _host_jsvm_target_,
281    ]
282    deps += _deps_
283
284    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
285
286    # 214: all bytecodes
287    _asm_run_options_ =
288        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
289    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
290        invoker.is_set_maxNonmovableSpaceCapacity) {
291      _asm_run_options_ += " --maxNonmovableSpaceCapacity=524288"  # 0.5M
292    }
293
294    if (defined(invoker.is_enable_enableArkTools) &&
295        invoker.is_enable_enableArkTools) {
296      _asm_run_options_ += " --enable-ark-tools=true"
297      _asm_run_options_ += " --enable-force-gc=false"
298    }
299
300    args = [
301      "--script-file",
302      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
303      "--script-options",
304      _asm_run_options_,
305      "--script-args",
306      _script_args_,
307      "--expect-file",
308      rebase_path(_test_expect_path_),
309      "--env-path",
310      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
311          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
312          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
313          rebase_path(_root_out_dir_) +
314          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
315    ]
316
317    inputs = [ _test_abc_path_ ]
318    inputs += _extra_modules_
319
320    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStep/" ]
321  }
322}
323
324if (!ark_standalone_build) {
325  template("host_aot_js_test_action") {
326    _target_name_ = "${target_name}"
327    _deps_ = invoker.deps
328
329    _test_ts_path_ = "./${_target_name_}.js"
330    _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
331    _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
332    _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
333    _test_aot_arg_ = "$target_out_dir/${_target_name_}"
334    _test_aot_log_level = "info"
335    _test_expect_path_ = "./expect_output.txt"
336
337    ts2abc_gen_abc("gen_${_target_name_}_abc") {
338      extra_visibility =
339          [ ":*" ]  # Only targets in this file can depend on this.
340      extra_dependencies = _deps_
341      src_js = rebase_path(_test_ts_path_)
342      dst_file = rebase_path(_test_abc_path_)
343      extra_args = [
344        "--merge-abc",
345        "--module",
346      ]
347
348      in_puts = [
349        _test_ts_path_,
350        _test_expect_path_,
351      ]
352      out_puts = [ _test_abc_path_ ]
353    }
354
355    _script_args_ = rebase_path(_test_abc_path_)
356
357    action("${_target_name_}AotCompileAction") {
358      testonly = true
359
360      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
361      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
362      deps = [
363        ":gen_${_target_name_}_abc",
364        _host_aot_target_,
365      ]
366      deps += _deps_
367
368      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
369
370      _aot_compile_options_ =
371          " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
372          _test_aot_log_level + " --log-components=all"
373
374      if (defined(invoker.is_disable_type_lowering) &&
375          invoker.is_disable_type_lowering) {
376        _aot_compile_options_ += " --enable-type-lowering=false"
377      }
378
379      args = [
380        "--script-file",
381        rebase_path(_root_out_dir_) +
382            "/arkcompiler/ets_runtime/ark_aot_compiler",
383        "--script-options",
384        _aot_compile_options_,
385        "--script-args",
386        _script_args_,
387        "--expect-sub-output",
388        "ts aot compile success",
389        "--env-path",
390        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
391            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
392            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
393            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
394      ]
395
396      inputs = [ _test_abc_path_ ]
397
398      outputs = [
399        _test_aot_path_,
400        _test_aot_snapshot_path_,
401      ]
402    }
403
404    action("${_target_name_}AotAction") {
405      testonly = true
406
407      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
408      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
409
410      deps = [
411        ":${_target_name_}AotCompileAction",
412        ":gen_${_target_name_}_abc",
413        _host_jsvm_target_,
414      ]
415      deps += _deps_
416
417      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
418
419      _aot_run_options_ =
420          " --aot-file=" + rebase_path(_test_aot_arg_) +
421          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
422
423      if (defined(invoker.is_enable_enableArkTools) &&
424          invoker.is_enable_enableArkTools) {
425        _aot_run_options_ += " --enable-ark-tools=true"
426        _aot_run_options_ += " --enable-force-gc=false"
427      }
428
429      _icu_data_path_options_ =
430          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
431      _aot_run_options_ += _icu_data_path_options_
432
433      args = [
434        "--script-file",
435        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
436        "--script-options",
437        _aot_run_options_,
438        "--script-args",
439        _script_args_,
440        "--expect-file",
441        rebase_path(_test_expect_path_),
442        "--env-path",
443        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
444            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
445            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
446            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
447      ]
448
449      inputs = [ _test_abc_path_ ]
450
451      outputs = [ "$target_out_dir/${_target_name_}/" ]
452    }
453  }
454
455  template("host_aot_test_action") {
456    _target_name_ = "${target_name}"
457    _deps_ = invoker.deps
458
459    _test_ts_path_ = "./${_target_name_}.ts"
460    _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
461    _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
462    _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
463    _test_aot_arg_ = "$target_out_dir/${_target_name_}"
464    _test_aot_log_level = "info"
465    _test_expect_path_ = "./expect_output.txt"
466
467    ts2abc_gen_abc("gen_${_target_name_}_abc") {
468      extra_visibility =
469          [ ":*" ]  # Only targets in this file can depend on this.
470      extra_dependencies = _deps_
471      src_js = rebase_path(_test_ts_path_)
472      dst_file = rebase_path(_test_abc_path_)
473      extra_args = [
474        "--merge-abc",
475        "--module",
476      ]
477
478      in_puts = [
479        _test_ts_path_,
480        _test_expect_path_,
481      ]
482      out_puts = [ _test_abc_path_ ]
483    }
484
485    _script_args_ = rebase_path(_test_abc_path_)
486
487  _builtins_dts_path_ =
488      "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts"
489  _builtins_d_abc_path_ = "$target_out_dir/lib_ark_builtins.d.abc"
490
491  ts2abc_gen_abc("gen_builtins_d_abc") {
492    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
493
494    # extra_dependencies = _deps_
495    src_js = rebase_path(_builtins_dts_path_)
496    dst_file = rebase_path(_builtins_d_abc_path_)
497    extra_args = [
498      "--merge-abc",
499      "--q",
500      "--b",
501    ]
502
503    in_puts = [ _builtins_dts_path_ ]
504    out_puts = [ _builtins_d_abc_path_ ]
505  }
506
507  action("${_target_name_}AotCompileAction") {
508    testonly = true
509
510      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
511      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
512      deps = [
513        ":gen_${_target_name_}_abc",
514        _host_aot_target_,
515      ]
516      deps += _deps_
517
518      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
519
520      _aot_compile_options_ =
521          " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
522          _test_aot_log_level + " --log-components=all"
523
524      if (defined(invoker.is_disable_type_lowering) &&
525          invoker.is_disable_type_lowering) {
526        _aot_compile_options_ += " --enable-type-lowering=false"
527      }
528
529      if (defined(invoker.is_enable_builtins_dts) &&
530          invoker.is_enable_builtins_dts) {
531        deps += [ ":gen_builtins_d_abc" ]
532        _aot_compile_options_ +=
533            " --builtins-dts=" + rebase_path(_builtins_d_abc_path_)
534      }
535
536      args = [
537        "--script-file",
538        rebase_path(_root_out_dir_) +
539            "/arkcompiler/ets_runtime/ark_aot_compiler",
540        "--script-options",
541        _aot_compile_options_,
542        "--script-args",
543        _script_args_,
544        "--expect-sub-output",
545        "ts aot compile success",
546        "--env-path",
547        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
548            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
549            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
550            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
551      ]
552
553      inputs = [ _test_abc_path_ ]
554
555      outputs = [
556        _test_aot_path_,
557        _test_aot_snapshot_path_,
558      ]
559    }
560
561    action("${_target_name_}AotAction") {
562      testonly = true
563
564      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
565      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
566
567      deps = [
568        ":${_target_name_}AotCompileAction",
569        ":gen_${_target_name_}_abc",
570        _host_jsvm_target_,
571      ]
572      deps += _deps_
573
574      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
575
576      _aot_run_options_ =
577          " --aot-file=" + rebase_path(_test_aot_arg_) +
578          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
579
580      if (defined(invoker.is_enable_enableArkTools) &&
581          invoker.is_enable_enableArkTools) {
582        _aot_run_options_ += " --enable-ark-tools=true"
583        _aot_run_options_ += " --enable-force-gc=false"
584      }
585
586      if (defined(invoker.log_option)) {
587        _aot_run_options_ += invoker.log_option
588      }
589
590      args = [
591        "--script-file",
592        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
593        "--script-options",
594        _aot_run_options_,
595        "--script-args",
596        _script_args_,
597        "--expect-file",
598        rebase_path(_test_expect_path_),
599        "--env-path",
600        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
601            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
602            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
603            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
604      ]
605
606      inputs = [ _test_abc_path_ ]
607
608      outputs = [ "$target_out_dir/${_target_name_}/" ]
609    }
610  }
611
612  template("host_typeinfer_test_action") {
613    _target_name_ = "${target_name}"
614    _deps_ = invoker.deps
615
616    _test_ts_path_ = "./${_target_name_}.ts"
617    _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
618
619    ts2abc_gen_abc("gen_${_target_name_}_abc") {
620      extra_visibility =
621          [ ":*" ]  # Only targets in this file can depend on this.
622      extra_dependencies = _deps_
623      src_js = rebase_path(_test_ts_path_)
624      dst_file = rebase_path(_test_abc_path_)
625      extra_args = [
626        "--merge-abc",
627        "--module",
628      ]
629
630      in_puts = [ _test_ts_path_ ]
631      out_puts = [ _test_abc_path_ ]
632    }
633
634    _script_args_ = rebase_path(_test_abc_path_)
635
636    _builtins_dts_path_ =
637        "//arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts"
638    _builtins_d_abc_path_ = "$target_out_dir/lib_ark_builtins.d.abc"
639
640    ts2abc_gen_abc("gen_builtins_d_abc") {
641      extra_visibility =
642          [ ":*" ]  # Only targets in this file can depend on this.
643
644      # extra_dependencies = _deps_
645      src_js = rebase_path(_builtins_dts_path_)
646      dst_file = rebase_path(_builtins_d_abc_path_)
647      extra_args = [
648        "--merge-abc",
649        "--q",
650        "--b",
651      ]
652
653      in_puts = [ _builtins_dts_path_ ]
654      out_puts = [ _builtins_d_abc_path_ ]
655    }
656
657    action("${_target_name_}AotTypeInferAction") {
658      testonly = true
659
660      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
661      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
662      deps = [
663        ":gen_${_target_name_}_abc",
664        _host_aot_target_,
665      ]
666      deps += _deps_
667
668      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
669
670      _aot_compile_options_ = " --assert-types=true"
671
672      if (defined(invoker.is_enable_builtins_dts) &&
673          invoker.is_enable_builtins_dts) {
674        deps += [ ":gen_builtins_d_abc" ]
675        _aot_compile_options_ +=
676            " --builtins-dts=" + rebase_path(_builtins_d_abc_path_)
677      }
678
679      if (defined(invoker.is_disable_type_lowering) &&
680          invoker.is_disable_type_lowering) {
681        _aot_compile_options_ += " --enable-type-lowering=false"
682      }
683
684      args = [
685        "--script-file",
686        rebase_path(_root_out_dir_) +
687            "/arkcompiler/ets_runtime/ark_aot_compiler",
688        "--script-options",
689        _aot_compile_options_,
690        "--script-args",
691        _script_args_,
692        "--expect-output",
693        "0",
694        "--env-path",
695        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
696            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
697            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
698            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
699      ]
700
701      inputs = [ _test_abc_path_ ]
702
703      outputs = [ "$target_out_dir/${_target_name_}/" ]
704    }
705  }
706}
707
708template("host_quickfix_test_action") {
709  _target_name_ = "${target_name}"
710  _extra_patches_ = invoker.extra_patches
711
712  _test_js_path_ = [
713    "./${_target_name_}/base.js",
714    "./${_target_name_}/module.js",
715    "./${_target_name_}/patch/base.js",
716    "./${_target_name_}/patch/module.js",
717    "./${_target_name_}/test.js",
718  ]
719
720  foreach(patch, _extra_patches_) {
721    _test_js_path_ += [
722      "./${_target_name_}/${patch}/base.js",
723      "./${_target_name_}/${patch}/module.js",
724    ]
725  }
726
727  _base_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/base.txt"
728  _test_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/test.txt"
729  _retest_merge_file_raw_ = "//arkcompiler/ets_runtime/test/quickfix/retest.txt"
730
731  _base_merge_file_ = "$target_out_dir/${_target_name_}/base.txt"
732  _test_merge_file_ = "$target_out_dir/${_target_name_}/test.txt"
733  _retest_merge_file_ = "$target_out_dir/${_target_name_}/retest.txt"
734  _patch_merge_file_ = "$target_out_dir/${_target_name_}/patch.txt"
735
736  _base_abc_path_ = "$target_out_dir/${_target_name_}/merge.abc"
737  _test_abc_path_ = "$target_out_dir/${_target_name_}/test.abc"
738  _retest_abc_path_ = "$target_out_dir/${_target_name_}/retest.abc"
739  _patch_abc_path_ = "$target_out_dir/${_target_name_}/patch/merge.abc"
740
741  _test_expect_path_ = "./${_target_name_}/expect_output.txt"
742
743  action("gen_${_target_name_}_base_merge_file") {
744    script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
745    args = [
746      "--input",
747      rebase_path(_base_merge_file_raw_),
748      "--output",
749      rebase_path(_base_merge_file_),
750      "--prefix",
751      rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
752    ]
753
754    inputs = [ _base_merge_file_raw_ ]
755    outputs = [ _base_merge_file_ ]
756  }
757
758  action("gen_${_target_name_}_test_merge_file") {
759    script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
760    args = [
761      "--input",
762      rebase_path(_test_merge_file_raw_),
763      "--output",
764      rebase_path(_test_merge_file_),
765      "--prefix",
766      rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
767    ]
768
769    inputs = [ _test_merge_file_raw_ ]
770    outputs = [ _test_merge_file_ ]
771  }
772
773  action("gen_${_target_name_}_retest_merge_file") {
774    script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
775    args = [
776      "--input",
777      rebase_path(_retest_merge_file_raw_),
778      "--output",
779      rebase_path(_retest_merge_file_),
780      "--prefix",
781      rebase_path("//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"),
782    ]
783
784    inputs = [ _retest_merge_file_raw_ ]
785    outputs = [ _retest_merge_file_ ]
786  }
787
788  action("gen_${_target_name_}_patch_merge_file") {
789    script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
790    args = [
791      "--input",
792      rebase_path(_base_merge_file_raw_),
793      "--output",
794      rebase_path(_patch_merge_file_),
795      "--prefix",
796      rebase_path(
797          "//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/patch/"),
798    ]
799
800    inputs = [ _base_merge_file_raw_ ]
801    outputs = [ _patch_merge_file_ ]
802  }
803
804  es2abc_gen_abc("gen_${_target_name_}_base_abc") {
805    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
806    extra_dependencies = [ ":gen_${_target_name_}_base_merge_file" ]
807    src_js = "@" + rebase_path(_base_merge_file_)
808    dst_file = rebase_path(_base_abc_path_)
809    extra_args = []
810    extra_args += [ "--module" ]
811    extra_args += [ "--merge-abc" ]
812
813    in_puts = [ _test_expect_path_ ]
814    in_puts += _test_js_path_
815    out_puts = [ _base_abc_path_ ]
816  }
817
818  es2abc_gen_abc("gen_${_target_name_}_test_abc") {
819    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
820    extra_dependencies = [ ":gen_${_target_name_}_test_merge_file" ]
821    src_js = "@" + rebase_path(_test_merge_file_)
822    dst_file = rebase_path(_test_abc_path_)
823    extra_args = []
824    extra_args += [ "--module" ]
825    extra_args += [ "--merge-abc" ]
826
827    in_puts = [ _test_expect_path_ ]
828    in_puts += _test_js_path_
829    out_puts = [ _test_abc_path_ ]
830  }
831
832  es2abc_gen_abc("gen_${_target_name_}_retest_abc") {
833    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
834    extra_dependencies = [ ":gen_${_target_name_}_retest_merge_file" ]
835    src_js = "@" + rebase_path(_retest_merge_file_)
836    dst_file = rebase_path(_retest_abc_path_)
837    extra_args = []
838    extra_args += [ "--module" ]
839    extra_args += [ "--merge-abc" ]
840
841    in_puts = [ _test_expect_path_ ]
842    in_puts += _test_js_path_
843    out_puts = [ _retest_abc_path_ ]
844  }
845
846  es2abc_gen_abc("gen_${_target_name_}_patch_abc") {
847    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
848    extra_dependencies = [ ":gen_${_target_name_}_patch_merge_file" ]
849    src_js = "@" + rebase_path(_patch_merge_file_)
850    dst_file = rebase_path(_patch_abc_path_)
851    extra_args = []
852    extra_args += [ "--module" ]
853    extra_args += [ "--merge-abc" ]
854
855    in_puts = [ _test_expect_path_ ]
856    in_puts += _test_js_path_
857    out_puts = [ _patch_abc_path_ ]
858  }
859
860  if (defined(invoker.entry_point)) {
861    _script_args_ = invoker.entry_point + " "
862  }
863
864  _script_args_ +=
865      rebase_path(_base_abc_path_) + ":" + rebase_path(_test_abc_path_) + ":" +
866      rebase_path(_retest_abc_path_) + ":" + rebase_path(_patch_abc_path_)
867
868  foreach(patch, _extra_patches_) {
869    _merge_file_ = "$target_out_dir/${_target_name_}/${patch}.txt"
870    _abc_file_ = "$target_out_dir/${_target_name_}/${patch}/merge.abc"
871    action("gen_${_target_name_}_${patch}_merge_file") {
872      script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
873      args = [
874        "--input",
875        rebase_path(_base_merge_file_raw_),
876        "--output",
877        rebase_path(_merge_file_),
878        "--prefix",
879        rebase_path(
880            "//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/${patch}/"),
881      ]
882
883      inputs = [ _base_merge_file_raw_ ]
884      outputs = [ _merge_file_ ]
885    }
886
887    es2abc_gen_abc("gen_${_target_name_}_${patch}_abc") {
888      extra_visibility =
889          [ ":*" ]  # Only targets in this file can depend on this.
890      extra_dependencies = [ ":gen_${_target_name_}_${patch}_merge_file" ]
891      src_js = "@" + rebase_path(_merge_file_)
892      dst_file = rebase_path(_abc_file_)
893      extra_args = []
894      extra_args += [ "--module" ]
895      extra_args += [ "--merge-abc" ]
896
897      in_puts = [ _test_expect_path_ ]
898      in_puts += _test_js_path_
899      out_puts = [ _abc_file_ ]
900    }
901
902    _script_args_ += ":" + rebase_path(_abc_file_)
903  }
904
905  action("${_target_name_}QuickfixAction") {
906    testonly = true
907
908    _host_quickfix_target_ = "//arkcompiler/ets_runtime/ecmascript/quick_fix:quick_fix(${host_toolchain})"
909    _root_out_dir_ = get_label_info(_host_quickfix_target_, "root_out_dir")
910    deps = [
911      ":gen_${_target_name_}_base_abc",
912      ":gen_${_target_name_}_patch_abc",
913      ":gen_${_target_name_}_retest_abc",
914      ":gen_${_target_name_}_test_abc",
915      _host_quickfix_target_,
916    ]
917    foreach(patch, _extra_patches_) {
918      deps += [ ":gen_${_target_name_}_${patch}_abc" ]
919    }
920
921    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
922
923    quickfix_options = " --merge-abc true "
924
925    args = [
926      "--script-file",
927      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/quick_fix",
928      "--script-options",
929      quickfix_options,
930      "--script-args",
931      _script_args_,
932      "--timeout-limit",
933      "120",
934      "--expect-file",
935      rebase_path(_test_expect_path_),
936      "--env-path",
937      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
938          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
939          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
940          rebase_path(_root_out_dir_) +
941          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
942    ]
943
944    inputs = [
945      _base_abc_path_,
946      _test_abc_path_,
947      _retest_abc_path_,
948      _patch_abc_path_,
949    ]
950
951    outputs = [ "$target_out_dir/${_target_name_}/" ]
952  }
953}
954