1# Copyright (c) 2024 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 14if (!defined(ark_standalone_build)) { 15 ark_standalone_build = false 16} 17 18if (!defined(ark_hybrid)) { 19 ark_hybrid = false 20} 21 22declare_args() { 23 # If true, use icu to implement Intl APIs. 24 # If false, use @ohos.intl APIs to implement Intl APIs. 25 enable_ark_intl = true 26 run_regress_test = false 27 28 # If true, enable fuzz option. Default false. 29 enable_fuzz_option = false 30 run_with_asan = false 31 32 # Enable pgo for building. 33 ets_runtime_feature_enable_pgo = false 34 35 # Enable pgo for building. 36 ets_runtime_feature_enable_codemerge = false 37 38 # Set pgo profdata path. 39 ets_runtime_feature_pgo_path = "" 40 41 # Enable -Bsymbolic to reduce overhead of intra-library calls. 42 ets_runtime_feature_enable_bsymbolic = true 43 44 # Defaults for fort 45 ets_runtime_support_jit_code_sign = false 46 enable_jit_code_sign = false 47 disable_fort_switch = false 48 49 enable_litecg_emit = true 50 51 is_qemu_runtime = false 52 53 disable_hilog = false 54 55 TARGET = "x86_64" 56 HOST_ARCH = 64 57 58 if (!defined(timeout)) { 59 timeout = 2400 60 } 61 62 # Turn off next optimization features if set to false 63 enable_next_optimization = true 64 65 # If true app_aot_jit_enable_list will be placed in /etc/ark 66 # Default false. 67 ets_runtime_feature_enable_list = false 68 enable_gc_dfx_options = false 69 70 # NOTE(ipetrov): Need to enable for mac previewer 71 ark_js_hybrid = !ark_standalone_build && !is_mac 72 73 ets_runtime_enable_cmc_gc = false 74 75 enable_handle_leak_detect = false 76} 77 78if (defined(enable_cmc_gc)) { 79 ets_runtime_enable_cmc_gc = enable_cmc_gc 80} 81 82if (target_cpu == "arm64") { 83 TARGET = "aarch64" 84} 85MAPLEALL_ROOT = "//arkcompiler/ets_runtime/ecmascript/compiler/codegen/maple" 86MAPLEALL_THIRD_PARTY_ROOT = "//third_party" 87LLVM_LIB_ROOT = "//arkcompiler/ets_runtime/ecmascript/compiler/codegen/llvm/lib" 88 89if (!ark_standalone_build) { 90 build_root = "//build" 91 ark_third_party_root = "//third_party" 92 import("$build_root/config/components/toolchain/build_type.gni") 93 import("$build_root/ohos.gni") 94} else { 95 ark_third_party_root = "//build/third_party_gn" 96 import("$build_root/ark.gni") 97 import("$build_root/config/build_type.gni") 98} 99if (!defined(build_variant)) { 100 build_variant = "root" 101} 102import("$build_root/config/sanitizers/sanitizers.gni") 103ark_root = "//arkcompiler/runtime_core" 104arkplatform_root = "//arkcompiler/runtime_core/arkplatform" 105js_root = "//arkcompiler/ets_runtime" 106global_root = "//base/global/i18n" 107hilog_root = "//base/hiviewdfx/hilog/interfaces/native/innerkits" 108qos_root = "//foundation/resourceschedule/qos_manager" 109compile_llvm_online = false 110if (enable_fuzz_option) { 111 run_with_asan = true 112} 113enable_cow_array = true 114enable_coverage = false 115enable_asm_assert = false 116ark_compile_mode = "debug" 117if (defined(is_arkui_x) && is_arkui_x && defined(runtime_mode) && 118 runtime_mode == "release") { 119 ark_compile_mode = "release" 120} 121 122asan_lib_path = "/usr/lib/llvm-10/lib/clang/10.0.0/lib/linux" 123 124# under /system/lib64 dir 125if (is_asan) { 126 arkcompiler_lib64_path = "/system/asan/lib64" 127} else { 128 arkcompiler_lib64_path = "/system/lib64" 129} 130arkcompiler_relative_lib_path = "module/arkcompiler" 131if (is_standard_system || ark_standalone_build) { 132 icu_part_name = "icu" 133 icu_subsystem_name = "thirdparty" 134} else { 135 icu_part_name = "i18n" 136 icu_subsystem_name = "global" 137} 138 139if (defined(is_arkui_x) && is_arkui_x && target_os == "ios") { 140 sdk_libc_secshared_dep = 141 "$ark_third_party_root/bounds_checking_function:libsec_static" 142} else { 143 sdk_libc_secshared_dep = "bounds_checking_function:libsec_shared" 144} 145sdk_libc_secshared_config = 146 "$ark_third_party_root/bounds_checking_function:libsec_public_config" 147 148# ohos device, windows previewer, mac previewer 149enable_hilog = 150 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && 151 (is_ohos || is_mingw || is_mac) && !is_qemu_runtime && !disable_hilog 152enable_hisysevent = 153 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 154 is_standard_system && !is_qemu_runtime 155enable_dump_in_faultlog = 156 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 157 is_standard_system && !is_qemu_runtime 158enable_bytrace = 159 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 160 is_standard_system && !is_qemu_runtime 161enable_hitrace = 162 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 163 is_standard_system && !is_qemu_runtime 164enable_unwinder = 165 !ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 166 is_standard_system && !is_qemu_runtime 167 168hiviewdfx_deps = [] 169hiviewdfx_ext_deps = [] 170if (enable_dump_in_faultlog) { 171 hiviewdfx_ext_deps += [ 172 "faultloggerd:libfaultloggerd", 173 "init:libbegetutil", 174 ] 175} 176if (enable_unwinder) { 177 hiviewdfx_ext_deps += [ "faultloggerd:libunwinder" ] 178} 179if (enable_bytrace) { 180 hiviewdfx_ext_deps += [ "hitrace:hitrace_meter" ] 181} 182if (enable_hitrace) { 183 hiviewdfx_ext_deps += [ "hitrace:libhitracechain" ] 184} 185if (enable_hilog) { 186 hiviewdfx_ext_deps += [ "hilog:libhilog" ] 187} 188if (enable_hisysevent) { 189 hiviewdfx_ext_deps += [ 190 "hisysevent:libhisysevent", 191 "hiview:libucollection_client", 192 "faultloggerd:dfx_signalhandler", 193 ] 194} 195if (is_ohos && is_standard_system && !is_arkui_x && !is_qemu_runtime && 196 defined(global_parts_info) && 197 defined(global_parts_info.resourceschedule_qos_manager)) { 198 hiviewdfx_ext_deps += [ "qos_manager:qos" ] 199} 200 201enable_sanitize = is_ohos && is_standard_system && !ark_standalone_build && 202 current_toolchain != host_toolchain 203 204enable_target_compilation = 205 !ark_standalone_build && !is_mac && !(defined(is_arkui_x) && is_arkui_x) && 206 (current_cpu == "arm64" && host_cpu != "arm64") 207 208have_local_code_sign = false 209if (defined(global_parts_info) && 210 defined(global_parts_info.security_code_signature) && 211 global_parts_info.security_code_signature) { 212 have_local_code_sign = true 213} 214enable_local_code_sign = false 215if (have_local_code_sign && enable_target_compilation) { 216 enable_local_code_sign = true 217} 218if (!ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && is_ohos && 219 is_standard_system && target_cpu == "arm64" && !is_emulator && 220 defined(global_parts_info) && 221 defined(global_parts_info.security_code_signature)) { 222 enable_jit_code_sign = ets_runtime_support_jit_code_sign 223} 224ets_runtime_output_path = "ets_runtime/ets_runtime" 225 226template("libark_jsruntime_common_set") { 227 forward_variables_from(invoker, "*") 228 229 ohos_source_set(target_name) { 230 if (target_name == "libark_jsruntime_arm_set" && is_ohos && 231 is_standard_system && !is_arkui_x && target_cpu == "arm64") { 232 include_dirs = [ 233 "$js_root", 234 "$js_root/ecmascript/napi/include", 235 ] 236 } 237 238 stack_protector_ret = false 239 240 if (is_ohos && is_standard_system) { 241 stub_an_file_path = 242 "${arkcompiler_lib64_path}/${arkcompiler_relative_lib_path}/stub.an" 243 } else { 244 stub_an_file_path = 245 rebase_path("$root_gen_dir/arkcompiler/ets_runtime/stub.an") 246 } 247 defines = [ "STUB_AN_FILE=\"${stub_an_file_path}\"" ] 248 249 if (current_cpu == "arm64") { 250 defines += [ "ENABLE_POSTFORK_FORCEEXPAND" ] 251 } 252 253 sources = invoker.ecma_source 254 sources += invoker.ecma_profiler_source 255 sources += invoker.ecma_debugger_source 256 sources += invoker.hitrace_scope_source 257 sources += invoker.ecma_platform_source 258 259 if (is_ohos) { 260 sources += invoker.ecma_stackinfo_source 261 } 262 263 public_configs = [ "$js_root:ark_jsruntime_public_config" ] 264 public_configs += [ ":include_llvm" ] 265 266 configs = [ 267 "$js_root:ark_jsruntime_common_config", 268 "$js_root:asm_interp_enable_config", 269 ] 270 271 cflags_cc = [] 272 if (is_standard_system || target_os == "android" || target_os == "ios") { 273 cflags_cc += [ "-fvisibility=hidden" ] 274 } 275 276 external_deps = [ "libuv:uv" ] 277 if (target_name == "libark_jsruntime_arm_set" && is_ohos && 278 is_standard_system && !is_arkui_x) { 279 defines += [ "ENABLE_FFRT_INTERFACES" ] 280 external_deps += [ 281 "ffrt:libffrt", 282 "hilog:libhilog", 283 ] 284 } 285 deps = [] 286 if (!is_arkui_x) { 287 external_deps += [ "runtime_core:arkfile_header_deps" ] 288 } else { 289 deps += [ "$ark_root/libpandafile:arkfile_header_deps" ] 290 } 291 292 if (!ark_standalone_build && !(defined(is_arkui_x) && is_arkui_x) && 293 is_ohos && is_standard_system) { 294 external_deps += [ "init:libbegetutil" ] 295 defines += [ 296 "GET_PARAMETER_FOR_JIT", 297 "JIT_ESCAPE_ENABLE", 298 "AOT_ESCAPE_ENABLE", 299 "OHOS_GET_PARAMETER", 300 ] 301 } 302 303 if (ark_standalone_build) { 304 defines += [ "STANDALONE_MODE" ] 305 } 306 307 include_dirs = [] 308 if (enable_jit_code_sign) { 309 defines += [ "JIT_ENABLE_CODE_SIGN" ] 310 external_deps += [ "code_signature:libjit_code_sign" ] 311 if (disable_fort_switch) { 312 defines += [ "JIT_FORT_DISABLE" ] 313 } 314 } 315 316 if (enable_target_compilation) { 317 external_deps += [ "c_utils:utils" ] 318 } 319 320 # hiviewdfx libraries 321 external_deps += hiviewdfx_ext_deps 322 deps += hiviewdfx_deps 323 324 if (ark_standalone_build || is_arkui_x) { 325 deps += [ "$ark_third_party_root/zlib:libz" ] 326 } else { 327 external_deps += [ "zlib:shared_libz" ] 328 } 329 330 # gc dfx options 331 if (enable_gc_dfx_options) { 332 defines += [ "ECMASCRIPT_ENABLE_GC_DFX_OPTIONS" ] 333 } 334 if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { 335 external_deps += [ 336 "icu:shared_icuuc", 337 sdk_libc_secshared_dep, 338 ] 339 } 340 part_name = "ets_runtime" 341 subsystem_name = "arkcompiler" 342 } 343} 344 345template("libark_jsruntime_intl_common_set") { 346 forward_variables_from(invoker, "*") 347 348 ohos_source_set(target_name) { 349 stack_protector_ret = false 350 sources = invoker.intl_sources 351 352 public_configs = [ "$js_root:ark_jsruntime_public_config" ] 353 354 configs = [ "$js_root:ark_jsruntime_common_config" ] 355 356 cflags_cc = [] 357 if (is_standard_system || target_os == "android" || target_os == "ios") { 358 cflags_cc += [ "-fvisibility=hidden" ] 359 } 360 361 external_deps = [] 362 deps = [] 363 if (!is_arkui_x) { 364 external_deps += [ "runtime_core:arkfile_header_deps" ] 365 } else { 366 deps += [ "$ark_root/libpandafile:arkfile_header_deps" ] 367 } 368 369 # hiviewdfx libraries 370 external_deps += hiviewdfx_ext_deps 371 deps += hiviewdfx_deps 372 if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { 373 external_deps += [ 374 "icu:shared_icuuc", 375 sdk_libc_secshared_dep, 376 ] 377 } 378 part_name = "ets_runtime" 379 subsystem_name = "arkcompiler" 380 } 381} 382