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# http://www.apache.org/licenses/LICENSE-2.0 6# Unless required by applicable law or agreed to in writing, software 7# distributed under the License is distributed on an "AS IS" BASIS, 8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9# See the License for the specific language governing permissions and 10# limitations under the License. 11 12import("//arkcompiler/runtime_core/static_core/ark_config.gni") 13import("//arkcompiler/runtime_core/static_vm_config.gni") 14import("$ark_root/plugins/plugins.gni") 15 16if (ark_standalone_build) { 17 import("$build_root/ark.gni") 18} else { 19 import("//build/ohos.gni") 20} 21 22ohos_static_library("libarktsassembler_package") { 23 deps = [] 24 if (enable_static_vm) { 25 deps += [ ":libarktsassembler" ] 26 } 27 28 part_name = ark_part_name 29 subsystem_name = "$ark_subsystem_name" 30} 31 32config("arkassembler_public_config") { 33 include_dirs = [ 34 "$ark_root/assembler", 35 "$target_gen_dir", 36 "$target_gen_dir/include", 37 "$ark_root_gen_dir", 38 "$ark_root", 39 ] 40 41 configs = [ "$ark_root/runtime:profiling_gen_public_config" ] 42} 43 44libarkassembler_sources = [ 45 "$target_gen_dir/ins_to_string.cpp", 46 "annotation.cpp", 47 "assembly-emitter.cpp", 48 "assembly-ins.cpp", 49 "assembly-parser.cpp", 50 "assembly-program.cpp", 51 "assembly-type.cpp", 52 "context.cpp", 53 "extensions/extensions.cpp", 54 "lexer.cpp", 55 "meta.cpp", 56 "utils/number-utils.cpp", 57] 58libarkassembler_sources += plugin_libarkassembler_sources 59 60libarkassembler_configs = [ 61 "$ark_root:ark_config", 62 ":arkassembler_public_config", 63 "$ark_root/runtime:arkruntime_public_config", 64 "$ark_root/libpandabase:arkbase_public_config", 65 "$ark_root/libpandafile:arkfile_public_config", 66 "$ark_root/compiler:arkcompiler_public_config", 67] 68libarkassembler_configs += plugin_libarkassembler_configs 69 70group("arktsassembler_header_deps") { 71 deps = [ 72 ":ark_asm_meta_gen_h", 73 ":ark_asm_register_extensions_h", 74 ":isa_gen_libarkassembler_ins_create_api_h", 75 ":isa_gen_libarkassembler_ins_emit_h", 76 ":isa_gen_libarkassembler_isa_h", 77 ":isa_gen_libarkassembler_opcode_parsing_h", 78 ":isa_gen_libarkassembler_operand_types_print_h", 79 ] 80} 81 82ohos_source_set("libarktsassembler_static") { 83 sources = libarkassembler_sources 84 85 public_configs = libarkassembler_configs 86 87 deps = [ 88 ":arktsassembler_header_deps", 89 ":isa_gen_libarkassembler_ins_to_string_cpp", 90 "$ark_root/compiler:libarktscompiler", 91 "$ark_root/libpandabase:libarktsbase", 92 "$ark_root/libpandafile:libarktsfile", 93 "$ark_root/runtime:profiling_gen_profiling_gen_h", 94 ] 95 96 deps += plugin_assembler_deps 97 98 external_deps = [ sdk_libc_secshared_dep ] 99 100 part_name = ark_part_name 101 subsystem_name = "$ark_subsystem_name" 102} 103 104ohos_shared_library("libarktsassembler") { 105 deps = [ ":libarktsassembler_static" ] 106 107 if (is_mingw || is_win) { 108 output_extension = "dll" 109 } else { 110 output_extension = "so" 111 } 112 part_name = ark_part_name 113 subsystem_name = "$ark_subsystem_name" 114} 115 116ohos_source_set("libarktsassembler_frontend_set_static") { 117 sources = libarkassembler_sources 118 119 public_configs = libarkassembler_configs 120 121 deps = [ 122 ":arktsassembler_header_deps", 123 ":isa_gen_libarkassembler_ins_to_string_cpp", 124 "$ark_root/libpandafile:libarktsfile_frontend_static", 125 "$ark_root/runtime:profiling_gen_profiling_gen_h", 126 ] 127 128 deps += plugin_assembler_deps 129 130 external_deps = [ sdk_libc_secshared_dep ] 131 132 part_name = ark_part_name 133 subsystem_name = "$ark_subsystem_name" 134} 135 136ohos_static_library("libarktsassembler_frontend_static") { 137 deps = [ ":libarktsassembler_frontend_set_static" ] 138 part_name = ark_part_name 139 subsystem_name = "$ark_subsystem_name" 140} 141 142ohos_source_set("arkts_asm_static") { 143 sources = [ "pandasm.cpp" ] 144 145 include_dirs = [ "$target_gen_dir" ] 146 147 public_configs = [ 148 ":arkassembler_public_config", 149 "$ark_root:ark_config", 150 "$ark_root/libpandabase:arkbase_public_config", 151 "$ark_root/libpandafile:arkfile_public_config", 152 "$ark_root/compiler:arkcompiler_public_config", 153 "$ark_root/runtime:arkruntime_public_config", 154 ] 155 156 deps = [ 157 ":libarktsassembler_frontend_static", 158 "$ark_root/bytecode_optimizer:libarktsbytecodeopt_frontend_static", 159 "$ark_root/libpandabase:libarktsbase_frontend_static", 160 "$ark_root/libpandafile:libarktsfile_frontend_static", 161 ] 162 163 part_name = ark_part_name 164 subsystem_name = "$ark_subsystem_name" 165} 166 167ohos_executable("arkts_asm") { 168 deps = [ ":arkts_asm_static" ] 169 170 libs = platform_libs 171 ldflags = platform_ldflags 172 173 install_enable = true 174 part_name = ark_part_name 175 subsystem_name = "$ark_subsystem_name" 176} 177 178ark_isa_gen("isa_gen_libarkassembler") { 179 template_files = [ 180 "isa.h.erb", 181 "ins_emit.h.erb", 182 "ins_to_string.cpp.erb", 183 "ins_create_api.h.erb", 184 "opcode_parsing.h.erb", 185 "operand_types_print.h.erb", 186 ] 187 sources = "templates" 188 destination = "$target_gen_dir" 189 requires = [ 190 "asm_isapi.rb", 191 "../libpandafile/pandafile_isapi.rb", 192 ] 193} 194 195ark_gen_file("ark_asm_meta_gen_h") { 196 template_file = "templates/meta_gen.cpp.erb" 197 data = [ "metadata.yaml" ] 198 api = [ "asm_metadata.rb" ] 199 output_file = "$target_gen_dir/meta_gen.h" 200} 201 202ark_gen_file("ark_asm_register_extensions_h") { 203 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 204 template_file = "extensions/register_extensions.h.erb" 205 data = [ ark_plugin_options_yaml ] 206 api = [ "$ark_root/templates/plugin_options.rb" ] 207 output_file = "$target_gen_dir/register_extensions.h" 208} 209