1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License. 4b1994897Sopenharmony_ci# You may obtain a copy of the License at 5b1994897Sopenharmony_ci# 6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 7b1994897Sopenharmony_ci# 8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and 12b1994897Sopenharmony_ci# limitations under the License. 13b1994897Sopenharmony_ci 14b1994897Sopenharmony_ciimport("//arkcompiler/runtime_core/ark_config.gni") 15b1994897Sopenharmony_ci 16b1994897Sopenharmony_ciconfig("arkdisassembler_public_config") { 17b1994897Sopenharmony_ci defines = [ "PANDA_WITH_ECMASCRIPT" ] 18b1994897Sopenharmony_ci} 19b1994897Sopenharmony_ci 20b1994897Sopenharmony_ciarkdisassembler_sources = [ 21b1994897Sopenharmony_ci "$target_gen_dir/bc_ins_to_pandasm_ins.cpp", 22b1994897Sopenharmony_ci "$target_gen_dir/get_ins_info.cpp", 23b1994897Sopenharmony_ci "$target_gen_dir/opcode_translator.cpp", 24b1994897Sopenharmony_ci "$target_gen_dir/type_to_pandasm_type.cpp", 25b1994897Sopenharmony_ci "disassembler.cpp", 26b1994897Sopenharmony_ci] 27b1994897Sopenharmony_ci 28b1994897Sopenharmony_ciarkdisassembler_configs = [ 29b1994897Sopenharmony_ci ":arkdisassembler_public_config", 30b1994897Sopenharmony_ci "$ark_root:ark_config", 31b1994897Sopenharmony_ci "$ark_root/libpandabase:arkbase_public_config", 32b1994897Sopenharmony_ci "$ark_root/assembler:arkassembler_public_config", 33b1994897Sopenharmony_ci "$ark_root/libpandafile:arkfile_public_config", 34b1994897Sopenharmony_ci] 35b1994897Sopenharmony_ci 36b1994897Sopenharmony_ciforeach(plugin, enabled_plugins) { 37b1994897Sopenharmony_ci print("add disassembler plugin: $plugin") 38b1994897Sopenharmony_ci plugin_dir = "$ark_root/plugins/$plugin" 39b1994897Sopenharmony_ci 40b1994897Sopenharmony_ci source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 41b1994897Sopenharmony_ci if (defined(source_files.srcs_disassembler_path)) { 42b1994897Sopenharmony_ci source_file = "$plugin_dir/${source_files.srcs_disassembler_path}" 43b1994897Sopenharmony_ci src_scope = read_file(source_file, "scope") 44b1994897Sopenharmony_ci foreach(src, src_scope.srcs) { 45b1994897Sopenharmony_ci arkdisassembler_sources += [ "$plugin_dir/disassembler/$src" ] 46b1994897Sopenharmony_ci } 47b1994897Sopenharmony_ci src_scope = { 48b1994897Sopenharmony_ci } 49b1994897Sopenharmony_ci } 50b1994897Sopenharmony_ci source_files = [] 51b1994897Sopenharmony_ci} 52b1994897Sopenharmony_ci 53b1994897Sopenharmony_ciohos_shared_library("arkdisassembler") { 54b1994897Sopenharmony_ci stack_protector_ret = false 55b1994897Sopenharmony_ci sources = arkdisassembler_sources 56b1994897Sopenharmony_ci 57b1994897Sopenharmony_ci include_dirs = [ 58b1994897Sopenharmony_ci "$ark_root/disassembler", 59b1994897Sopenharmony_ci "$target_gen_dir", 60b1994897Sopenharmony_ci ] 61b1994897Sopenharmony_ci 62b1994897Sopenharmony_ci configs = arkdisassembler_configs 63b1994897Sopenharmony_ci 64b1994897Sopenharmony_ci deps = [ 65b1994897Sopenharmony_ci ":disasm_plugins_inc", 66b1994897Sopenharmony_ci ":get_language_specific_metadata_inc", 67b1994897Sopenharmony_ci ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp", 68b1994897Sopenharmony_ci ":isa_gen_ark_disam_get_ins_info_cpp", 69b1994897Sopenharmony_ci ":isa_gen_ark_disam_opcode_translator_cpp", 70b1994897Sopenharmony_ci ":type_to_pandasm_type_cpp", 71b1994897Sopenharmony_ci "$ark_root/assembler:libarkassembler", 72b1994897Sopenharmony_ci "$ark_root/libpandabase:libarkbase", 73b1994897Sopenharmony_ci "$ark_root/libpandafile:libarkfile", 74b1994897Sopenharmony_ci ] 75b1994897Sopenharmony_ci 76b1994897Sopenharmony_ci external_deps = [ sdk_libc_secshared_dep ] 77b1994897Sopenharmony_ci 78b1994897Sopenharmony_ci if (!is_standard_system) { 79b1994897Sopenharmony_ci relative_install_dir = "ark" 80b1994897Sopenharmony_ci } 81b1994897Sopenharmony_ci output_extension = "so" 82b1994897Sopenharmony_ci if (is_mingw) { 83b1994897Sopenharmony_ci output_extension = "dll" 84b1994897Sopenharmony_ci } 85b1994897Sopenharmony_ci 86b1994897Sopenharmony_ci part_name = "runtime_core" 87b1994897Sopenharmony_ci subsystem_name = "arkcompiler" 88b1994897Sopenharmony_ci} 89b1994897Sopenharmony_ci 90b1994897Sopenharmony_ciohos_static_library("arkdisassembler_frontend_static") { 91b1994897Sopenharmony_ci stack_protector_ret = false 92b1994897Sopenharmony_ci sources = arkdisassembler_sources 93b1994897Sopenharmony_ci 94b1994897Sopenharmony_ci include_dirs = [ 95b1994897Sopenharmony_ci "$ark_root/disassembler", 96b1994897Sopenharmony_ci "$target_gen_dir", 97b1994897Sopenharmony_ci ] 98b1994897Sopenharmony_ci 99b1994897Sopenharmony_ci configs = arkdisassembler_configs 100b1994897Sopenharmony_ci 101b1994897Sopenharmony_ci deps = [ 102b1994897Sopenharmony_ci ":disasm_plugins_inc", 103b1994897Sopenharmony_ci ":get_language_specific_metadata_inc", 104b1994897Sopenharmony_ci ":isa_gen_ark_disam_bc_ins_to_pandasm_ins_cpp", 105b1994897Sopenharmony_ci ":isa_gen_ark_disam_get_ins_info_cpp", 106b1994897Sopenharmony_ci ":isa_gen_ark_disam_opcode_translator_cpp", 107b1994897Sopenharmony_ci ":type_to_pandasm_type_cpp", 108b1994897Sopenharmony_ci "$ark_root/assembler:libarkassembler_frontend_static", 109b1994897Sopenharmony_ci "$ark_root/libpandabase:libarkbase_frontend_static", 110b1994897Sopenharmony_ci "$ark_root/libpandafile:libarkfile_frontend_static", 111b1994897Sopenharmony_ci ] 112b1994897Sopenharmony_ci external_deps = [ sdk_libc_secshared_dep ] 113b1994897Sopenharmony_ci 114b1994897Sopenharmony_ci part_name = "runtime_core" 115b1994897Sopenharmony_ci subsystem_name = "arkcompiler" 116b1994897Sopenharmony_ci} 117b1994897Sopenharmony_ci 118b1994897Sopenharmony_ciohos_executable("ark_disasm") { 119b1994897Sopenharmony_ci sources = [ "disasm.cpp" ] 120b1994897Sopenharmony_ci 121b1994897Sopenharmony_ci include_dirs = [ 122b1994897Sopenharmony_ci "$target_gen_dir", 123b1994897Sopenharmony_ci "$root_gen_dir/libpandabase", 124b1994897Sopenharmony_ci ] 125b1994897Sopenharmony_ci 126b1994897Sopenharmony_ci configs = [ 127b1994897Sopenharmony_ci "$ark_root:ark_config", 128b1994897Sopenharmony_ci "$ark_root/assembler:arkassembler_public_config", 129b1994897Sopenharmony_ci "$ark_root/libpandabase:arkbase_public_config", 130b1994897Sopenharmony_ci "$ark_root/libpandafile:arkfile_public_config", 131b1994897Sopenharmony_ci ] 132b1994897Sopenharmony_ci 133b1994897Sopenharmony_ci deps = [ 134b1994897Sopenharmony_ci ":arkdisassembler_frontend_static", 135b1994897Sopenharmony_ci "$ark_root/assembler:libarkassembler_frontend_static", 136b1994897Sopenharmony_ci "$ark_root/libpandabase:libarkbase_frontend_static", 137b1994897Sopenharmony_ci "$ark_root/libpandafile:libarkfile_frontend_static", 138b1994897Sopenharmony_ci ] 139b1994897Sopenharmony_ci 140b1994897Sopenharmony_ci external_deps = [ sdk_libc_secshared_dep ] 141b1994897Sopenharmony_ci 142b1994897Sopenharmony_ci libs = platform_libs 143b1994897Sopenharmony_ci if (!is_mac && !is_mingw && (is_build_sdk && !is_ohos)) { 144b1994897Sopenharmony_ci ldflags = platform_ldflags 145b1994897Sopenharmony_ci } 146b1994897Sopenharmony_ci 147b1994897Sopenharmony_ci install_enable = false 148b1994897Sopenharmony_ci part_name = "runtime_core" 149b1994897Sopenharmony_ci subsystem_name = "arkcompiler" 150b1994897Sopenharmony_ci} 151b1994897Sopenharmony_ci 152b1994897Sopenharmony_ciark_isa_gen("isa_gen_ark_disam") { 153b1994897Sopenharmony_ci template_files = [ 154b1994897Sopenharmony_ci "opcode_translator.cpp.erb", 155b1994897Sopenharmony_ci "bc_ins_to_pandasm_ins.cpp.erb", 156b1994897Sopenharmony_ci "get_ins_info.cpp.erb", 157b1994897Sopenharmony_ci ] 158b1994897Sopenharmony_ci sources = "templates" 159b1994897Sopenharmony_ci destination = "$target_gen_dir" 160b1994897Sopenharmony_ci requires = [ 161b1994897Sopenharmony_ci "$ark_root//assembler/asm_isapi.rb", 162b1994897Sopenharmony_ci "$ark_root//libpandafile/pandafile_isapi.rb", 163b1994897Sopenharmony_ci ] 164b1994897Sopenharmony_ci} 165b1994897Sopenharmony_ci 166b1994897Sopenharmony_ciark_gen_file("type_to_pandasm_type_cpp") { 167b1994897Sopenharmony_ci template_file = 168b1994897Sopenharmony_ci "$ark_root/disassembler/templates/type_to_pandasm_type.cpp.erb" 169b1994897Sopenharmony_ci data_file = "$ark_root/libpandafile/types.yaml" 170b1994897Sopenharmony_ci requires = [ "$ark_root/libpandafile/types.rb" ] 171b1994897Sopenharmony_ci output_file = "$target_gen_dir/type_to_pandasm_type.cpp" 172b1994897Sopenharmony_ci} 173b1994897Sopenharmony_ci 174b1994897Sopenharmony_ciark_gen_file("disasm_plugins_inc") { 175b1994897Sopenharmony_ci extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 176b1994897Sopenharmony_ci template_file = "templates/disasm_plugins.inc.erb" 177b1994897Sopenharmony_ci data_file = "$target_gen_dir/../plugin_options.yaml" 178b1994897Sopenharmony_ci requires = [ "$ark_root/templates/plugin_options.rb" ] 179b1994897Sopenharmony_ci output_file = "$target_gen_dir/disasm_plugins.inc" 180b1994897Sopenharmony_ci} 181b1994897Sopenharmony_ci 182b1994897Sopenharmony_ciark_gen_file("get_language_specific_metadata_inc") { 183b1994897Sopenharmony_ci extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 184b1994897Sopenharmony_ci template_file = "templates/get_language_specific_metadata.inc.erb" 185b1994897Sopenharmony_ci data_file = "$target_gen_dir/../plugin_options.yaml" 186b1994897Sopenharmony_ci requires = [ "$ark_root/templates/plugin_options.rb" ] 187b1994897Sopenharmony_ci output_file = "$target_gen_dir/get_language_specific_metadata.inc" 188b1994897Sopenharmony_ci} 189