• 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")
17
18if (is_standard_system || ark_standalone_build) {
19  _icu_path_ = "thirdparty/icu"
20} else {
21  _icu_path_ = "global/i18n"
22}
23
24template("host_unittest_action") {
25  _target_name_ = "${target_name}"
26
27  # unittest for phone running
28  ohos_unittest(_target_name_) {
29    resource_config_file =
30        "//arkcompiler/ets_runtime/test/resource/js_runtime/ohos_test.xml"
31    forward_variables_from(invoker, "*")
32  }
33
34  _module_out_path_ = invoker.module_out_path
35
36  # unittest for host running
37  action("${_target_name_}ActionWithoutQemu") {
38    testonly = true
39
40    _host_test_target_ = ":${_target_name_}(${host_toolchain})"
41    _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
42
43    deps = [ _host_test_target_ ]
44
45    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
46
47    args = [
48      "--script-file",
49      rebase_path(_root_out_dir_) +
50          "/tests/unittest/${_module_out_path_}/${_target_name_}",
51      "--expect-output",
52      "0",
53      "--env-path",
54      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
55          rebase_path(_root_out_dir_) + "/test/test:" +
56          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
57          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
58          rebase_path(_root_out_dir_) +
59          "/thirdparty/bounds_checking_function:" +
60          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
61      "--timeout-limit",
62      "1200",
63    ]
64
65    inputs = [
66      "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
67    ]
68    outputs = [ "$target_out_dir/${_target_name_}/" ]
69  }
70  if (ark_standalone_build && host_os == "linux" && target_os == "ohos") {
71    import("$ark_third_party_root/musl/musl_template.gni")
72    import("$build_root/config/qemu/config.gni")
73
74    action("${_target_name_}ActionWithQemu") {
75      testonly = true
76
77      _host_test_target_ = ":${_target_name_}"
78
79      # path of root_out_dir based on root_src_dir
80      _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
81
82      deps = [
83        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
84        _host_test_target_,
85      ]
86
87      script = "${js_root}/script/run_ark_executable.py"
88
89      args = [
90        "--script-file",
91        rebase_path(
92            "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
93            root_build_dir),
94        "--expect-output",
95        "0",
96        "--clang-lib-path",
97        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos",
98                    root_build_dir),
99        "--qemu-binary-path",
100        rebase_path("${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
101                    root_build_dir),
102        "--qemu-ld-prefix",
103        rebase_path(musl_linker_so_out_dir, root_build_dir),
104        "--timeout-limit",
105        "1200",
106      ]
107
108      inputs = [
109        "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
110      ]
111      outputs = [ "$target_out_dir/${_target_name_}WithQemu/" ]
112    }
113  }
114  group("${_target_name_}Action") {
115    testonly = true
116
117    deps = []
118    if (ark_standalone_build && host_os == "linux" && target_os == "ohos" &&
119        run_with_qemu) {
120      deps += [ ":${_target_name_}ActionWithQemu" ]
121    } else {
122      deps += [ ":${_target_name_}ActionWithoutQemu" ]
123    }
124  }
125}
126
127template("host_moduletest_action") {
128  _target_name_ = "${target_name}"
129  _deps_ = invoker.deps
130  _is_module_ = false
131  if (defined(invoker.is_module) && invoker.is_module) {
132    _is_module_ = true
133  }
134  _is_commonjs_ = false
135  if (defined(invoker.is_commonjs) && invoker.is_commonjs) {
136    _is_commonjs_ = true
137  }
138  _is_merge_ = false
139  if (defined(invoker.is_merge) && invoker.is_merge) {
140    _is_merge_ = true
141  }
142  _is_json_ = false
143  if (defined(invoker.is_json) && invoker.is_json) {
144    _is_json_ = true
145  }
146  _timeout_ = "150"
147  if (defined(invoker.timeout)) {
148    _timeout_ = invoker.timeout
149  }
150
151  _test_js_path_ = "./${_target_name_}.js"
152  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
153  _test_expect_path_ = "./expect_output.txt"
154
155  if (_is_json_) {
156    merge_file_raw = "./${_target_name_}.txt"
157    merge_file = "$target_out_dir/${_target_name_}.txt"
158    merge_file_prefix =
159        "//arkcompiler/ets_runtime/test/moduletest/${_target_name_}/"
160
161    action("gen_${_target_name_}_merge_file") {
162      script = "../../quickfix/generate_merge_file.py"
163      args = [
164        "--input",
165        rebase_path(merge_file_raw),
166        "--output",
167        rebase_path(merge_file),
168        "--prefix",
169        rebase_path(merge_file_prefix),
170      ]
171
172      inputs = [ merge_file_raw ]
173      outputs = [ merge_file ]
174    }
175  }
176
177  es2abc_gen_abc("gen_${_target_name_}_abc") {
178    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
179    extra_dependencies = _deps_
180    src_js = rebase_path(_test_js_path_)
181    dst_file = rebase_path(_test_abc_path_)
182    extra_args = []
183    if (_is_module_) {
184      extra_args += [ "--module" ]
185    }
186    if (_is_commonjs_) {
187      extra_args += [ "--commonjs" ]
188    }
189    if (_is_merge_) {
190      extra_args += [ "--merge-abc" ]
191    }
192    if (_is_json_) {
193      extra_dependencies = [ ":gen_${_target_name_}_merge_file" ]
194      src_js = "@" + rebase_path(merge_file)
195      in_puts = [
196        _test_expect_path_,
197        merge_file,
198      ]
199    } else {
200      in_puts = [
201        _test_expect_path_,
202        _test_js_path_,
203      ]
204    }
205    out_puts = [ _test_abc_path_ ]
206  }
207
208  _extra_modules_ = []
209  if (defined(invoker.extra_modules)) {
210    foreach(module, invoker.extra_modules) {
211      _extra_modules_ += [ "$target_out_dir/${module}.abc" ]
212    }
213  }
214  if (defined(invoker.entry_point)) {
215    _script_args_ = invoker.entry_point
216    _script_args_ += " " + rebase_path(_test_abc_path_)
217  } else {
218    _script_args_ = rebase_path(_test_abc_path_)
219  }
220  foreach(extra_module, _extra_modules_) {
221    _script_args_ += ":" + rebase_path(extra_module)
222  }
223
224  action("${_target_name_}Action") {
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    js_vm_options = " --asm-interpreter=false"
238    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
239        invoker.is_set_maxNonmovableSpaceCapacity) {
240      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
241    }
242
243    if (defined(invoker.is_enable_enableArkTools) &&
244        invoker.is_enable_enableArkTools) {
245      js_vm_options += " --enable-ark-tools=true"
246      js_vm_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      js_vm_options,
254      "--script-args",
255      _script_args_,
256      "--timeout-limit",
257      "${_timeout_}",
258      "--expect-file",
259      rebase_path(_test_expect_path_),
260      "--env-path",
261      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
262          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
263          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
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_}/" ]
271  }
272
273  action("${_target_name_}ContextAction") {
274    testonly = true
275
276    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_context(${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    js_vm_options = " --asm-interpreter=false"
287    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
288        invoker.is_set_maxNonmovableSpaceCapacity) {
289      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
290    }
291
292    if (defined(invoker.is_enable_enableArkTools) &&
293        invoker.is_enable_enableArkTools) {
294      js_vm_options += " --enable-ark-tools=true"
295      js_vm_options += " --enable-force-gc=false"
296    }
297
298    args = [
299      "--script-file",
300      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_context",
301      "--script-options",
302      js_vm_options,
303      "--script-args",
304      _script_args_,
305      "--timeout-limit",
306      "${_timeout_}",
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("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
314    ]
315
316    inputs = [ _test_abc_path_ ]
317    inputs += _extra_modules_
318
319    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
320  }
321
322  action("${_target_name_}AsmAction") {
323    testonly = true
324
325    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
326    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
327    deps = [
328      ":gen_${_target_name_}_abc",
329      _host_jsvm_target_,
330    ]
331    deps += _deps_
332
333    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
334
335    _asm_run_options_ = " --asm-interpreter=true"
336    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
337        invoker.is_set_maxNonmovableSpaceCapacity) {
338      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
339    }
340
341    if (defined(invoker.is_enable_enableArkTools) &&
342        invoker.is_enable_enableArkTools) {
343      _asm_run_options_ += " --enable-ark-tools=true"
344      _asm_run_options_ += " --enable-force-gc=false"
345    }
346
347    args = [
348      "--script-file",
349      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
350      "--script-options",
351      _asm_run_options_,
352      "--script-args",
353      _script_args_,
354      "--timeout-limit",
355      "${_timeout_}",
356      "--expect-file",
357      rebase_path(_test_expect_path_),
358      "--env-path",
359      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
360          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
361          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
362          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
363    ]
364
365    inputs = [ _test_abc_path_ ]
366    inputs += _extra_modules_
367
368    outputs = [ "$target_out_dir/${_target_name_}Asm/" ]
369  }
370
371  action("${_target_name_}AsmContextAction") {
372    testonly = true
373
374    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_context(${host_toolchain})"
375    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
376    deps = [
377      ":gen_${_target_name_}_abc",
378      _host_jsvm_target_,
379    ]
380    deps += _deps_
381
382    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
383
384    _asm_run_options_ = " --asm-interpreter=true"
385    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
386        invoker.is_set_maxNonmovableSpaceCapacity) {
387      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
388    }
389
390    if (defined(invoker.is_enable_enableArkTools) &&
391        invoker.is_enable_enableArkTools) {
392      _asm_run_options_ += " --enable-ark-tools=true"
393      _asm_run_options_ += " --enable-force-gc=false"
394    }
395
396    args = [
397      "--script-file",
398      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_context",
399      "--script-options",
400      _asm_run_options_,
401      "--script-args",
402      _script_args_,
403      "--timeout-limit",
404      "${_timeout_}",
405      "--expect-file",
406      rebase_path(_test_expect_path_),
407      "--env-path",
408      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
409          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
410          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
411          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
412    ]
413
414    inputs = [ _test_abc_path_ ]
415    inputs += _extra_modules_
416
417    outputs = [ "$target_out_dir/${_target_name_}AsmContext/" ]
418  }
419
420  action("${_target_name_}AsmSingleStepAction") {
421    testonly = true
422
423    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
424    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
425    deps = [
426      ":gen_${_target_name_}_abc",
427      _host_jsvm_target_,
428    ]
429    deps += _deps_
430
431    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
432
433    # 214: all bytecodes
434    _asm_run_options_ =
435        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
436    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
437        invoker.is_set_maxNonmovableSpaceCapacity) {
438      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
439    }
440
441    if (defined(invoker.is_enable_enableArkTools) &&
442        invoker.is_enable_enableArkTools) {
443      _asm_run_options_ += " --enable-ark-tools=true"
444      _asm_run_options_ += " --enable-force-gc=false"
445    }
446
447    args = [
448      "--script-file",
449      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
450      "--script-options",
451      _asm_run_options_,
452      "--script-args",
453      _script_args_,
454      "--expect-file",
455      rebase_path(_test_expect_path_),
456      "--env-path",
457      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
458          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
459          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
460          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
461    ]
462
463    inputs = [ _test_abc_path_ ]
464    inputs += _extra_modules_
465
466    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStep/" ]
467  }
468
469  action("${_target_name_}AsmSingleStepContextAction") {
470    testonly = true
471
472    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_context(${host_toolchain})"
473    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
474    deps = [
475      ":gen_${_target_name_}_abc",
476      _host_jsvm_target_,
477    ]
478    deps += _deps_
479
480    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
481
482    # 214: all bytecodes
483    _asm_run_options_ =
484        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
485    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
486        invoker.is_set_maxNonmovableSpaceCapacity) {
487      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
488    }
489
490    if (defined(invoker.is_enable_enableArkTools) &&
491        invoker.is_enable_enableArkTools) {
492      _asm_run_options_ += " --enable-ark-tools=true"
493      _asm_run_options_ += " --enable-force-gc=false"
494    }
495
496    args = [
497      "--script-file",
498      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_context",
499      "--script-options",
500      _asm_run_options_,
501      "--script-args",
502      _script_args_,
503      "--expect-file",
504      rebase_path(_test_expect_path_),
505      "--env-path",
506      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
507          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
508          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
509          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
510    ]
511
512    inputs = [ _test_abc_path_ ]
513    inputs += _extra_modules_
514
515    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStepContext/" ]
516  }
517}
518
519template("host_aot_js_test_action") {
520  _target_name_ = "${target_name}"
521  _deps_ = invoker.deps
522
523  _test_ts_path_ = "./${_target_name_}.js"
524  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
525  _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
526  _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
527  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
528  _test_aot_log_level = "info"
529  _test_expect_path_ = "./expect_output.txt"
530
531  if (defined(invoker.is_common_js) && invoker.is_common_js) {
532    extra_args = [ "--commonjs" ]
533  } else {
534    extra_args = [ "--module" ]
535  }
536  extra_args += [ "--merge-abc" ]
537
538  es2abc_gen_abc("gen_${_target_name_}_abc") {
539    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
540    extra_dependencies = _deps_
541    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
542      src_js = rebase_path("./")
543    } else {
544      src_js = rebase_path(_test_ts_path_)
545    }
546    dst_file = rebase_path(_test_abc_path_)
547
548    in_puts = [
549      _test_ts_path_,
550      _test_expect_path_,
551    ]
552    out_puts = [ _test_abc_path_ ]
553  }
554
555  _script_args_ = rebase_path(_test_abc_path_)
556
557  action("${_target_name_}AotCompileAction") {
558    testonly = true
559
560    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
561    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
562    deps = [
563      ":gen_${_target_name_}_abc",
564      _host_aot_target_,
565    ]
566    deps += _deps_
567
568    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
569
570    _aot_compile_options_ = " --aot-file=" + rebase_path(_test_aot_arg_) +
571                            " --log-level=" + _test_aot_log_level + " --log-components=compiler --compiler-opt-type-lowering=false --compiler-opt-inlining=false"
572
573    if (defined(invoker.is_enable_trace_deopt) &&
574        invoker.is_enable_trace_deopt) {
575      _aot_compile_options_ += " --compiler-trace-deopt=true"
576    }
577
578    if (defined(invoker.is_enable_opt_inlining) &&
579        invoker.is_enable_opt_inlining) {
580      _aot_compile_options_ +=
581          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
582    }
583
584    if (defined(invoker.is_enable_opt_loop_peeling) &&
585        invoker.is_enable_opt_loop_peeling) {
586      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
587    }
588
589    if (defined(invoker.is_enable_inline_trace) &&
590        invoker.is_enable_inline_trace) {
591      _aot_compile_options_ += " --compiler-trace-inline=true"
592    }
593
594    if (defined(invoker.userDefinedMethodsInModule) &&
595        invoker.userDefinedMethodsInModule) {
596      _aot_compile_options_ += " --compiler-module-methods=2"
597    }
598
599    args = [
600      "--script-file",
601      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
602      "--script-options",
603      _aot_compile_options_,
604      "--script-args",
605      _script_args_,
606      "--expect-sub-output",
607      "ts aot compile success",
608      "--env-path",
609      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
610          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
611          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
612          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
613    ]
614
615    inputs = [ _test_abc_path_ ]
616
617    outputs = [
618      _test_aot_path_,
619      _test_aot_snapshot_path_,
620    ]
621  }
622
623  action("${_target_name_}AotAction") {
624    testonly = true
625
626    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
627    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
628
629    deps = [
630      ":${_target_name_}AotCompileAction",
631      ":gen_${_target_name_}_abc",
632      _host_jsvm_target_,
633    ]
634    deps += _deps_
635
636    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
637
638    _aot_run_options_ =
639        " --aot-file=" + rebase_path(_test_aot_arg_) +
640        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
641
642    if (defined(invoker.is_enable_enableArkTools) &&
643        invoker.is_enable_enableArkTools) {
644      _aot_run_options_ += " --enable-ark-tools=true"
645      _aot_run_options_ += " --enable-force-gc=false"
646    }
647
648    _icu_data_path_options_ =
649        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
650    _aot_run_options_ += _icu_data_path_options_
651
652    args = [
653      "--script-file",
654      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
655      "--script-options",
656      _aot_run_options_,
657      "--script-args",
658      _script_args_,
659      "--expect-file",
660      rebase_path(_test_expect_path_),
661      "--env-path",
662      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
663          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
664          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
665          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
666    ]
667
668    inputs = [ _test_abc_path_ ]
669
670    outputs = [ "$target_out_dir/${_target_name_}/" ]
671  }
672
673  action("${_target_name_}AotContextAction") {
674    testonly = true
675
676    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_context(${host_toolchain})"
677    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
678
679    deps = [
680      ":${_target_name_}AotCompileAction",
681      ":gen_${_target_name_}_abc",
682      _host_jsvm_target_,
683    ]
684    deps += _deps_
685
686    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
687
688    _aot_run_options_ =
689        " --aot-file=" + rebase_path(_test_aot_arg_) +
690        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
691
692    if (defined(invoker.is_enable_enableArkTools) &&
693        invoker.is_enable_enableArkTools) {
694      _aot_run_options_ += " --enable-ark-tools=true"
695      _aot_run_options_ += " --enable-force-gc=false"
696    }
697
698    _icu_data_path_options_ =
699        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
700    _aot_run_options_ += _icu_data_path_options_
701
702    args = [
703      "--script-file",
704      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_context",
705      "--script-options",
706      _aot_run_options_,
707      "--script-args",
708      _script_args_,
709      "--expect-file",
710      rebase_path(_test_expect_path_),
711      "--env-path",
712      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
713          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
714          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
715          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
716    ]
717
718    inputs = [ _test_abc_path_ ]
719
720    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
721  }
722}
723
724template("host_aot_test_action") {
725  _target_name_ = "${target_name}"
726  _deps_ = invoker.deps
727
728  _test_ts_path_ = "./${_target_name_}.ts"
729  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
730  _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
731  _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
732  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
733  _test_aot_path_slowpath_ = "$target_out_dir/slowpath/${_target_name_}.an"
734  _test_aot_snapshot_path_slowpath_ =
735      "$target_out_dir/slowpath/${_target_name_}.ai"
736  _test_aot_arg_slowpath_ = "$target_out_dir/slowpath/${_target_name_}"
737  _test_aot_log_level = "info"
738  _test_expect_path_ = "./expect_output.txt"
739  _test_pgo_expect_path_ = "./pgo_expect_output.txt"
740
741  es2abc_gen_abc("gen_${_target_name_}_abc") {
742    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
743    extra_dependencies = _deps_
744    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
745      src_js = rebase_path("./")
746    } else {
747      src_js = rebase_path(_test_ts_path_)
748    }
749    dst_file = rebase_path(_test_abc_path_)
750    extension = "ts"
751    extra_args = [
752      "--merge-abc",
753      "--module",
754      "--type-extractor",
755    ]
756
757    if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
758      extra_args += [ "--debug" ]
759    }
760
761    in_puts = [
762      _test_ts_path_,
763      _test_expect_path_,
764    ]
765    out_puts = [ _test_abc_path_ ]
766  }
767
768  _script_args_ = rebase_path(_test_abc_path_)
769
770  action("${_target_name_}PgoExecute") {
771    testonly = true
772    _host_jsvm_target_ =
773        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
774    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
775
776    deps = [
777      ":gen_${_target_name_}_abc",
778      _host_jsvm_target_,
779    ]
780    deps += _deps_
781
782    script = "$js_root/script/run_ark_executable.py"
783
784    _aot_run_options_ =
785        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
786        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
787        rebase_path(_test_aot_arg_) + "/modules.ap"
788
789    if (defined(invoker.is_enable_enableArkTools) &&
790        invoker.is_enable_enableArkTools) {
791      _aot_run_options_ += " --enable-ark-tools=true"
792      _aot_run_options_ += " --enable-force-gc=false"
793    }
794
795    if (defined(invoker.log_option)) {
796      _aot_run_options_ += invoker.log_option
797    }
798
799    args = [
800      "--script-file",
801      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
802      "--script-options",
803      _aot_run_options_,
804      "--script-args",
805      _script_args_,
806      "--expect-file",
807      rebase_path(_test_pgo_expect_path_),
808      "--env-path",
809      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
810          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
811          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
812          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
813    ]
814
815    inputs = [ _test_abc_path_ ]
816
817    outputs = [ "$target_out_dir/${_target_name_}/pgo" ]
818  }
819
820  action("${_target_name_}AotCompileAction") {
821    testonly = true
822
823    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
824    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
825    deps = [
826      ":gen_${_target_name_}_abc",
827      _host_aot_target_,
828    ]
829    deps += _deps_
830
831    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
832      deps += [ ":${_target_name_}PgoExecute" ]
833    }
834
835    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
836
837    _aot_compile_options_ =
838        " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
839        _test_aot_log_level + " --log-components=compiler" +
840        " --compiler-opt-inlining=false"
841
842    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
843      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
844                               rebase_path(_test_aot_arg_) + "/modules.ap"
845    }
846    if (defined(invoker.is_enable_trace_deopt) &&
847        invoker.is_enable_trace_deopt) {
848      _aot_compile_options_ += " --compiler-trace-deopt=true"
849    }
850    if (defined(invoker.is_enable_builtins_dts) &&
851        invoker.is_enable_builtins_dts) {
852      deps += [ "//arkcompiler/ets_runtime:es2abc_gen_builtins_d_abc" ]
853      _aot_compile_options_ += " --builtins-dts=" + rebase_path(root_out_dir) + "/obj/arkcompiler/ets_runtime/lib_ark_builtins/es2abc/lib_ark_builtins.d.abc"
854    }
855    if (defined(invoker.is_enable_opt_inlining) &&
856        invoker.is_enable_opt_inlining) {
857      _aot_compile_options_ +=
858          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
859    }
860
861    if (defined(invoker.is_enable_opt_loop_peeling) &&
862        invoker.is_enable_opt_loop_peeling) {
863      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
864    }
865
866    if (defined(invoker.is_enable_inline_trace) &&
867        invoker.is_enable_inline_trace) {
868      _aot_compile_options_ += " --compiler-trace-inline=true"
869    }
870
871    if (defined(invoker.userDefinedMethodsInModule) &&
872        invoker.userDefinedMethodsInModule) {
873      _aot_compile_options_ += " --compiler-module-methods=2"
874    }
875
876    args = [
877      "--script-file",
878      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
879      "--script-options",
880      _aot_compile_options_,
881      "--script-args",
882      _script_args_,
883      "--expect-sub-output",
884      "ts aot compile success",
885      "--env-path",
886      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
887          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
888          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
889          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
890    ]
891
892    inputs = [ _test_abc_path_ ]
893
894    outputs = [
895      _test_aot_path_,
896      _test_aot_snapshot_path_,
897    ]
898  }
899
900  action("${_target_name_}AotCompileActionSlowPath") {
901    testonly = true
902    _host_aot_target_ =
903        "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
904    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
905    deps = [
906      ":gen_${_target_name_}_abc",
907      _host_aot_target_,
908    ]
909    deps += _deps_
910
911    script = "$js_root/script/run_ark_executable.py"
912
913    _aot_compile_options_ =
914        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
915        " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
916        " --compiler-opt-type-lowering=false" + " --compiler-opt-inlining=false"
917    if (defined(invoker.is_enable_trace_deopt) &&
918        invoker.is_enable_trace_deopt) {
919      _aot_compile_options_ += " --compiler-trace-deopt=true"
920    }
921
922    if (defined(invoker.is_enable_builtins_dts) &&
923        invoker.is_enable_builtins_dts) {
924      deps += [ "//arkcompiler/ets_runtime:es2abc_gen_builtins_d_abc" ]
925      _aot_compile_options_ += " --builtins-dts=" + rebase_path(root_out_dir) + "/obj/arkcompiler/ets_runtime/lib_ark_builtins/es2abc/lib_ark_builtins.d.abc"
926    }
927
928    if (defined(invoker.is_enable_opt_inlining) &&
929        invoker.is_enable_opt_inlining) {
930      _aot_compile_options_ +=
931          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
932    }
933
934    if (defined(invoker.is_enable_opt_loop_peeling) &&
935        invoker.is_enable_opt_loop_peeling) {
936      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
937    }
938
939    if (defined(invoker.is_enable_inline_trace) &&
940        invoker.is_enable_inline_trace) {
941      _aot_compile_options_ += " --compiler-trace-inline=true"
942    }
943
944    if (defined(invoker.userDefinedMethodsInModule) &&
945        invoker.userDefinedMethodsInModule) {
946      _aot_compile_options_ += " --compiler-module-methods=2"
947    }
948
949    args = [
950      "--script-file",
951      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
952      "--script-options",
953      _aot_compile_options_,
954      "--script-args",
955      _script_args_,
956      "--expect-sub-output",
957      "ts aot compile success",
958      "--env-path",
959      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
960          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
961          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
962          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
963    ]
964
965    inputs = [ _test_abc_path_ ]
966
967    outputs = [
968      _test_aot_path_slowpath_,
969      _test_aot_snapshot_path_slowpath_,
970    ]
971  }
972
973  action("${_target_name_}AotAction") {
974    testonly = true
975    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
976    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
977
978    deps = [
979      ":${_target_name_}AotCompileAction",
980      ":gen_${_target_name_}_abc",
981      _host_jsvm_target_,
982    ]
983    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
984      deps += [ ":${_target_name_}AotActionSlowPath" ]
985    }
986    deps += _deps_
987
988    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
989
990    _aot_run_options_ =
991        " --aot-file=" + rebase_path(_test_aot_arg_) +
992        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
993
994    if (defined(invoker.is_enable_enableArkTools) &&
995        invoker.is_enable_enableArkTools) {
996      _aot_run_options_ += " --enable-ark-tools=true"
997      _aot_run_options_ += " --enable-force-gc=false"
998    }
999
1000    if (defined(invoker.log_option)) {
1001      _aot_run_options_ += invoker.log_option
1002    }
1003
1004    args = [
1005      "--script-file",
1006      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1007      "--script-options",
1008      _aot_run_options_,
1009      "--script-args",
1010      _script_args_,
1011      "--expect-file",
1012      rebase_path(_test_expect_path_),
1013      "--env-path",
1014      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1015          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1016          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1017          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1018    ]
1019
1020    inputs = [ _test_abc_path_ ]
1021
1022    outputs = [ "$target_out_dir/${_target_name_}/" ]
1023  }
1024
1025  action("${_target_name_}AotContextAction") {
1026    testonly = true
1027    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_context(${host_toolchain})"
1028    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1029
1030    deps = [
1031      ":${_target_name_}AotCompileAction",
1032      ":gen_${_target_name_}_abc",
1033      _host_jsvm_target_,
1034    ]
1035    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
1036      deps += [ ":${_target_name_}AotActionSlowPath" ]
1037    }
1038    deps += _deps_
1039
1040    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1041
1042    _aot_run_options_ =
1043        " --aot-file=" + rebase_path(_test_aot_arg_) +
1044        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1045
1046    if (defined(invoker.is_enable_enableArkTools) &&
1047        invoker.is_enable_enableArkTools) {
1048      _aot_run_options_ += " --enable-ark-tools=true"
1049      _aot_run_options_ += " --enable-force-gc=false"
1050    }
1051
1052    if (defined(invoker.log_option)) {
1053      _aot_run_options_ += invoker.log_option
1054    }
1055
1056    args = [
1057      "--script-file",
1058      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_context",
1059      "--script-options",
1060      _aot_run_options_,
1061      "--script-args",
1062      _script_args_,
1063      "--expect-file",
1064      rebase_path(_test_expect_path_),
1065      "--env-path",
1066      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1067          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1068          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1069          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1070    ]
1071
1072    inputs = [ _test_abc_path_ ]
1073
1074    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
1075  }
1076
1077  action("${_target_name_}AotActionSlowPath") {
1078    testonly = true
1079    _host_jsvm_target_ =
1080        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1081    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1082
1083    deps = [
1084      ":${_target_name_}AotCompileActionSlowPath",
1085      ":gen_${_target_name_}_abc",
1086      _host_jsvm_target_,
1087    ]
1088    deps += _deps_
1089
1090    script = "$js_root/script/run_ark_executable.py"
1091
1092    _aot_run_options_ =
1093        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
1094        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1095
1096    if (defined(invoker.is_enable_enableArkTools) &&
1097        invoker.is_enable_enableArkTools) {
1098      _aot_run_options_ += " --enable-ark-tools=true"
1099      _aot_run_options_ += " --enable-force-gc=false"
1100    }
1101
1102    if (defined(invoker.log_option)) {
1103      _aot_run_options_ += invoker.log_option
1104    }
1105
1106    args = [
1107      "--script-file",
1108      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1109      "--script-options",
1110      _aot_run_options_,
1111      "--script-args",
1112      _script_args_,
1113      "--expect-file",
1114      rebase_path(_test_expect_path_),
1115      "--env-path",
1116      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1117          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1118          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1119          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1120    ]
1121
1122    inputs = [ _test_abc_path_ ]
1123
1124    outputs = [ "$target_out_dir/${_target_name_}/SlowPath" ]
1125  }
1126}
1127
1128template("host_typeinfer_test_action") {
1129  _target_name_ = "${target_name}"
1130  _deps_ = invoker.deps
1131
1132  _host_aot_target_ =
1133      "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1134
1135  _test_ts_path_ = "./${_target_name_}.ts"
1136  _test_es2abc_abc_path_ = "$target_out_dir/es2abc/${_target_name_}.abc"
1137
1138  es2abc_gen_abc("es2abc_gen_${_target_name_}_abc") {
1139    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
1140    extra_dependencies = _deps_
1141    if (defined(invoker.is_multi_file_tests) && invoker.is_multi_file_tests) {
1142      _test_es2abc_ts_path_ = "."
1143    } else {
1144      _test_es2abc_ts_path_ = _test_ts_path_
1145    }
1146    src_js = rebase_path(_test_es2abc_ts_path_)
1147    dst_file = rebase_path(_test_es2abc_abc_path_)
1148    extension = "ts"
1149    extra_args = [
1150      "--module",
1151      "--merge-abc",
1152      "--type-extractor",
1153    ]
1154
1155    in_puts = [ _test_ts_path_ ]
1156    out_puts = [ _test_es2abc_abc_path_ ]
1157  }
1158
1159  action("${_target_name_}Es2abcAotTypeInferAction") {
1160    testonly = true
1161
1162    _script_args_ = rebase_path(_test_es2abc_abc_path_)
1163    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1164    deps = [
1165      ":es2abc_gen_${_target_name_}_abc",
1166      _host_aot_target_,
1167    ]
1168    deps += _deps_
1169
1170    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1171
1172    _aot_compile_options_ =
1173        " --compiler-assert-types=true" + " --compiler-opt-type-lowering=false"
1174
1175    if (defined(invoker.is_enable_builtins_dts) &&
1176        invoker.is_enable_builtins_dts) {
1177      deps += [ "//arkcompiler/ets_runtime:es2abc_gen_builtins_d_abc" ]
1178      _aot_compile_options_ += " --builtins-dts=" + rebase_path(root_out_dir) + "/obj/arkcompiler/ets_runtime/lib_ark_builtins/es2abc/lib_ark_builtins.d.abc"
1179    }
1180
1181    if (defined(invoker.is_enable_global_typeinfer) &&
1182        invoker.is_enable_global_typeinfer) {
1183      _aot_compile_options_ += " --compiler-opt-global-typeinfer=true"
1184    }
1185
1186    args = [
1187      "--script-file",
1188      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
1189      "--script-options",
1190      _aot_compile_options_,
1191      "--script-args",
1192      _script_args_,
1193      "--expect-output",
1194      "0",
1195      "--env-path",
1196      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1197          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1198          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1199          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1200    ]
1201
1202    inputs = [ _test_es2abc_abc_path_ ]
1203
1204    outputs = [ "$target_out_dir/${_target_name_}/es2abc/" ]
1205  }
1206}
1207
1208template("host_quickfix_test_action") {
1209  _target_name_ = "${target_name}"
1210
1211  _test_expect_path_ = "./${_target_name_}/expect_output.txt"
1212  _test_file_name_ = [
1213    "base",
1214    "test",
1215    "retest",
1216    "patch",
1217  ]
1218
1219  if (defined(invoker.extra_patches)) {
1220    _test_file_name_ += invoker.extra_patches
1221  }
1222
1223  if (defined(invoker.entry_point)) {
1224    _script_args_ = invoker.entry_point + " "
1225  }
1226
1227  if (defined(invoker.is_hotpatch) && invoker.is_hotpatch) {
1228    _test_map_path_ = "$target_out_dir/${_target_name_}/base.map"
1229  }
1230
1231  foreach(filename, _test_file_name_) {
1232    merge_file_raw = "//arkcompiler/ets_runtime/test/quickfix/"
1233    if (filename == "test" || filename == "retest") {
1234      merge_file_raw += "${filename}.txt"
1235    } else {
1236      merge_file_raw += "${_target_name_}/${filename}.txt"
1237    }
1238
1239    merge_file = "$target_out_dir/${_target_name_}/${filename}.txt"
1240    merge_file_prefix =
1241        "//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"
1242
1243    action("gen_${_target_name_}_${filename}_merge_file") {
1244      script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
1245      args = [
1246        "--input",
1247        rebase_path(merge_file_raw),
1248        "--output",
1249        rebase_path(merge_file),
1250        "--prefix",
1251        rebase_path(merge_file_prefix),
1252      ]
1253
1254      inputs = [ merge_file_raw ]
1255      outputs = [ merge_file ]
1256    }
1257
1258    abc_path = "$target_out_dir/${_target_name_}/${filename}.abc"
1259
1260    es2abc_gen_abc("gen_${_target_name_}_${filename}_abc") {
1261      extra_visibility =
1262          [ ":*" ]  # Only targets in this file can depend on this.
1263      extra_dependencies = [ ":gen_${_target_name_}_${filename}_merge_file" ]
1264
1265      if (defined(invoker.is_hotpatch) && filename == "patch") {
1266        extra_dependencies += [ ":gen_${_target_name_}_base_abc" ]
1267      }
1268
1269      src_js = "@" + rebase_path(merge_file)
1270      dst_file = rebase_path(abc_path)
1271      extra_args = [
1272        "--module",
1273        "--merge-abc",
1274      ]
1275
1276      if (defined(invoker.is_hotpatch) && filename == "patch") {
1277        extra_args += [ "--generate-patch" ]
1278      }
1279
1280      if (defined(invoker.is_hotpatch) && filename == "base") {
1281        dump_symbol_table = rebase_path(_test_map_path_)
1282      }
1283
1284      if (defined(invoker.is_hotpatch) && filename == "patch") {
1285        input_symbol_table = rebase_path(_test_map_path_)
1286      }
1287
1288      in_puts = [
1289        _test_expect_path_,
1290        merge_file,
1291      ]
1292
1293      if (defined(invoker.is_hotpatch) && filename == "patch") {
1294        in_puts += [ _test_map_path_ ]
1295      }
1296
1297      out_puts = [ abc_path ]
1298
1299      if (defined(invoker.is_hotpatch) && filename == "base") {
1300        out_puts += [ _test_map_path_ ]
1301      }
1302    }
1303
1304    if (filename != _test_file_name_[0]) {
1305      _script_args_ += ":"
1306    }
1307    _script_args_ += rebase_path(abc_path)
1308  }
1309
1310  action("${_target_name_}QuickfixAction") {
1311    testonly = true
1312
1313    _host_quickfix_target_ = "//arkcompiler/ets_runtime/ecmascript/quick_fix:quick_fix(${host_toolchain})"
1314    _root_out_dir_ = get_label_info(_host_quickfix_target_, "root_out_dir")
1315
1316    deps = [ _host_quickfix_target_ ]
1317    foreach(filename, _test_file_name_) {
1318      deps += [ ":gen_${_target_name_}_${filename}_abc" ]
1319    }
1320
1321    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1322
1323    quickfix_options = " --merge-abc true "
1324
1325    args = [
1326      "--script-file",
1327      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/quick_fix",
1328      "--script-options",
1329      quickfix_options,
1330      "--script-args",
1331      _script_args_,
1332      "--timeout-limit",
1333      "500",
1334      "--expect-file",
1335      rebase_path(_test_expect_path_),
1336      "--env-path",
1337      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1338          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1339          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1340          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1341    ]
1342
1343    inputs = []
1344
1345    outputs = [ "$target_out_dir/${_target_name_}/" ]
1346  }
1347}
1348