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_frontend_static" ] 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 44if (!ark_static_standalone_build) { 45 ohos_shared_headers("assembler_headers") { 46 include_dirs = [ 47 "$ark_root/assembler", 48 "$target_gen_dir", 49 "$target_gen_dir/include", 50 "$ark_root_gen_dir", 51 "$ark_root", 52 ] 53 part_name = ark_part_name 54 subsystem_name = "$ark_subsystem_name" 55 } 56} 57 58libarkassembler_sources = [ 59 "$target_gen_dir/ins_to_string.cpp", 60 "annotation.cpp", 61 "assembly-emitter.cpp", 62 "assembly-ins.cpp", 63 "assembly-parser.cpp", 64 "assembly-program.cpp", 65 "assembly-type.cpp", 66 "context.cpp", 67 "extensions/extensions.cpp", 68 "lexer.cpp", 69 "meta.cpp", 70 "utils/number-utils.cpp", 71] 72libarkassembler_sources += plugin_libarkassembler_sources 73 74libarkassembler_configs = [ 75 "$ark_root:ark_config", 76 ":arkassembler_public_config", 77 "$ark_root/runtime:arkruntime_public_config", 78 "$ark_root/libpandabase:arkbase_public_config", 79 "$ark_root/libpandafile:arkfile_public_config", 80 "$ark_root/compiler:arkcompiler_public_config", 81] 82libarkassembler_configs += plugin_libarkassembler_configs 83 84group("arktsassembler_header_deps") { 85 deps = [ 86 ":ark_asm_meta_gen_h", 87 ":ark_asm_register_extensions_h", 88 ":isa_gen_libarkassembler_ins_create_api_h", 89 ":isa_gen_libarkassembler_ins_emit_h", 90 ":isa_gen_libarkassembler_isa_h", 91 ":isa_gen_libarkassembler_opcode_parsing_h", 92 ":isa_gen_libarkassembler_operand_types_print_h", 93 ] 94} 95 96ohos_source_set("libarktsassembler_static") { 97 sources = libarkassembler_sources 98 99 public_configs = libarkassembler_configs 100 101 deps = [ 102 ":arktsassembler_header_deps", 103 ":isa_gen_libarkassembler_ins_to_string_cpp", 104 "$ark_root/compiler:libarktscompiler", 105 "$ark_root/libpandabase:libarktsbase", 106 "$ark_root/libpandafile:libarktsfile", 107 "$ark_root/runtime:profiling_gen_profiling_gen_h", 108 ] 109 110 deps += plugin_assembler_deps 111 112 external_deps = [ sdk_libc_secshared_dep ] 113 114 part_name = ark_part_name 115 subsystem_name = "$ark_subsystem_name" 116} 117 118ohos_shared_library("libarktsassembler") { 119 deps = [ ":libarktsassembler_static" ] 120 121 if (is_mingw || is_win) { 122 output_extension = "dll" 123 } else { 124 output_extension = "so" 125 } 126 part_name = ark_part_name 127 subsystem_name = "$ark_subsystem_name" 128} 129 130ohos_source_set("libarktsassembler_frontend_set_static") { 131 sources = libarkassembler_sources 132 133 public_configs = libarkassembler_configs 134 135 deps = [ 136 ":arktsassembler_header_deps", 137 ":isa_gen_libarkassembler_ins_to_string_cpp", 138 "$ark_root/libpandafile:libarktsfile_frontend_static", 139 "$ark_root/runtime:profiling_gen_profiling_gen_h", 140 ] 141 142 deps += plugin_assembler_deps 143 144 external_deps = [ sdk_libc_secshared_dep ] 145 146 part_name = ark_part_name 147 subsystem_name = "$ark_subsystem_name" 148} 149 150ohos_static_library("libarktsassembler_frontend_static") { 151 deps = [ ":libarktsassembler_frontend_set_static" ] 152 part_name = ark_part_name 153 subsystem_name = "$ark_subsystem_name" 154} 155 156ohos_source_set("arkts_asm_static") { 157 sources = [ "pandasm.cpp" ] 158 159 include_dirs = [ "$target_gen_dir" ] 160 161 public_configs = [ 162 ":arkassembler_public_config", 163 "$ark_root:ark_config", 164 "$ark_root/libpandabase:arkbase_public_config", 165 "$ark_root/libpandafile:arkfile_public_config", 166 "$ark_root/compiler:arkcompiler_public_config", 167 "$ark_root/runtime:arkruntime_public_config", 168 ] 169 170 deps = [ 171 ":libarktsassembler_frontend_static", 172 "$ark_root/bytecode_optimizer:libarktsbytecodeopt_frontend_static", 173 "$ark_root/libpandabase:libarktsbase_frontend_static", 174 "$ark_root/libpandafile:libarktsfile_frontend_static", 175 ] 176 177 part_name = ark_part_name 178 subsystem_name = "$ark_subsystem_name" 179} 180 181ohos_executable("arkts_asm") { 182 deps = [ ":arkts_asm_static" ] 183 184 libs = platform_libs 185 ldflags = platform_ldflags 186 187 install_enable = true 188 part_name = ark_part_name 189 subsystem_name = "$ark_subsystem_name" 190} 191 192ark_isa_gen("isa_gen_libarkassembler") { 193 template_files = [ 194 "isa.h.erb", 195 "ins_emit.h.erb", 196 "ins_to_string.cpp.erb", 197 "ins_create_api.h.erb", 198 "opcode_parsing.h.erb", 199 "operand_types_print.h.erb", 200 ] 201 sources = "templates" 202 destination = "$target_gen_dir" 203 requires = [ 204 "asm_isapi.rb", 205 "../libpandafile/pandafile_isapi.rb", 206 ] 207} 208 209ark_gen_file("ark_asm_meta_gen_h") { 210 template_file = "templates/meta_gen.cpp.erb" 211 data = [ "metadata.yaml" ] 212 api = [ "asm_metadata.rb" ] 213 output_file = "$target_gen_dir/meta_gen.h" 214} 215 216ark_gen_file("ark_asm_register_extensions_h") { 217 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 218 template_file = "extensions/register_extensions.h.erb" 219 data = [ ark_plugin_options_yaml ] 220 api = [ "$ark_root/templates/plugin_options.rb" ] 221 output_file = "$target_gen_dir/register_extensions.h" 222} 223