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