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