• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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")
16
17if (ark_standalone_build) {
18  import("$build_root/ark.gni")
19} else {
20  import("//build/ohos.gni")
21}
22
23ark_gen_file("type_to_pandasm_type_cpp") {
24  template_file =
25      "$ark_root/disassembler/templates/type_to_pandasm_type.cpp.erb"
26  data = [ "$ark_root/libpandafile/types.yaml" ]
27  api = [ "$ark_root/libpandafile/types.rb" ]
28  output_file = "$target_gen_dir/type_to_pandasm_type.cpp"
29}
30
31ark_gen_file("disasm_plugins_inc") {
32  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
33  template_file = "templates/disasm_plugins.inc.erb"
34  data = [ ark_plugin_options_yaml ]
35  api = [ "$ark_root/templates/plugin_options.rb" ]
36  output_file = "$target_gen_dir/disasm_plugins.inc"
37}
38
39ark_gen_file("get_language_specific_metadata_inc") {
40  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
41  template_file = "templates/get_language_specific_metadata.inc.erb"
42  data = [ ark_plugin_options_yaml ]
43  api = [ "$ark_root/templates/plugin_options.rb" ]
44  output_file = "$target_gen_dir/get_language_specific_metadata.inc"
45}
46
47config("arkdisassembler_public_config") {
48  include_dirs = [
49    "$ark_root/assembler",
50    "$ark_root_gen_dir/assembler",
51    "$ark_root_gen_dir/disassembler",
52  ]
53  include_dirs +=
54      get_path_info(get_target_outputs(":disasm_plugins_inc"), "dir")
55}
56
57arkdisassembler_sources = [
58  "$target_gen_dir/bc_ins_to_pandasm_ins.cpp",
59  "$target_gen_dir/opcode_translator.cpp",
60  "$target_gen_dir/type_to_pandasm_type.cpp",
61  "disasm_backed_debug_info_extractor.cpp",
62  "disassembler.cpp",
63]
64arkdisassembler_sources += plugin_arkdisassembler_sources
65
66arkdisassembler_configs = [
67  ":arkdisassembler_public_config",
68  "$ark_root:ark_config",
69  "$ark_root/libpandabase:arkbase_public_config",
70  "$ark_root/assembler:arkassembler_public_config",
71  "$ark_root/libpandafile:arkfile_public_config",
72]
73
74ohos_shared_library("arktsdisassembler") {
75  sources = arkdisassembler_sources
76
77  include_dirs = [
78    "$ark_root/disassembler",
79    "$target_gen_dir",
80  ]
81
82  configs = arkdisassembler_configs
83
84  deps = [
85    ":disasm_plugins_inc",
86    ":get_language_specific_metadata_inc",
87    ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp",
88    ":isa_gen_ark_disam_opcode_translator_cpp",
89    ":type_to_pandasm_type_cpp",
90    "$ark_root/assembler:libarktsassembler",
91    "$ark_root/libpandabase:libarktsbase",
92    "$ark_root/libpandafile:libarktsfile",
93  ]
94
95  external_deps = [ sdk_libc_secshared_ext_dep ]
96
97  if (is_mingw || is_win) {
98    output_extension = "dll"
99  } else {
100    output_extension = "so"
101  }
102  part_name = ark_part_name
103  subsystem_name = "$ark_subsystem_name"
104}
105
106ohos_static_library("arktsdisassembler_frontend_static") {
107  sources = arkdisassembler_sources
108
109  include_dirs = [
110    "$ark_root/disassembler",
111    "$target_gen_dir",
112  ]
113
114  configs = arkdisassembler_configs
115
116  deps = [
117    ":disasm_plugins_inc",
118    ":get_language_specific_metadata_inc",
119    ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp",
120    ":isa_gen_ark_disam_opcode_translator_cpp",
121    ":type_to_pandasm_type_cpp",
122    "$ark_root/assembler:libarktsassembler_frontend_static",
123    "$ark_root/libpandabase:libarktsbase_frontend_static",
124    "$ark_root/libpandafile:libarktsfile_frontend_static",
125  ]
126
127  external_deps = [ sdk_libc_secshared_ext_dep ]
128
129  part_name = ark_part_name
130  subsystem_name = ark_subsystem_name
131}
132
133ohos_executable("arkts_disasm") {
134  sources = [ "disasm.cpp" ]
135
136  include_dirs = [
137    "$target_gen_dir",
138    "$ark_root_gen_dir/libpandabase",
139  ]
140
141  configs = [
142    "$ark_root:ark_config",
143    "$ark_root/assembler:arkassembler_public_config",
144    "$ark_root/libpandabase:arkbase_public_config",
145    "$ark_root/libpandafile:arkfile_public_config",
146  ]
147
148  deps = [
149    ":arktsdisassembler_frontend_static",
150    "$ark_root/assembler:libarktsassembler_frontend_static",
151    "$ark_root/libpandabase:libarktsbase_frontend_static",
152    "$ark_root/libpandafile:libarktsfile_frontend_static",
153  ]
154  external_deps = [ sdk_libc_secshared_ext_dep ]
155
156  libs = platform_libs
157  ldflags = platform_ldflags
158
159  install_enable = true
160  part_name = ark_part_name
161  subsystem_name = "$ark_subsystem_name"
162}
163
164ark_isa_gen("isa_gen_ark_disam") {
165  template_files = [
166    "opcode_translator.cpp.erb",
167    "bc_ins_to_pandasm_ins.cpp.erb",
168  ]
169  sources = "templates"
170  destination = "$target_gen_dir"
171  requires = [
172    "$ark_root//assembler/asm_isapi.rb",
173    "$ark_root//libpandafile/pandafile_isapi.rb",
174  ]
175}
176