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("$ark_root/plugins/plugins.gni")
16import("$ark_root/verification/verification.gni")
17
18if (ark_standalone_build) {
19  import("$build_root/ark.gni")
20} else {
21  import("//build/ohos.gni")
22}
23
24runtime_yaml = [ "runtime.yaml" ]
25if (enable_irtoc) {
26  runtime_yaml += [ "$ark_root/irtoc/intrinsics.yaml" ]
27}
28runtime_yaml += plugin_runtime_yamls
29
30config("arkruntime_public_config") {
31  include_dirs = [
32    "$ark_root/runtime",
33    get_label_info(
34        "$ark_root/cross_values:cross_values_getters_generate(${default_toolchain})",
35        "target_gen_dir"),
36    "$target_gen_dir",
37    "$target_gen_dir/generated",
38    "$target_gen_dir/include",
39  ]
40
41  include_dirs += platform_include_dirs
42
43  configs = [
44    "$ark_root/libpandabase:arkbase_public_config",
45    "$ark_root/libpandafile:arkfile_public_config",
46    "$ark_root/verification/gen:verification_public_config",
47    "$ark_root/compiler:arkcompiler_public_config",
48  ]
49  configs += plugin_runtime_configs
50}
51
52config("arkruntime_config") {
53  include_dirs = [
54    "$ark_root/compiler",
55    "$ark_root/dprof/libdprof",
56  ]
57  if (ark_standalone_build) {
58    include_dirs += [ "//third_party/icu/icu4c/source" ]
59  }
60
61  cflags_cc = [
62    "-Wno-invalid-offsetof",
63    "-Wno-unused-parameter",
64  ]
65
66  if (current_cpu == "arm64") {
67    asmflags = [ "-march=armv8-a+crc" ]
68  }
69
70  configs = [
71    "$build_root/config/compiler:optimize_speed",
72    "$build_root/config/compiler:no_exceptions",
73    "$build_root/config/compiler:no_rtti",
74  ]
75}
76
77group("arkruntime_header_deps") {
78  deps = [
79    ":arkruntime_gen_entrypoints_entrypoints_gen_S",
80    ":arkruntime_gen_entrypoints_entrypoints_gen_h",
81    ":arkruntime_gen_intrinsics_intrinsics_enum_h",
82    ":arkruntime_gen_intrinsics_intrinsics_gen_h",
83    ":arkruntime_gen_intrinsics_intrinsics_h",
84    ":arkruntime_gen_intrinsics_unimplemented_intrinsics-inl_cpp",
85    ":arkruntime_gen_intrinsics_yaml",
86    ":intrinsics_inl_h",
87    ":isa_gen_libarkruntime_interpreter-inl_gen_h",
88    ":isa_gen_libarkruntime_isa_constants_gen_h",
89    ":language_config_gen_inc",
90    ":libarkruntime_options_gen_h",
91    ":libarkruntime_shorty_values_h",
92    ":plugin_clear_profile_h",
93    ":plugin_destroy_profile_h",
94    ":plugin_dump_profile_h",
95    ":plugin_find_method_in_profile_h",
96    ":plugin_profiling_includes_disasm_h",
97    ":plugin_profiling_includes_h",
98    ":plugin_read_profile_h",
99    ":plugins_asm_defines_def",
100    ":plugins_defines_h",
101    ":plugins_entrypoints_gen_h",
102    ":plugins_inc",
103    ":plugins_interpreters_inl_h",
104    ":profiling_gen_profiling_gen_h",
105    ":substitute_icu_path",
106    "$ark_root/libpandabase:base_options_h",
107    "$ark_root/verification/gen:isa_gen_verification_gen_abs_int_inl_gen_h",
108    "$ark_root/verification/gen:isa_gen_verification_gen_cflow_iterate_inl_gen_h",
109    "$ark_root/verification/gen:isa_gen_verification_gen_handle_gen_h",
110    "$ark_root/verification/gen:isa_gen_verification_gen_job_fill_gen_h",
111    "$ark_root/verification/gen:verification_abs_int_inl_compat_checks_h",
112    "$ark_root/verification/gen:verification_gen_plugins_gen_inc",
113    "$ark_root/verification/gen:verification_verifier_messages_data_cpp",
114    "$ark_root/verification/gen:verification_verifier_messages_h",
115  ]
116  if (enable_irtoc) {
117    deps += [ ":isa_gen_libarkruntime_irtoc_interpreter_utils_h" ]
118  }
119
120  deps += plugin_arkruntime_header_plugin_deps
121}
122
123ohos_source_set("libarkruntime_set_static") {
124  sources = [
125    "arch/asm_support.cpp",
126    "assert_gc_scope.cpp",
127    "bridge/bridge.cpp",
128    "cframe.cpp",
129    "cha.cpp",
130    "class.cpp",
131    "class_helper.cpp",
132    "class_initializer.cpp",
133    "class_linker.cpp",
134    "class_linker_extension.cpp",
135    "compiler.cpp",
136    "compiler_task_manager_worker.cpp",
137    "compiler_thread_pool_worker.cpp",
138    "coretypes/array.cpp",
139    "coretypes/string.cpp",
140    "coroutines/coroutine.cpp",
141    "coroutines/coroutine_events.cpp",
142    "coroutines/coroutine_manager.cpp",
143    "coroutines/coroutine_stats.cpp",
144    "coroutines/stackful_coroutine.cpp",
145    "coroutines/stackful_coroutine_manager.cpp",
146    "coroutines/stackful_coroutine_worker.cpp",
147    "coroutines/threaded_coroutine.cpp",
148    "coroutines/threaded_coroutine_manager.cpp",
149    "default_debugger_agent.cpp",
150    "deoptimization.cpp",
151    "entrypoints/entrypoints.cpp",
152    "exceptions.cpp",
153    "fibers/fiber_context.cpp",
154    "field.cpp",
155    "file_manager.cpp",
156    "gc_task.cpp",
157    "global_object_lock.cpp",
158    "handle_scope.cpp",
159    "hotreload/hotreload.cpp",
160    "imtable_builder.cpp",
161    "init_icu.cpp",
162    "interpreter/interpreter.cpp",
163    "interpreter/runtime_interface.cpp",
164    "intrinsics.cpp",
165    "language_context.cpp",
166    "loadable_agent.cpp",
167    "lock_order_graph.cpp",
168    "locks.cpp",
169    "mark_word.cpp",
170    "mem/allocator.cpp",
171    "mem/gc/bitmap.cpp",
172    "mem/gc/card_table.cpp",
173    "mem/gc/epsilon-g1/epsilon-g1.cpp",
174    "mem/gc/epsilon/epsilon.cpp",
175    "mem/gc/epsilon/epsilon_barrier.cpp",
176    "mem/gc/g1/g1-allocator.cpp",
177    "mem/gc/g1/g1-gc.cpp",
178    "mem/gc/g1/g1-helpers.cpp",
179    "mem/gc/g1/g1_analytics.cpp",
180    "mem/gc/g1/g1_pause_tracker.cpp",
181    "mem/gc/g1/hot_cards.cpp",
182    "mem/gc/g1/ref_updater.cpp",
183    "mem/gc/g1/update_remset_task_queue.cpp",
184    "mem/gc/g1/update_remset_thread.cpp",
185    "mem/gc/g1/update_remset_worker.cpp",
186    "mem/gc/gc-hung/gc_hung.cpp",
187    "mem/gc/gc.cpp",
188    "mem/gc/gc_adaptive_marking_stack.cpp",
189    "mem/gc/gc_barrier_set.cpp",
190    "mem/gc/gc_queue.cpp",
191    "mem/gc/gc_root.cpp",
192    "mem/gc/gc_root_type.cpp",
193    "mem/gc/gc_scope.cpp",
194    "mem/gc/gc_scoped_phase.cpp",
195    "mem/gc/gc_settings.cpp",
196    "mem/gc/gc_stats.cpp",
197    "mem/gc/gc_trigger.cpp",
198    "mem/gc/gen-gc/gen-gc.cpp",
199    "mem/gc/generational-gc-base.cpp",
200    "mem/gc/heap-space-misc/crossing_map.cpp",
201    "mem/gc/heap-space-misc/crossing_map_singleton.cpp",
202    "mem/gc/lang/gc_lang.cpp",
203    "mem/gc/stw-gc/stw-gc.cpp",
204    "mem/gc/workers/gc_worker.cpp",
205    "mem/gc/workers/gc_workers_task_pool.cpp",
206    "mem/gc/workers/gc_workers_task_queue.cpp",
207    "mem/gc/workers/gc_workers_thread_pool.cpp",
208    "mem/heap_manager.cpp",
209    "mem/heap_space.cpp",
210    "mem/heap_verifier.cpp",
211    "mem/internal_allocator.cpp",
212    "mem/mem_stats.cpp",
213    "mem/mem_stats_additional_info.cpp",
214    "mem/mem_stats_default.cpp",
215    "mem/memory_manager.cpp",
216    "mem/object_helpers.cpp",
217    "mem/panda_string.cpp",
218    "mem/refstorage/global_object_storage.cpp",
219    "mem/refstorage/ref_block.cpp",
220    "mem/refstorage/reference_storage.cpp",
221    "mem/region_space.cpp",
222    "mem/rendezvous.cpp",
223    "mem/runslots.cpp",
224    "mem/tlab.cpp",
225    "method.cpp",
226    "methodtrace/trace.cpp",
227    "monitor.cpp",
228    "monitor_object_lock.cpp",
229    "monitor_pool.cpp",
230    "mt_thread_manager.cpp",
231    "object_accessor.cpp",
232    "object_header.cpp",
233    "osr.cpp",
234    "panda_vm.cpp",
235    "plugins.cpp",
236    "profilesaver/profile_dump_info.cpp",
237    "profilesaver/profile_saver.cpp",
238    "regexp/ecmascript/mem/dyn_chunk.cpp",
239    "regexp/ecmascript/regexp_executor.cpp",
240    "regexp/ecmascript/regexp_opcode.cpp",
241    "regexp/ecmascript/regexp_parser.cpp",
242    "relayout_profiler.cpp",
243    "runtime.cpp",
244    "runtime_controller.cpp",
245    "runtime_helpers.cpp",
246    "stack_walker.cpp",
247    "string_table.cpp",
248    "thread.cpp",
249    "time_utils.cpp",
250    "timing.cpp",
251    "tooling/debug_inf.cpp",
252    "tooling/debugger.cpp",
253    "tooling/default_inspector_extension.cpp",
254    "tooling/pt_thread.cpp",
255    "tooling/sampler/lock_free_queue.cpp",
256    "tooling/sampler/sample_writer.cpp",
257    "tooling/sampler/sampling_profiler.cpp",
258    "tooling/sampler/stack_walker_base.cpp",
259    "tooling/sampler/thread_communicator.cpp",
260    "tooling/tools.cpp",
261    "vtable_builder_base.cpp",
262  ]
263
264  if (!is_mingw) {
265    sources += [
266      "dprofiler/dprofiler.cpp",
267      "signal_handler.cpp",
268    ]
269  }
270
271  if (enable_irtoc) {
272    sources += [ "$ark_root_gen_dir/generated/irtoc_lib.o" ]
273    if (is_llvm_interpreter || is_llvm_fastpath) {
274      sources += [ "$ark_root_gen_dir/generated/irtoc_llvm_lib.o" ]
275    }
276  }
277  if (current_cpu == "arm") {
278    sources += [
279      "arch/arm/interpreter_support.S",
280      "arch/arm/osr_arm.S",
281      "bridge/arch/arm/compiled_code_to_interpreter_bridge_arm.S",
282      "bridge/arch/arm/compiled_code_to_interpreter_bridge_dyn_arm.S",
283      "bridge/arch/arm/compiled_code_to_runtime_bridge_arm.S",
284      "bridge/arch/arm/deoptimization_arm.S",
285      "bridge/arch/arm/expand_compiled_code_args_dyn_arm.S",
286      "bridge/arch/arm/interpreter_to_compiled_code_bridge_arm.S",
287      "bridge/arch/arm/interpreter_to_compiled_code_bridge_dyn_arm.S",
288      "fibers/arch/arm/get.S",
289      "fibers/arch/arm/switch.S",
290      "fibers/arch/arm/update.S",
291    ]
292    #TODO add arm32 abi hard
293  } else if (current_cpu == "arm64") {
294    sources += [
295      "arch/aarch64/interpreter_support.S",
296      "arch/aarch64/osr_aarch64.S",
297      "bridge/arch/aarch64/compiled_code_to_interpreter_bridge_aarch64.S",
298      "bridge/arch/aarch64/compiled_code_to_interpreter_bridge_dyn_aarch64.S",
299      "bridge/arch/aarch64/compiled_code_to_runtime_bridge_aarch64.S",
300      "bridge/arch/aarch64/deoptimization_aarch64.S",
301      "bridge/arch/aarch64/expand_compiled_code_args_dyn_aarch64.S",
302      "bridge/arch/aarch64/interpreter_to_compiled_code_bridge_aarch64.S",
303      "bridge/arch/aarch64/interpreter_to_compiled_code_bridge_dyn_aarch64.S",
304      "fibers/arch/aarch64/get.S",
305      "fibers/arch/aarch64/switch.S",
306      "fibers/arch/aarch64/update.S",
307    ]
308  } else if (current_cpu == "x86") {
309    sources += [
310      "arch/x86/interpreter_support.S",
311      "arch/x86/osr_x86.S",
312      "bridge/arch/x86/compiled_code_to_interpreter_bridge_x86.S",
313      "bridge/arch/x86/deoptimization_x86.S",
314      "bridge/arch/x86/interpreter_to_compiled_code_bridge_x86.S",
315    ]
316  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
317             current_cpu == "x86_64") {
318    sources += [
319      "arch/amd64/common_amd64.S",
320      "arch/amd64/interpreter_support.S",
321      "arch/amd64/osr_amd64.S",
322      "bridge/arch/amd64/compiled_code_to_interpreter_bridge_amd64.S",
323      "bridge/arch/amd64/compiled_code_to_interpreter_bridge_dyn_amd64.S",
324      "bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S",
325      "bridge/arch/amd64/deoptimization_amd64.S",
326      "bridge/arch/amd64/expand_compiled_code_args_dyn_amd64.S",
327      "bridge/arch/amd64/interpreter_to_compiled_code_bridge_amd64.S",
328      "bridge/arch/amd64/interpreter_to_compiled_code_bridge_dyn_amd64.S",
329      "fibers/arch/amd64/get.S",
330      "fibers/arch/amd64/switch.S",
331      "fibers/arch/amd64/update.S",
332    ]
333  }
334
335  if (is_mob) {
336    sources += [
337      "$ark_root/platforms/mobile/runtime/thread.cpp",
338      "$ark_root/platforms/mobile/runtime/verify_app_install.cpp",
339    ]
340  } else {
341    sources += [
342      "$ark_root/platforms/common/runtime/thread.cpp",
343      "$ark_root/platforms/common/runtime/verify_app_install.cpp",
344    ]
345  }
346
347  core_vm_sources = [
348    "core/core_class_linker_extension.cpp",
349    "core/core_language_context.cpp",
350    "core/core_vm.cpp",
351  ]
352
353  sources += core_vm_sources
354  sources += verifier_sources + plugin_verifier_sources
355  sources += plugin_runtime_sources
356
357  public_configs = [
358    "$ark_root/assembler:arkassembler_public_config",
359    "$ark_root:ark_config",
360    "$ark_root/libpandabase:arkbase_public_config",
361    "$ark_root/libpandafile:arkfile_public_config",
362    "$ark_root/compiler:arkcompiler_public_config",
363    "$ark_root/verification/gen:verification_public_config",
364    ":arkruntime_public_config",
365    ":arkruntime_config",
366    "$ark_root/runtime/asm_defines:asmdefines_public_config",
367  ]
368
369  public_configs += plugin_runtime_configs
370
371  deps = [
372    ":arkruntime_header_deps",
373    ":arkruntime_interpreter_impl",
374    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_entrypoints_bridge_asm_macro_inl",
375    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsics_enum_inl",
376    "$ark_root/compiler:libarktscompiler",
377    "$ark_root/compiler/aot:libarkaotmanager",
378    "$ark_root/cross_values:cross_values_getters_generate(${default_toolchain})",
379    "$ark_root/libpandabase:libarktsbase",
380    "$ark_root/libpandafile:libarkfile_type_gen_h",
381    "$ark_root/libpandafile:libarktsfile",
382    "$ark_root/libziparchive:libarktsziparchive",
383    "$ark_root/runtime/asm_defines:asm_defines_generator",
384  ]
385
386  if (ark_static_standalone_build) {
387    deps += [ icui18n_dep ]
388  }
389
390  external_deps = [
391    icui18n_dep,
392    icuuc_dep,
393    sdk_libc_secshared_dep,
394  ]
395
396  if (!ark_standalone_build) {
397    external_deps += [ "napi:ace_napi" ]
398  }
399
400  deps += plugin_runtime_deps
401  deps += plugin_arkruntime_stdlib_plugin_deps
402
403  if (!is_mingw) {
404    deps += [ "$ark_root/dprof:libdprof" ]
405  }
406
407  if (enable_irtoc) {
408    deps += [ "$ark_root/irtoc:irtoc_generate" ]
409  }
410
411  if (current_cpu == "arm") {
412    deps += [
413      ":bridge_dispatch_arm",
414      ":bridge_dispatch_dyn_arm",
415    ]
416  } else if (current_cpu == "arm64") {
417    deps += [
418      ":bridge_dispatch_aarch64",
419      ":bridge_dispatch_dyn_aarch64",
420    ]
421  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
422             current_cpu == "x86_64") {
423    deps += [
424      ":bridge_dispatch_amd64",
425      ":bridge_dispatch_dyn_amd64",
426    ]
427  }
428  if (is_ohos && is_standard_system) {
429    defines = [ "PANDA_USE_OHOS_LOG" ]
430  }
431
432  if (is_ohos && is_standard_system) {
433    external_deps += [ "hilog:libhilog" ]
434  }
435  part_name = ark_part_name
436  subsystem_name = ark_subsystem_name
437}
438
439ohos_static_library("libarkruntime_static") {
440  deps = [ ":libarkruntime_set_static" ]
441  output_extension = "a"
442  part_name = ark_part_name
443  subsystem_name = "$ark_subsystem_name"
444}
445
446ohos_shared_library("libarkruntime") {
447  deps = [ ":libarkruntime_set_static" ]
448
449  if (current_cpu == "amd64" || current_cpu == "x64" ||
450      current_cpu == "x86_64") {
451    ldflags = [ "-latomic" ]
452  }
453
454  output_extension = "so"
455  part_name = ark_part_name
456  subsystem_name = "$ark_subsystem_name"
457}
458
459config("arkruntime_interpreter_impl_config") {
460  include_dirs = [
461    "$ark_root/compiler",
462    "$ark_root/libpandabase",
463    "$ark_root/libpandafile",
464    "$ark_root/runtime",
465    "$ark_root/dprof/libdprof",
466    get_label_info(
467        "$ark_root/cross_values:cross_values_getters_generate(${default_toolchain})",
468        "target_gen_dir"),
469    "$target_gen_dir",
470    "$target_gen_dir/generated",
471    "$target_gen_dir/include",
472  ]
473
474  include_dirs += platform_include_dirs
475
476  configs = plugin_runtime_interpreter_impl_configs
477
478  cflags_cc = [
479    "-Wno-invalid-offsetof",
480    "-Wno-unused-parameter",
481  ]
482  defines = []
483
484  if (ark_enable_global_register_variables) {
485    if (current_cpu == "arm64") {
486      cflags_cc += [
487        "-ffixed-x20",
488        "-ffixed-x21",
489        "-ffixed-x22",
490        "-ffixed-x23",
491        "-ffixed-x24",
492        "-ffixed-x25",
493        "-ffixed-x28",
494      ]
495      defines += [ "FFIXED_REGISTERS" ]
496    }
497  }
498}
499
500ohos_source_set("arkruntime_interpreter_impl_static") {
501  sources = [ "interpreter/interpreter_impl.cpp" ]
502
503  public_configs = [
504    "$ark_root:ark_config",
505    "$ark_root/libpandabase:arkbase_public_config",
506    "$ark_root/libpandafile:arkfile_public_config",
507    "$ark_root/runtime:arkruntime_public_config",
508    "$ark_root/compiler:arkcompiler_public_config",
509    "$ark_root/verification/gen:verification_public_config",
510    ":arkruntime_interpreter_impl_config",
511  ]
512
513  deps = [
514    ":arkruntime_header_deps",
515    "$ark_root/cross_values:cross_values_getters_generate(${default_toolchain})",
516    "$ark_root/libpandabase:libarktsbase",
517    "$ark_root/libpandafile:libarktsfile",
518  ]
519
520  external_deps = [ sdk_libc_secshared_dep ]
521
522  deps += plugin_arkruntime_stdlib_plugin_deps
523
524  part_name = ark_part_name
525  subsystem_name = "$ark_subsystem_name"
526}
527
528# panda_set_lib_32bit_property not used in android
529ohos_static_library("arkruntime_interpreter_impl") {
530  deps = [ ":arkruntime_interpreter_impl_static" ]
531  part_name = ark_part_name
532  subsystem_name = ark_subsystem_name
533}
534
535template("gen_intrinsics_yaml") {
536  assert(defined(invoker.data_files), "data_files required!")
537  assert(defined(invoker.output_file), "output_file required!")
538
539  data_files = string_join(",", rebase_path(invoker.data_files, root_build_dir))
540  template_file = "templates/intrinsics.yaml.erb"
541  requires = string_join(",",
542                         [
543                           rebase_path("templates/runtime.rb", root_build_dir),
544                           rebase_path("$ark_root/libpandabase/utils.rb",
545                                       root_build_dir),
546                         ])
547
548  action("$target_name") {
549    script = "$ark_root/runtime/templates/gen_intrinsics_data.rb"
550
551    # rerun action when data file or template file update
552    inputs = [ template_file ]
553    inputs += invoker.data_files
554
555    outputs = [ invoker.output_file ]
556    args = [
557      rebase_path("templates/runtime.rb", root_build_dir),
558      "-d",
559      data_files,
560      "-t",
561      rebase_path(template_file, root_build_dir),
562      "-o",
563      rebase_path(outputs[0]),
564      "-r",
565      requires,
566    ]
567  }
568}
569
570gen_intrinsics_yaml("arkruntime_gen_intrinsics_yaml") {
571  data_files = runtime_yaml
572  output_file = "$target_gen_dir/intrinsics.yaml"
573}
574
575gen_include_dir = "$target_gen_dir/include"
576
577ark_isa_gen("profiling_gen") {
578  template_files = [ "profiling_gen.h.erb" ]
579  sources = "profiling"
580  destination = "$target_gen_dir/runtime/include"
581}
582
583config("profiling_gen_public_config") {
584  include_dirs =
585      [ get_label_info(":profiling_gen_profiling_gen_h", "target_gen_dir") ]
586}
587
588ark_isa_gen("isa_gen_libarkruntime") {
589  template_files = [
590    "interpreter-inl_gen.h.erb",
591    "isa_constants_gen.h.erb",
592  ]
593  if (enable_irtoc) {
594    template_files += [ "irtoc_interpreter_utils.h.erb" ]
595  }
596  sources = "interpreter/templates"
597  destination = gen_include_dir
598}
599
600isa = ark_isa_yaml
601isa_api = "$ark_root/isa/isapi.rb"
602bridge_dispatch_template = "templates/bridge_dispatch.S.erb"
603bridge_dispatch_dyn_template = "templates/bridge_dispatch_dyn.S.erb"
604bridge_archs = [
605  "aarch64",
606  "arm",
607  "armhf",
608  "amd64",
609  "x86",
610]
611foreach(arch, bridge_archs) {
612  ark_gen_file("bridge_dispatch_${arch}") {
613    data = [ isa ]
614    template_file = bridge_dispatch_template
615    output_file = "$gen_include_dir/bridge_dispatch_${arch}.S"
616    api = [ isa_api ]
617    requires = [
618      "templates/bridge_helpers_${arch}.rb",
619      "templates/bridge_helpers_common.rb",
620      "templates/bridge_helpers_static.rb",
621    ]
622    extra_dependencies = [ "$ark_root/isa:isa_combine" ]
623  }
624
625  ark_gen_file("bridge_dispatch_dyn_${arch}") {
626    data = [ isa ]
627    template_file = bridge_dispatch_dyn_template
628    output_file = "$gen_include_dir/bridge_dispatch_dyn_${arch}.S"
629    api = [ isa_api ]
630    requires = [
631      "templates/bridge_helpers_dynamic.rb",
632      "templates/bridge_helpers_common.rb",
633      "templates/bridge_helpers_${arch}.rb",
634    ]
635    extra_dependencies = [ "$ark_root/isa:isa_combine" ]
636  }
637}
638
639ark_gen("arkruntime_gen_entrypoints") {
640  data = [ "$target_gen_dir/entrypoints.yaml" ]
641  template_files = [
642    "entrypoints_gen.h.erb",
643    "entrypoints_gen.S.erb",
644    "entrypoints_compiler.inl.erb",
645  ]
646  api = [ "entrypoints/entrypoints.rb" ]
647  requires = [ "$ark_root/templates/common.rb" ]
648  sources = "entrypoints"
649  destination = "$target_gen_dir/generated"
650  extra_dependencies = [ "$ark_root:concat_entrypoints_yamls" ]
651}
652
653# Substitute ICU path
654action("substitute_icu_path") {
655  script = "templates/substitute_icu_path.rb"
656  outputs = [ "$target_gen_dir/init_icu_gen.cpp" ]
657  args = [
658    rebase_path("templates/init_icu_gen.cpp.erb"),
659    rebase_path("$target_gen_dir/init_icu_gen.cpp"),
660    rebase_path(ark_third_party_root),
661  ]
662}
663
664ark_gen("arkruntime_gen_entrypoints_compiler_checksum") {
665  data = [ "entrypoints/entrypoints.yaml" ]
666  template_files = [ "entrypoints_compiler_checksum.inl.erb" ]
667  api = [ "entrypoints/entrypoints.rb" ]
668  sources = "entrypoints"
669  destination = "$target_gen_dir/generated"
670  extra_dependencies =
671      [ "$ark_root/cross_values:cross_values_generate(${default_toolchain})" ]
672  extra_argv = [ rebase_path(
673          get_label_info(
674              "$ark_root/cross_values:cross_values_generate(${default_toolchain})",
675              "target_gen_dir"),
676          root_build_dir) ]
677}
678
679ark_gen("arkruntime_gen_intrinsics") {
680  if (enable_libabckit && current_toolchain == host_toolchain) {
681    data = [ "$target_gen_dir/abckit_intrinsics.yaml" ]
682  } else {
683    data = [ "$target_gen_dir/intrinsics.yaml" ]
684  }
685  template_files = [
686    "intrinsics_gen.h.erb",
687    "intrinsics.h.erb",
688    "intrinsics_enum.h.erb",
689    "unimplemented_intrinsics-inl.cpp.erb",
690  ]
691  api = [ "templates/intrinsics.rb" ]
692  requires = [ "$ark_root/libpandabase/utils.rb" ]
693  sources = "templates"
694  destination = "$target_gen_dir"
695  extra_dependencies = [ ":arkruntime_gen_intrinsics_yaml" ]
696  if (enable_libabckit && current_toolchain == host_toolchain) {
697    extra_dependencies +=
698        [ "$ark_root/../libabckit:concat_abckit_intrinsics_yaml" ]
699  }
700}
701
702ark_gen_file("libarkruntime_options_gen_h") {
703  template_file = "../templates/options/options.h.erb"
704  data = [ "$target_gen_dir/../runtime_options.yaml" ]
705  api = [ "../templates/common.rb" ]
706  output_file = "$target_gen_dir/generated/runtime_options_gen.h"
707  extra_dependencies = [ "$ark_root:merge_runtime_options_yamls" ]
708}
709
710ark_gen_file("libarkruntime_shorty_values_h") {
711  template_file = "templates/shorty_values.h.erb"
712  data = [ "../libpandafile/types.yaml" ]
713  api = [ "../libpandafile/types.rb" ]
714  output_file = "$target_gen_dir/generated/shorty_values.h"
715}
716
717ark_gen_file("plugins_inc") {
718  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
719  template_file = "templates/plugins.inc.erb"
720  data = [ ark_plugin_options_yaml ]
721  api = [ "$ark_root/templates/plugin_options.rb" ]
722  output_file = "$target_gen_dir/plugins.inc"
723}
724
725ark_gen_file("plugins_entrypoints_gen_h") {
726  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
727  template_file = "entrypoints/plugins_entrypoints_gen.h.erb"
728  data = [ ark_plugin_options_yaml ]
729  api = [ "$ark_root/templates/plugin_options.rb" ]
730  output_file = "$target_gen_dir/plugins_entrypoints_gen.h"
731}
732
733ark_gen_file("plugins_interpreters_inl_h") {
734  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
735  template_file = "templates/plugins_interpreters-inl.h.erb"
736  data = [ ark_plugin_options_yaml ]
737  api = [ "$ark_root/templates/plugin_options.rb" ]
738  output_file = "$target_gen_dir/plugins_interpreters-inl.h"
739}
740
741ark_gen_file("language_config_gen_inc") {
742  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
743  template_file = "templates/language_config_gen.inc.erb"
744  data = [ ark_plugin_options_yaml ]
745  api = [ "$ark_root/templates/plugin_options.rb" ]
746  output_file = "$target_gen_dir/language_config_gen.inc"
747}
748
749ark_gen_file("intrinsics_inl_h") {
750  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
751  template_file = "templates/intrinsics.inl.h.erb"
752  data = [ ark_plugin_options_yaml ]
753  api = [ "$ark_root/templates/plugin_options.rb" ]
754  output_file = "$target_gen_dir/intrinsics.inl.h"
755}
756
757ark_gen_file("plugins_defines_h") {
758  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
759  template_file = "templates/plugins_defines.h.erb"
760  data = [ ark_plugin_options_yaml ]
761  api = [ "$ark_root/templates/plugin_options.rb" ]
762  output_file = "$target_gen_dir/plugins_defines.h"
763}
764
765ark_gen_file("plugins_asm_defines_def") {
766  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
767  template_file = "templates/plugins_asm_defines.def.erb"
768  data = [ ark_plugin_options_yaml ]
769  api = [ "$ark_root/templates/plugin_options.rb" ]
770  output_file = "$target_gen_dir/plugins_asm_defines.def"
771}
772
773generated_file("plugin_read_profile_h") {
774  outputs = [ "$target_gen_dir/profiling/generated/read_profile.h" ]
775  contents = plugin_read_profile_paths
776  output_conversion = "list lines"
777}
778generated_file("plugin_clear_profile_h") {
779  outputs = [ "$target_gen_dir/profiling/generated/clear_profile.h" ]
780  contents = plugin_clear_profile_paths
781  output_conversion = "list lines"
782}
783generated_file("plugin_destroy_profile_h") {
784  outputs = [ "$target_gen_dir/profiling/generated/destroy_profile.h" ]
785  contents = plugin_destroy_profile_paths
786  output_conversion = "list lines"
787}
788generated_file("plugin_dump_profile_h") {
789  outputs = [ "$target_gen_dir/profiling/generated/dump_profile.h" ]
790  contents = plugin_dump_profile_paths
791  output_conversion = "list lines"
792}
793generated_file("plugin_find_method_in_profile_h") {
794  outputs = [ "$target_gen_dir/profiling/generated/find_method_in_profile.h" ]
795  contents = plugin_find_method_in_profile_paths
796  output_conversion = "list lines"
797}
798generated_file("plugin_profiling_includes_disasm_h") {
799  outputs =
800      [ "$target_gen_dir/profiling/generated/profiling_includes_disasm.h" ]
801  contents = plugin_profiling_includes_disasm_paths
802  output_conversion = "list lines"
803}
804generated_file("plugin_profiling_includes_h") {
805  outputs = [ "$target_gen_dir/profiling/generated/profiling_includes.h" ]
806  contents = plugin_profiling_includes_paths
807  output_conversion = "list lines"
808}
809generated_file("get_profiling_any_type_h") {
810  outputs = [ "$target_gen_dir/profiling/generated/get_profiling_any_type.h" ]
811  contents = plugin_get_profiling_any_type_paths
812  output_conversion = "list lines"
813}
814