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# http://www.apache.org/licenses/LICENSE-2.0
6# Unless required by applicable law or agreed to in writing, software
7# distributed under the License is distributed on an "AS IS" BASIS,
8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9# See the License for the specific language governing permissions and
10# limitations under the License.
11
12import("//arkcompiler/runtime_core/static_core/ark_config.gni")
13import("//arkcompiler/runtime_core/static_vm_config.gni")
14import("$ark_root/plugins/plugins.gni")
15
16if (ark_standalone_build) {
17  import("$build_root/ark.gni")
18} else {
19  import("//build/ohos.gni")
20}
21
22ohos_static_library("libarktsassembler_package") {
23  deps = []
24  if (enable_static_vm) {
25    deps += [ ":libarktsassembler_frontend_static" ]
26  }
27
28  part_name = ark_part_name
29  subsystem_name = "$ark_subsystem_name"
30}
31
32config("arkassembler_public_config") {
33  include_dirs = [
34    "$ark_root/assembler",
35    "$target_gen_dir",
36    "$target_gen_dir/include",
37    "$ark_root_gen_dir",
38    "$ark_root",
39  ]
40
41  configs = [ "$ark_root/runtime:profiling_gen_public_config" ]
42}
43
44libarkassembler_sources = [
45  "$target_gen_dir/ins_to_string.cpp",
46  "annotation.cpp",
47  "assembly-emitter.cpp",
48  "assembly-ins.cpp",
49  "assembly-parser.cpp",
50  "assembly-program.cpp",
51  "assembly-type.cpp",
52  "context.cpp",
53  "extensions/extensions.cpp",
54  "lexer.cpp",
55  "meta.cpp",
56  "utils/number-utils.cpp",
57]
58libarkassembler_sources += plugin_libarkassembler_sources
59
60libarkassembler_configs = [
61  "$ark_root:ark_config",
62  ":arkassembler_public_config",
63  "$ark_root/runtime:arkruntime_public_config",
64  "$ark_root/libpandabase:arkbase_public_config",
65  "$ark_root/libpandafile:arkfile_public_config",
66  "$ark_root/compiler:arkcompiler_public_config",
67]
68libarkassembler_configs += plugin_libarkassembler_configs
69
70ohos_source_set("libarktsassembler_static") {
71  sources = libarkassembler_sources
72
73  public_configs = libarkassembler_configs
74
75  deps = [
76    ":ark_asm_meta_gen_h",
77    ":ark_asm_register_extensions_h",
78    ":isa_gen_libarkassembler_ins_create_api_h",
79    ":isa_gen_libarkassembler_ins_emit_h",
80    ":isa_gen_libarkassembler_ins_to_string_cpp",
81    ":isa_gen_libarkassembler_isa_h",
82    ":isa_gen_libarkassembler_opcode_parsing_h",
83    ":isa_gen_libarkassembler_operand_types_print_h",
84    "$ark_root/compiler:libarktscompiler",
85    "$ark_root/libpandabase:libarktsbase",
86    "$ark_root/libpandafile:libarktsfile",
87    "$ark_root/runtime:profiling_gen_profiling_gen_h",
88  ]
89
90  deps += plugin_assembler_deps
91
92  external_deps = [ sdk_libc_secshared_dep ]
93
94  part_name = ark_part_name
95  subsystem_name = "$ark_subsystem_name"
96}
97
98ohos_shared_library("libarktsassembler") {
99  deps = [ ":libarktsassembler_static" ]
100
101  output_extension = "so"
102  if (is_mingw) {
103    output_extension = "dll"
104  }
105  part_name = ark_part_name
106  subsystem_name = "$ark_subsystem_name"
107}
108
109ohos_source_set("libarktsassembler_frontend_set_static") {
110  sources = libarkassembler_sources
111
112  public_configs = libarkassembler_configs
113
114  deps = [
115    ":ark_asm_meta_gen_h",
116    ":ark_asm_register_extensions_h",
117    ":isa_gen_libarkassembler_ins_create_api_h",
118    ":isa_gen_libarkassembler_ins_emit_h",
119    ":isa_gen_libarkassembler_ins_to_string_cpp",
120    ":isa_gen_libarkassembler_isa_h",
121    ":isa_gen_libarkassembler_opcode_parsing_h",
122    ":isa_gen_libarkassembler_operand_types_print_h",
123    "$ark_root/libpandafile:libarktsfile_frontend_static",
124    "$ark_root/runtime:profiling_gen_profiling_gen_h",
125  ]
126
127  deps += plugin_assembler_deps
128
129  external_deps = [ sdk_libc_secshared_dep ]
130
131  part_name = ark_part_name
132  subsystem_name = "$ark_subsystem_name"
133}
134
135ohos_static_library("libarktsassembler_frontend_static") {
136  deps = [ ":libarktsassembler_frontend_set_static" ]
137  part_name = ark_part_name
138  subsystem_name = "$ark_subsystem_name"
139}
140
141ohos_source_set("arkts_asm_static") {
142  sources = [ "pandasm.cpp" ]
143
144  include_dirs = [ "$target_gen_dir" ]
145
146  public_configs = [
147    ":arkassembler_public_config",
148    "$ark_root:ark_config",
149    "$ark_root/libpandabase:arkbase_public_config",
150    "$ark_root/libpandafile:arkfile_public_config",
151    "$ark_root/compiler:arkcompiler_public_config",
152    "$ark_root/runtime:arkruntime_public_config",
153  ]
154
155  deps = [
156    ":libarktsassembler_frontend_static",
157    "$ark_root/bytecode_optimizer:libarktsbytecodeopt_frontend_static",
158    "$ark_root/libpandabase:libarktsbase_frontend_static",
159    "$ark_root/libpandafile:libarktsfile_frontend_static",
160  ]
161
162  part_name = ark_part_name
163  subsystem_name = "$ark_subsystem_name"
164}
165
166ohos_executable("arkts_asm") {
167  deps = [ ":arkts_asm_static" ]
168
169  libs = platform_libs
170  ldflags = platform_ldflags
171
172  install_enable = true
173  part_name = ark_part_name
174  subsystem_name = "$ark_subsystem_name"
175}
176
177ark_isa_gen("isa_gen_libarkassembler") {
178  template_files = [
179    "isa.h.erb",
180    "ins_emit.h.erb",
181    "ins_to_string.cpp.erb",
182    "ins_create_api.h.erb",
183    "opcode_parsing.h.erb",
184    "operand_types_print.h.erb",
185  ]
186  sources = "templates"
187  destination = "$target_gen_dir"
188  requires = [
189    "asm_isapi.rb",
190    "../libpandafile/pandafile_isapi.rb",
191  ]
192}
193
194ark_gen_file("ark_asm_meta_gen_h") {
195  template_file = "templates/meta_gen.cpp.erb"
196  data = [ "metadata.yaml" ]
197  api = [ "asm_metadata.rb" ]
198  output_file = "$target_gen_dir/meta_gen.h"
199}
200
201ark_gen_file("ark_asm_register_extensions_h") {
202  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
203  template_file = "extensions/register_extensions.h.erb"
204  data = [ ark_plugin_options_yaml ]
205  api = [ "$ark_root/templates/plugin_options.rb" ]
206  output_file = "$target_gen_dir/register_extensions.h"
207}
208