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 233source_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 external_deps = [] 248 external_deps += [ 249 "zlib:shared_libz", 250 sdk_libc_secshared_dep, 251 ] 252} 253 254ohos_shared_library("libarkfile") { 255 stack_protector_ret = false 256 deps = [ ":libarkfile_static" ] 257 258 if (!is_standard_system) { 259 relative_install_dir = "ark" 260 } 261 if (!is_mingw && !is_mac) { 262 output_extension = "so" 263 } 264 265 part_name = "runtime_core" 266 subsystem_name = "arkcompiler" 267} 268 269ohos_source_set("libarkfile_frontend_set_static") { 270 sources = libarkfile_sources 271 272 public_configs = libarkfile_configs 273 274 deps = [ 275 ":arkfile_header_deps", 276 "$ark_root/libpandabase:libarkbase_frontend_static", 277 "$ark_root/libziparchive:libarkziparchive_frontend_static", 278 ] 279 280 if (is_arkui_x) { 281 deps += [ 282 "$ark_third_party_root/bounds_checking_function:libsec_static", 283 "$ark_third_party_root/zlib:libz", 284 ] 285 } else if (ark_standalone_build) { 286 external_deps = [ 287 "zlib:libz", 288 sdk_libc_secshared_dep, 289 ] 290 } else { 291 public_external_deps = [ 292 "zlib:libz", 293 sdk_libc_secshared_dep, 294 ] 295 } 296 297 part_name = "runtime_core" 298 subsystem_name = "arkcompiler" 299} 300 301ohos_static_library("libarkfile_frontend_static") { 302 stack_protector_ret = false 303 deps = [ ":libarkfile_frontend_set_static" ] 304 305 part_name = "runtime_core" 306 subsystem_name = "arkcompiler" 307} 308 309ark_gen_file("libarkfile_type_gen_h") { 310 template_file = "templates/type.h.erb" 311 data_file = "types.yaml" 312 requires = [ "types.rb" ] 313 output_file = "$target_gen_dir/type.h" 314} 315 316ark_isa_gen("isa_gen_libarkfile") { 317 template_files = [ 318 "arkcompiler.para.erb", 319 "bytecode_instruction_enum_gen.h.erb", 320 "bytecode_instruction-inl_gen.h.erb", 321 "bytecode_emitter_def_gen.h.erb", 322 "bytecode_emitter_gen.h.erb", 323 "file_format_version.h.erb", 324 "tests/bytecode_emitter_tests_gen.h.erb", 325 ] 326 sources = "templates" ## ark_root/templates 327 destination = "$target_gen_dir/include" ## target_gen_dir/include 328 requires = [ "pandafile_isapi.rb" ] 329} 330 331ark_gen_file("source_lang_enum_h") { 332 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 333 template_file = "templates/source_lang_enum.h.erb" 334 data_file = "$target_gen_dir/../plugin_options.yaml" 335 requires = [ "$ark_root/templates/plugin_options.rb" ] 336 output_file = "$target_gen_dir/include/source_lang_enum.h" 337} 338 339group("arkcompiler_params") { 340 deps = [] 341 342 if (!ark_standalone_build) { 343 deps += [ ":arkcompiler.para" ] 344 } 345} 346 347if (!ark_standalone_build) { 348 ohos_prebuilt_etc("arkcompiler.para") { 349 deps = [ ":isa_gen_libarkfile_arkcompiler_para" ] 350 source = "$target_gen_dir/include/arkcompiler.para" 351 relative_install_dir = "param" 352 part_name = "runtime_core" 353 subsystem_name = "arkcompiler" 354 } 355} 356