• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 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/ark_config.gni")
15
16config("arkdisassembler_public_config") {
17  defines = [ "PANDA_WITH_ECMASCRIPT" ]
18}
19
20arkdisassembler_sources = [
21  "$target_gen_dir/bc_ins_to_pandasm_ins.cpp",
22  "$target_gen_dir/get_ins_info.cpp",
23  "$target_gen_dir/opcode_translator.cpp",
24  "$target_gen_dir/type_to_pandasm_type.cpp",
25  "disassembler.cpp",
26]
27
28arkdisassembler_configs = [
29  ":arkdisassembler_public_config",
30  "$ark_root:ark_config",
31  "$ark_root/libpandabase:arkbase_public_config",
32  "$ark_root/assembler:arkassembler_public_config",
33  "$ark_root/libpandafile:arkfile_public_config",
34]
35
36foreach(plugin, enabled_plugins) {
37  print("add disassembler plugin: $plugin")
38  plugin_dir = "$ark_root/plugins/$plugin"
39
40  source_files = read_file("$plugin_dir/subproject_sources.gn", "scope")
41  if (defined(source_files.srcs_disassembler_path)) {
42    source_file = "$plugin_dir/${source_files.srcs_disassembler_path}"
43    src_scope = read_file(source_file, "scope")
44    foreach(src, src_scope.srcs) {
45      arkdisassembler_sources += [ "$plugin_dir/disassembler/$src" ]
46    }
47    src_scope = {
48    }
49  }
50  source_files = []
51}
52
53ohos_shared_library("arkdisassembler") {
54  stack_protector_ret = false
55  sources = arkdisassembler_sources
56
57  include_dirs = [
58    "$ark_root/disassembler",
59    "$target_gen_dir",
60  ]
61
62  configs = arkdisassembler_configs
63
64  deps = [
65    ":disasm_plugins_inc",
66    ":get_language_specific_metadata_inc",
67    ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp",
68    ":isa_gen_ark_disam_get_ins_info_cpp",
69    ":isa_gen_ark_disam_opcode_translator_cpp",
70    ":type_to_pandasm_type_cpp",
71    "$ark_root/assembler:libarkassembler",
72    "$ark_root/libpandabase:libarkbase",
73    "$ark_root/libpandafile:libarkfile",
74  ]
75
76  external_deps = [ sdk_libc_secshared_dep ]
77
78  if (!is_standard_system) {
79    relative_install_dir = "ark"
80  }
81  output_extension = "so"
82  if (is_mingw) {
83    output_extension = "dll"
84  }
85
86  part_name = "runtime_core"
87  subsystem_name = "arkcompiler"
88}
89
90ohos_static_library("arkdisassembler_frontend_static") {
91  stack_protector_ret = false
92  sources = arkdisassembler_sources
93
94  include_dirs = [
95    "$ark_root/disassembler",
96    "$target_gen_dir",
97  ]
98
99  configs = arkdisassembler_configs
100
101  deps = [
102    ":disasm_plugins_inc",
103    ":get_language_specific_metadata_inc",
104    ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp",
105    ":isa_gen_ark_disam_get_ins_info_cpp",
106    ":isa_gen_ark_disam_opcode_translator_cpp",
107    ":type_to_pandasm_type_cpp",
108    "$ark_root/assembler:libarkassembler_frontend_static",
109    "$ark_root/libpandabase:libarkbase_frontend_static",
110    "$ark_root/libpandafile:libarkfile_frontend_static",
111  ]
112  external_deps = [ sdk_libc_secshared_dep ]
113
114  part_name = "runtime_core"
115  subsystem_name = "arkcompiler"
116}
117
118ohos_executable("ark_disasm") {
119  sources = [ "disasm.cpp" ]
120
121  include_dirs = [
122    "$target_gen_dir",
123    "$root_gen_dir/libpandabase",
124  ]
125
126  configs = [
127    "$ark_root:ark_config",
128    "$ark_root/assembler:arkassembler_public_config",
129    "$ark_root/libpandabase:arkbase_public_config",
130    "$ark_root/libpandafile:arkfile_public_config",
131  ]
132
133  deps = [
134    ":arkdisassembler_frontend_static",
135    "$ark_root/assembler:libarkassembler_frontend_static",
136    "$ark_root/libpandabase:libarkbase_frontend_static",
137    "$ark_root/libpandafile:libarkfile_frontend_static",
138  ]
139
140  external_deps = [ sdk_libc_secshared_dep ]
141
142  libs = platform_libs
143  if (!is_mac && !is_mingw && (is_build_sdk && !is_ohos)) {
144    ldflags = platform_ldflags
145  }
146
147  install_enable = false
148  part_name = "runtime_core"
149  subsystem_name = "arkcompiler"
150}
151
152ark_isa_gen("isa_gen_ark_disam") {
153  template_files = [
154    "opcode_translator.cpp.erb",
155    "bc_ins_to_pandasm_ins.cpp.erb",
156    "get_ins_info.cpp.erb",
157  ]
158  sources = "templates"
159  destination = "$target_gen_dir"
160  requires = [
161    "$ark_root//assembler/asm_isapi.rb",
162    "$ark_root//libpandafile/pandafile_isapi.rb",
163  ]
164}
165
166ark_gen_file("type_to_pandasm_type_cpp") {
167  template_file =
168      "$ark_root/disassembler/templates/type_to_pandasm_type.cpp.erb"
169  data_file = "$ark_root/libpandafile/types.yaml"
170  requires = [ "$ark_root/libpandafile/types.rb" ]
171  output_file = "$target_gen_dir/type_to_pandasm_type.cpp"
172}
173
174ark_gen_file("disasm_plugins_inc") {
175  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
176  template_file = "templates/disasm_plugins.inc.erb"
177  data_file = "$target_gen_dir/../plugin_options.yaml"
178  requires = [ "$ark_root/templates/plugin_options.rb" ]
179  output_file = "$target_gen_dir/disasm_plugins.inc"
180}
181
182ark_gen_file("get_language_specific_metadata_inc") {
183  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
184  template_file = "templates/get_language_specific_metadata.inc.erb"
185  data_file = "$target_gen_dir/../plugin_options.yaml"
186  requires = [ "$ark_root/templates/plugin_options.rb" ]
187  output_file = "$target_gen_dir/get_language_specific_metadata.inc"
188}
189