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# 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/ark_config.gni") 13 14config("arkassembler_public_config") { 15 include_dirs = [ 16 "$ark_root/assembler", 17 "$target_gen_dir", 18 "$target_gen_dir/include", 19 "$root_gen_dir/libpandabase", 20 "$ark_root/plugins/ecmascript/assembler", 21 ] 22 23 defines = [ "PANDA_WITH_ECMASCRIPT" ] 24} 25 26if (!ark_standalone_build && !is_arkui_x) { 27 ohos_shared_headers("arkassembler_public_headers") { 28 include_dirs = [ 29 "$ark_root/assembler", 30 "$target_gen_dir", 31 "$target_gen_dir/include", 32 "$root_gen_dir/libpandabase", 33 "$ark_root/plugins/ecmascript/assembler", 34 ] 35 part_name = "runtime_core" 36 subsystem_name = "arkcompiler" 37 } 38} 39 40libarkassembler_sources = [ 41 "$target_gen_dir/function_collect_string.cpp", 42 "$target_gen_dir/ins_to_string.cpp", 43 "annotation.cpp", 44 "assembly-emitter.cpp", 45 "assembly-ins.cpp", 46 "assembly-parser.cpp", 47 "assembly-program.cpp", 48 "assembly-type.cpp", 49 "context.cpp", 50 "emit-item.cpp", 51 "extensions/ecmascript_meta.cpp", 52 "extensions/extensions.cpp", 53 "lexer.cpp", 54 "meta.cpp", 55] 56 57libarkassembler_configs = [ 58 "$ark_root:ark_config", 59 ":arkassembler_public_config", 60 "$ark_root/libpandabase:arkbase_public_config", 61 "$ark_root/libpandafile:arkfile_public_config", 62] 63 64plugin_deps = [] 65foreach(plugin, enabled_plugins) { 66 print("add assembler plugin: $plugin") 67 plugin_dir = "$ark_root/plugins/$plugin" 68 libarkassembler_configs += [ "$plugin_dir:assembler" ] 69 plugin_deps += [ "$plugin_dir:assembler_deps" ] 70 71 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 72 if (defined(source_files.srcs_assembler_path)) { 73 source_file = "$plugin_dir/${source_files.srcs_assembler_path}" 74 src_scope = read_file(source_file, "scope") 75 foreach(src, src_scope.srcs) { 76 libarkassembler_sources += [ "$plugin_dir/assembler/$src" ] 77 } 78 src_scope = { 79 } 80 } 81 source_files = [] 82} 83 84group("arkassembler_header_deps") { 85 deps = [ 86 ":ark_asm_meta_gen_h", 87 ":ark_asm_register_extensions_h", 88 ":isa_gen_libarkassembler_assembly-ins_h", 89 ":isa_gen_libarkassembler_ins_create_api_h", 90 ":isa_gen_libarkassembler_ins_emit_h", 91 ":isa_gen_libarkassembler_isa_h", 92 ":isa_gen_libarkassembler_opcode_parsing_h", 93 ":isa_gen_libarkassembler_operand_types_print_h", 94 ] 95} 96 97ohos_static_library("libarkassembler_static") { 98 sources = libarkassembler_sources 99 100 public_configs = libarkassembler_configs 101 102 deps = [ 103 ":arkassembler_header_deps", 104 ":isa_gen_libarkassembler_function_collect_string_cpp", 105 ":isa_gen_libarkassembler_ins_to_string_cpp", 106 "$ark_root/libpandabase:libarkbase_static", 107 "$ark_root/libpandafile:libarkfile_static", 108 ] 109 110 external_deps = [ sdk_libc_secshared_dep ] 111 if (enable_hilog && defined(ohos_indep_compiler_enable) && 112 ohos_indep_compiler_enable) { 113 external_deps += [ "hilog:libhilog" ] 114 } 115 116 deps += plugin_deps 117 118 part_name = "runtime_core" 119 subsystem_name = "arkcompiler" 120} 121 122ohos_shared_library("libarkassembler") { 123 stack_protector_ret = false 124 deps = [ ":libarkassembler_static" ] 125 126 if (!is_standard_system) { 127 relative_install_dir = "ark" 128 } 129 output_extension = "so" 130 if (is_mingw) { 131 output_extension = "dll" 132 } 133 134 part_name = "runtime_core" 135 subsystem_name = "arkcompiler" 136} 137 138ohos_source_set("libarkassembler_frontend_set_static") { 139 sources = libarkassembler_sources 140 141 public_configs = libarkassembler_configs 142 143 deps = [ 144 ":arkassembler_header_deps", 145 ":isa_gen_libarkassembler_function_collect_string_cpp", 146 ":isa_gen_libarkassembler_ins_to_string_cpp", 147 "$ark_root/libpandabase:libarkbase_frontend_static", 148 "$ark_root/libpandafile:libarkfile_frontend_static", 149 ] 150 151 if (is_arkui_x) { 152 deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ] 153 } else { 154 external_deps = [ sdk_libc_secshared_dep ] 155 if (enable_hilog && defined(ohos_indep_compiler_enable) && 156 ohos_indep_compiler_enable) { 157 external_deps += [ "hilog:libhilog" ] 158 } 159 } 160 161 deps += plugin_deps 162 163 part_name = "runtime_core" 164 subsystem_name = "arkcompiler" 165} 166 167ohos_static_library("libarkassembler_frontend_static") { 168 stack_protector_ret = false 169 deps = [ ":libarkassembler_frontend_set_static" ] 170 171 part_name = "runtime_core" 172 subsystem_name = "arkcompiler" 173} 174 175# ark_asm_static is a legcay component for ts2abc and is no longer valid 176ohos_source_set("ark_asm_static") { 177 sources = [ "pandasm.cpp" ] 178 179 include_dirs = [ 180 "$target_gen_dir", 181 "$root_gen_dir/libpandabase", 182 ] 183 184 public_configs = [ 185 ":arkassembler_public_config", 186 "$ark_root:ark_config", 187 "$ark_root/libpandabase:arkbase_public_config", 188 "$ark_root/libpandafile:arkfile_public_config", 189 ] 190 191 deps = [ 192 ":libarkassembler_frontend_static", 193 "$ark_root/libpandabase:libarkbase_frontend_static", 194 "$ark_root/libpandafile:libarkfile_frontend_static", 195 ] 196 197 external_deps = [ sdk_libc_secshared_dep ] 198 199 libs = platform_libs 200 if (!is_mac && !is_mingw) { 201 ldflags = platform_ldflags 202 } 203 204 part_name = "runtime_core" 205 subsystem_name = "arkcompiler" 206} 207 208ark_isa_gen("isa_gen_libarkassembler") { 209 template_files = [ 210 "isa.h.erb", 211 "function_collect_string.cpp.erb", 212 "ins_emit.h.erb", 213 "ins_to_string.cpp.erb", 214 "ins_create_api.h.erb", 215 "opcode_parsing.h.erb", 216 "operand_types_print.h.erb", 217 "assembly-ins.h.erb", 218 ] 219 sources = "templates" 220 destination = "$target_gen_dir" 221 requires = [ 222 "asm_isapi.rb", 223 "../libpandafile/pandafile_isapi.rb", 224 ] 225} 226 227ark_gen_file("ark_asm_meta_gen_h") { 228 template_file = "templates/meta_gen.cpp.erb" 229 data_file = "metadata.yaml" 230 requires = [ "asm_metadata.rb" ] 231 output_file = "$target_gen_dir/meta_gen.h" 232} 233 234ark_gen_file("ark_asm_register_extensions_h") { 235 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 236 template_file = "extensions/register_extensions.h.erb" 237 data_file = "$target_gen_dir/../plugin_options.yaml" 238 requires = [ "$ark_root/templates/plugin_options.rb" ] 239 output_file = "$target_gen_dir/register_extensions.h" 240} 241