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# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//arkcompiler/runtime_core/ark_config.gni") 15 16config("arkfile_public_config") { 17 include_dirs = [ 18 "$ark_root/libpandafile", 19 "$ark_root/libziparchive", 20 "$target_gen_dir", 21 "$target_gen_dir/include", 22 ] 23 24 defines = [] 25 if (is_ohos && !is_standard_system) { 26 defines += [ "ENABLE_FULL_FILE_FIELDS" ] 27 } 28} 29 30config("arkfile_runtime_public_config") { 31 include_dirs = [ 32 "$ark_root/libpandafile", 33 "$ark_root/libziparchive", 34 "$target_gen_dir", 35 "$target_gen_dir/include", 36 ] 37 38 defines = [ "ERROR_AS_FATAL" ] 39 if (is_ohos && !is_standard_system) { 40 defines += [ "ENABLE_FULL_FILE_FIELDS" ] 41 } 42} 43 44config("data_protect_configs") { 45 cflags_cc = [ "-march=armv8.4-a" ] 46 defines = [ "PANDA_ENABLE_DATA_PROTECT" ] 47} 48 49config("arkfile_fuzz_config") { 50 configs = [ "$build_root/config/compiler:exceptions" ] 51 defines = [ "SUPPORT_KNOWN_EXCEPTION" ] 52} 53 54config("arkfile_verifier_config") { 55 include_dirs = [ 56 "$ark_root/libpandafile", 57 "$ark_root/libziparchive", 58 "$target_gen_dir", 59 "$target_gen_dir/include", 60 ] 61 62 defines = [] 63 if (is_ohos && !is_standard_system) { 64 defines += [ "ENABLE_FULL_FILE_FIELDS" ] 65 } 66 67 defines += [ "FATAL_AS_ERROR" ] 68} 69 70libarkfile_sources = [ 71 "annotation_data_accessor.cpp", 72 "bytecode_emitter.cpp", 73 "class_data_accessor.cpp", 74 "code_data_accessor.cpp", 75 "debug_data_accessor.cpp", 76 "debug_info_extractor.cpp", 77 "field_data_accessor.cpp", 78 "file.cpp", 79 "file_format_version.cpp", 80 "file_item_container.cpp", 81 "file_items.cpp", 82 "file_writer.cpp", 83 "literal_data_accessor.cpp", 84 "method_data_accessor.cpp", 85 "method_handle_data_accessor.cpp", 86 "module_data_accessor.cpp", 87 "pgo.cpp", 88 "util/collect_util.cpp", 89] 90 91libarkfile_configs = [ 92 "$ark_root:ark_config", 93 "$ark_root/libpandabase:arkbase_public_config", 94 ":arkfile_public_config", 95] 96 97libarkfile_runtime_configs = [ 98 "$ark_root:ark_config", 99 "$ark_root/libpandabase:arkbase_public_config", 100 ":arkfile_runtime_public_config", 101] 102 103ohos_static_library("arkfile_header_deps") { 104 deps = [ 105 ":isa_gen_libarkfile_bytecode_emitter_def_gen_h", 106 ":isa_gen_libarkfile_bytecode_emitter_gen_h", 107 ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h", 108 ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h", 109 ":isa_gen_libarkfile_file_format_version_h", 110 ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h", 111 ":libarkfile_type_gen_h", 112 ":source_lang_enum_h", 113 "$ark_root/libpandabase:arkbase_header_deps", 114 ] 115 part_name = "runtime_core" 116 subsystem_name = "arkcompiler" 117} 118 119ohos_static_library("libarkfile_static") { 120 sources = libarkfile_sources 121 122 public_configs = libarkfile_configs 123 124 if (enabled_pac_data_protect) { 125 configs = libarkfile_configs 126 configs += [ ":data_protect_configs" ] 127 } 128 129 deps = [ 130 ":arkfile_header_deps", 131 "$ark_root/libpandabase:libarkbase_static", 132 "$ark_root/libziparchive:libarkziparchive_static", 133 ] 134 135 if (is_arkui_x) { 136 deps += [ 137 "$ark_third_party_root/bounds_checking_function:libsec_static", 138 "$ark_third_party_root/zlib:libz", 139 ] 140 } else if (ark_standalone_build) { 141 external_deps = [ 142 "zlib:shared_libz", 143 sdk_libc_secshared_dep, 144 ] 145 } else { 146 public_external_deps = [ 147 "zlib:shared_libz", 148 sdk_libc_secshared_dep, 149 ] 150 } 151 152 if (enable_hilog) { 153 public_external_deps += [ "hilog:libhilog" ] 154 } 155 156 part_name = "runtime_core" 157 subsystem_name = "arkcompiler" 158} 159 160ohos_static_library("libarkfile_runtime_static") { 161 sources = libarkfile_sources 162 163 public_configs = libarkfile_runtime_configs 164 165 if (enabled_pac_data_protect) { 166 configs = libarkfile_runtime_configs 167 configs += [ ":data_protect_configs" ] 168 } 169 170 deps = [ 171 ":arkfile_header_deps", 172 "$ark_root/libpandabase:libarkbase_static", 173 "$ark_root/libziparchive:libarkziparchive_static", 174 ] 175 176 if (is_arkui_x) { 177 deps += [ 178 "$ark_third_party_root/bounds_checking_function:libsec_static", 179 "$ark_third_party_root/zlib:libz", 180 ] 181 } else if (ark_standalone_build) { 182 external_deps = [ 183 "zlib:shared_libz", 184 sdk_libc_secshared_dep, 185 ] 186 } else { 187 public_external_deps = [ 188 "zlib:shared_libz", 189 sdk_libc_secshared_dep, 190 ] 191 } 192 193 if (enable_hilog) { 194 public_external_deps += [ "hilog:libhilog" ] 195 } 196 197 part_name = "runtime_core" 198 subsystem_name = "arkcompiler" 199} 200 201ohos_source_set("libarkfile_static_fuzz") { 202 sources = libarkfile_sources 203 204 public_configs = libarkfile_configs 205 public_configs += [ ":arkfile_fuzz_config" ] 206 207 deps = [ 208 ":arkfile_header_deps", 209 "$ark_root/libpandabase:libarkbase_static", 210 "$ark_root/libziparchive:libarkziparchive_static", 211 ] 212 213 if (!ark_standalone_build) { 214 public_external_deps = [ 215 "zlib:libz", 216 sdk_libc_secshared_dep, 217 ] 218 } else { 219 external_deps = [ 220 "zlib:libz", 221 sdk_libc_secshared_dep, 222 ] 223 } 224 225 if (enable_hilog) { 226 public_external_deps += [ "hilog:libhilog" ] 227 } 228 229 part_name = "runtime_core" 230 subsystem_name = "arkcompiler" 231} 232 233ohos_source_set("libarkfile_static_verifier") { 234 sources = libarkfile_sources 235 236 public_configs = [ 237 "$ark_root:ark_config", 238 "$ark_root/libpandabase:arkbase_public_config", 239 ":arkfile_verifier_config", 240 ] 241 242 deps = [ 243 ":arkfile_header_deps", 244 "$ark_root/libpandabase:libarkbase_static", 245 "$ark_root/libziparchive:libarkziparchive_static", 246 ] 247 248 if (!ark_standalone_build) { 249 public_external_deps = [ 250 "zlib:shared_libz", 251 sdk_libc_secshared_dep, 252 ] 253 } else { 254 external_deps = [ 255 "zlib:shared_libz", 256 sdk_libc_secshared_dep, 257 ] 258 } 259 260 part_name = "runtime_core" 261 subsystem_name = "arkcompiler" 262} 263 264ohos_shared_library("libarkfile") { 265 stack_protector_ret = false 266 deps = [ ":libarkfile_static" ] 267 268 if (!is_standard_system) { 269 relative_install_dir = "ark" 270 } 271 if (!is_mingw && !is_mac) { 272 output_extension = "so" 273 } 274 275 part_name = "runtime_core" 276 subsystem_name = "arkcompiler" 277} 278 279ohos_source_set("libarkfile_frontend_set_static") { 280 sources = libarkfile_sources 281 282 public_configs = libarkfile_configs 283 284 deps = [ 285 ":arkfile_header_deps", 286 "$ark_root/libpandabase:libarkbase_frontend_static", 287 "$ark_root/libziparchive:libarkziparchive_frontend_static", 288 ] 289 290 if (is_arkui_x) { 291 deps += [ 292 "$ark_third_party_root/bounds_checking_function:libsec_static", 293 "$ark_third_party_root/zlib:libz", 294 ] 295 } else if (ark_standalone_build) { 296 external_deps = [ 297 "zlib:libz", 298 sdk_libc_secshared_dep, 299 ] 300 } else { 301 public_external_deps = [ 302 "zlib:libz", 303 sdk_libc_secshared_dep, 304 ] 305 } 306 307 part_name = "runtime_core" 308 subsystem_name = "arkcompiler" 309} 310 311ohos_static_library("libarkfile_frontend_static") { 312 stack_protector_ret = false 313 deps = [ ":libarkfile_frontend_set_static" ] 314 315 part_name = "runtime_core" 316 subsystem_name = "arkcompiler" 317} 318 319ark_gen_file("libarkfile_type_gen_h") { 320 template_file = "templates/type.h.erb" 321 data_file = "types.yaml" 322 requires = [ "types.rb" ] 323 output_file = "$target_gen_dir/type.h" 324} 325 326ark_isa_gen("isa_gen_libarkfile") { 327 template_files = [ 328 "arkcompiler.para.erb", 329 "bytecode_instruction_enum_gen.h.erb", 330 "bytecode_instruction-inl_gen.h.erb", 331 "bytecode_emitter_def_gen.h.erb", 332 "bytecode_emitter_gen.h.erb", 333 "file_format_version.h.erb", 334 "tests/bytecode_emitter_tests_gen.h.erb", 335 ] 336 sources = "templates" ## ark_root/templates 337 destination = "$target_gen_dir/include" ## target_gen_dir/include 338 requires = [ "pandafile_isapi.rb" ] 339} 340 341ark_gen_file("source_lang_enum_h") { 342 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 343 template_file = "templates/source_lang_enum.h.erb" 344 data_file = "$target_gen_dir/../plugin_options.yaml" 345 requires = [ "$ark_root/templates/plugin_options.rb" ] 346 output_file = "$target_gen_dir/include/source_lang_enum.h" 347} 348 349group("arkcompiler_params") { 350 deps = [] 351 352 if (!ark_standalone_build) { 353 deps += [ ":arkcompiler.para" ] 354 } 355} 356 357if (!ark_standalone_build) { 358 ohos_prebuilt_etc("arkcompiler.para") { 359 deps = [ ":isa_gen_libarkfile_arkcompiler_para" ] 360 source = "$target_gen_dir/include/arkcompiler.para" 361 relative_install_dir = "param" 362 part_name = "runtime_core" 363 subsystem_name = "arkcompiler" 364 } 365} 366