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", 21 "$ark_root/plugins/ecmascript/assembler", 22 ] 23 24 defines = [ "PANDA_WITH_ECMASCRIPT" ] 25} 26 27libarkassembler_sources = [ 28 "$target_gen_dir/ins_to_string.cpp", 29 "annotation.cpp", 30 "assembly-emitter.cpp", 31 "assembly-ins.cpp", 32 "assembly-parser.cpp", 33 "assembly-program.cpp", 34 "assembly-type.cpp", 35 "context.cpp", 36 "extensions/ecmascript_meta.cpp", 37 "extensions/extensions.cpp", 38 "lexer.cpp", 39 "meta.cpp", 40] 41 42libarkassembler_configs = [ 43 sdk_libc_secshared_config, 44 "$ark_root:ark_config", 45 ":arkassembler_public_config", 46 "$ark_root/libpandabase:arkbase_public_config", 47 "$ark_root/libpandafile:arkfile_public_config", 48] 49 50plugin_deps = [] 51foreach(plugin, enabled_plugins) { 52 print("add assembler plugin: $plugin") 53 plugin_dir = "$ark_root/plugins/$plugin" 54 libarkassembler_configs += [ "$plugin_dir:assembler" ] 55 plugin_deps += [ "$plugin_dir:assembler_deps" ] 56 57 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 58 if (defined(source_files.srcs_assembler_path)) { 59 source_file = "$plugin_dir/${source_files.srcs_assembler_path}" 60 src_scope = read_file(source_file, "scope") 61 foreach(src, src_scope.srcs) { 62 libarkassembler_sources += [ "$plugin_dir/assembler/$src" ] 63 } 64 src_scope = { 65 } 66 } 67 source_files = [] 68} 69 70source_set("libarkassembler_static") { 71 sources = libarkassembler_sources 72 73 public_configs = libarkassembler_configs 74 75 deps = [ 76 ":ark_asm_meta_gen_h", 77 ":ark_asm_register_extensions_h", 78 ":isa_gen_libarkassembler_ins_create_api_h", 79 ":isa_gen_libarkassembler_ins_emit_h", 80 ":isa_gen_libarkassembler_ins_to_string_cpp", 81 ":isa_gen_libarkassembler_isa_h", 82 ":isa_gen_libarkassembler_opcode_parsing_h", 83 ":isa_gen_libarkassembler_operand_types_print_h", 84 "$ark_root/libpandabase:libarkbase_static", 85 "$ark_root/libpandafile:libarkfile_static", 86 sdk_libc_secshared_dep, 87 ] 88 89 deps += plugin_deps 90} 91 92ohos_shared_library("libarkassembler") { 93 stack_protector_ret = false 94 deps = [ ":libarkassembler_static" ] 95 96 if (!is_standard_system) { 97 relative_install_dir = "ark" 98 } 99 output_extension = "so" 100 if (is_mingw) { 101 output_extension = "dll" 102 } 103 104 part_name = "runtime_core" 105 subsystem_name = "arkcompiler" 106} 107 108source_set("libarkassembler_frontend_set_static") { 109 sources = libarkassembler_sources 110 111 public_configs = libarkassembler_configs 112 113 deps = [ 114 ":ark_asm_meta_gen_h", 115 ":ark_asm_register_extensions_h", 116 ":isa_gen_libarkassembler_ins_create_api_h", 117 ":isa_gen_libarkassembler_ins_emit_h", 118 ":isa_gen_libarkassembler_ins_to_string_cpp", 119 ":isa_gen_libarkassembler_isa_h", 120 ":isa_gen_libarkassembler_opcode_parsing_h", 121 ":isa_gen_libarkassembler_operand_types_print_h", 122 "$ark_root/libpandabase:libarkbase_frontend_static", 123 "$ark_root/libpandafile:libarkfile_frontend_static", 124 sdk_libc_secshared_dep, 125 ] 126 127 deps += plugin_deps 128} 129 130ohos_static_library("libarkassembler_frontend_static") { 131 stack_protector_ret = false 132 deps = [ ":libarkassembler_frontend_set_static" ] 133 134 part_name = "runtime_core" 135 subsystem_name = "arkcompiler" 136} 137 138source_set("ark_asm_static") { 139 sources = [ "pandasm.cpp" ] 140 141 include_dirs = [ 142 "$target_gen_dir", 143 "$root_gen_dir/libpandabase", 144 ] 145 146 public_configs = [ 147 sdk_libc_secshared_config, 148 ":arkassembler_public_config", 149 "$ark_root:ark_config", 150 "$ark_root/libpandabase:arkbase_public_config", 151 "$ark_root/libpandafile:arkfile_public_config", 152 ] 153 154 deps = [ 155 ":libarkassembler_frontend_static", 156 "$ark_root/libpandabase:libarkbase_frontend_static", 157 "$ark_root/libpandafile:libarkfile_frontend_static", 158 ] 159 160 libs = platform_libs 161 if (!is_mac && !is_mingw) { 162 ldflags = platform_ldflags 163 } 164} 165 166ohos_executable("ark_asm") { 167 deps = [ ":ark_asm_static" ] 168 169 install_enable = false 170 part_name = "runtime_core" 171 subsystem_name = "arkcompiler" 172} 173 174ark_isa_gen("isa_gen_libarkassembler") { 175 template_files = [ 176 "isa.h.erb", 177 "ins_emit.h.erb", 178 "ins_to_string.cpp.erb", 179 "ins_create_api.h.erb", 180 "opcode_parsing.h.erb", 181 "operand_types_print.h.erb", 182 ] 183 sources = "templates" 184 destination = "$target_gen_dir" 185 requires = [ 186 "asm_isapi.rb", 187 "../libpandafile/pandafile_isapi.rb", 188 ] 189} 190 191ark_gen_file("ark_asm_meta_gen_h") { 192 template_file = "templates/meta_gen.cpp.erb" 193 data_file = "metadata.yaml" 194 requires = [ "asm_metadata.rb" ] 195 output_file = "$target_gen_dir/meta_gen.h" 196} 197 198ark_gen_file("ark_asm_register_extensions_h") { 199 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 200 template_file = "extensions/register_extensions.h.erb" 201 data_file = "$target_gen_dir/../plugin_options.yaml" 202 requires = [ "$ark_root/templates/plugin_options.rb" ] 203 output_file = "$target_gen_dir/register_extensions.h" 204} 205