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