1# Copyright (c) 2021-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 14import("//arkcompiler/runtime_core/static_core/ark_config.gni") 15import("//arkcompiler/runtime_core/static_vm_config.gni") 16import("//build/ohos.gni") 17import("$ark_root/plugins/plugins.gni") 18 19group("ark_packages") { 20 if (enable_static_vm) { 21 deps = plugin_ark_packages 22 if (host_os != "mac") { 23 deps += [ 24 "$ark_root/compiler:libarktscompiler", 25 "$ark_root/compiler/aot:libarkaotmanager", 26 "$ark_root/compiler/tools/paoc:ark_aot", 27 "$ark_root/libpandabase:libarktsbase", 28 "$ark_root/libpandafile:libarktsfile", 29 "$ark_root/libpandafile/external:libarkfileExt", 30 "$ark_root/libpandafile/external:libarksupport", 31 "$ark_root/libziparchive:libarktsziparchive", 32 "$ark_root/panda:arkts_bin", 33 "$ark_root/runtime:libarkruntime", 34 "$ark_root/runtime/tooling/inspector:libarkinspector", 35 "$ark_root/verification/verifier:verifier.config", 36 "$ark_root/verification/verifier:verifier_bin", 37 ] 38 if (enable_codegen) { 39 deps += [ "$ark_root/compiler/optimizer/code_generator:libarkencoder" ] 40 } 41 } 42 } 43} 44 45group("ark_host_linux_tools_packages") { 46 deps = plugin_ark_host_linux_tools_packages 47 if (host_os != "mac" && current_cpu != "arm") { 48 deps += [ 49 "$ark_root/assembler:arkts_asm(${host_toolchain})", 50 "$ark_root/compiler:libarktscompiler(${host_toolchain})", 51 "$ark_root/compiler/aot:libarkaotmanager(${host_toolchain})", 52 "$ark_root/libpandabase:libarktsbase(${host_toolchain})", 53 "$ark_root/libpandafile:libarktsfile(${host_toolchain})", 54 "$ark_root/libpandafile/external:libarkfileExt(${host_toolchain})", 55 "$ark_root/libpandafile/external:libarksupport(${host_toolchain})", 56 "$ark_root/libziparchive:libarktsziparchive(${host_toolchain})", 57 "$ark_root/panda:arkts_bin(${host_toolchain})", 58 "$ark_root/runtime:libarkruntime(${host_toolchain})", 59 ] 60 if (enable_codegen) { 61 deps += [ "$ark_root/compiler/optimizer/code_generator:libarkencoder(${host_toolchain})" ] 62 } 63 64 # TODO: don't exclude these targets from OHOS build 65 if (ark_standalone_build) { 66 deps += [ 67 "$ark_root/compiler/tools/aotdump:ark_aotdump(${host_toolchain})", 68 "$ark_root/compiler/tools/paoc:ark_aot(${host_toolchain})", 69 "$ark_root/disassembler:arkts_disasm(${host_toolchain})", 70 "$ark_root/static_linker:ark_link(${host_toolchain})", 71 ] 72 } 73 } 74} 75 76group("ark_host_windows_tools_packages") { 77 deps = plugin_ark_host_windows_tools_packages 78 if (host_os != "mac" && current_cpu != "arm" && !ark_standalone_build) { 79 deps += [ 80 "$ark_root/assembler:arkts_asm(//build/toolchain/mingw:mingw_x86_64)", 81 "$ark_root/disassembler:arkts_disasm(//build/toolchain/mingw:mingw_x86_64)", 82 "$ark_root/static_linker:ark_link(//build/toolchain/mingw:mingw_x86_64)", 83 ] 84 } 85} 86 87group("ark_host_mac_tools_packages") { 88 deps = plugin_ark_host_mac_tools_packages 89 if (host_os == "mac") { 90 deps += [ 91 "$ark_root/assembler:arkts_asm(//build/toolchain/mac:clang_x64)", 92 "$ark_root/disassembler:arkts_disasm(//build/toolchain/mac:clang_x64)", 93 "$ark_root/libpandabase:libarktsbase(//build/toolchain/mac:clang_x64)", 94 "$ark_root/libpandafile:libarktsfile(//build/toolchain/mac:clang_x64)", 95 "$ark_root/libziparchive:libarktsziparchive(//build/toolchain/mac:clang_x64)", 96 "$ark_root/static_linker:ark_link(//build/toolchain/mac:clang_x64)", 97 ] 98 } 99} 100 101group("ark_host_tests") { 102 testonly = true 103 deps = [] 104 if (defined(extras)) { 105 foreach(ext, extras) { 106 deps += [ "${ext}:host_tests" ] 107 } 108 } 109} 110 111# Common config for ark source 112config("ark_config") { 113 if (!ark_standalone_build) { 114 visibility = [ 115 "$ark_es2panda_root:libes2panda", 116 "$ark_es2panda_root:libes2panda_frontend_static", 117 "$ark_es2panda_root:libes2panda_public", 118 "$ark_es2panda_root:libes2panda_public_frontend_static", 119 "$ark_es2panda_root/aot:ets2panda", 120 "$ark_third_party_root/asmjit:*", 121 "$ark_third_party_root/vixl:*", 122 "./*", 123 ] 124 } 125 126 include_dirs = [ 127 "$ark_root", 128 get_label_info(":create_pipeline(${default_toolchain})", "target_gen_dir"), 129 ] 130 defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ] 131 if (enable_codegen) { 132 defines += [ "PANDA_COMPILER_ENABLE" ] 133 } 134 if (is_emulator) { 135 defines += [ "PANDA_TARGET_EMULATOR" ] 136 } 137 138 if (is_llvm_interpreter || is_llvm_fastpath) { 139 defines += [ "PANDA_LLVM_IRTOC" ] 140 if (is_llvm_interpreter) { 141 defines += [ "PANDA_LLVM_INTERPRETER" ] 142 } 143 if (is_llvm_fastpath) { 144 defines += [ "PANDA_LLVM_FASTPATH" ] 145 } 146 } 147 if (is_llvm_aot) { 148 defines += [ "PANDA_LLVM_AOT" ] 149 } 150 151 if (is_ohos && is_standard_system) { 152 defines += [ "PANDA_TARGET_OHOS" ] 153 include_dirs += [ "$hilog_root/include" ] 154 } 155 156 if (is_linux) { 157 defines += [ 158 "PANDA_TARGET_UNIX", 159 "PANDA_TARGET_LINUX", 160 "PANDA_WITH_BYTECODE_OPTIMIZER", 161 "PANDA_WITH_COMPILER", 162 ] 163 if (enable_irtoc) { 164 defines += [ "PANDA_WITH_IRTOC" ] 165 } 166 if (enable_codegen) { 167 defines += [ "PANDA_WITH_CODEGEN" ] 168 } 169 if (!is_asan) { 170 defines += [ "PANDA_USE_FUTEX" ] 171 } 172 } else if (is_mingw) { 173 defines += [ 174 "PANDA_TARGET_WINDOWS", 175 "PANDA_WITH_BYTECODE_OPTIMIZER", 176 "PANDA_WITH_COMPILER", 177 "_CRTBLD", 178 "__LIBMSVCRT__", 179 ] 180 if (enable_irtoc) { 181 defines += [ "PANDA_WITH_IRTOC" ] 182 } 183 if (enable_codegen) { 184 defines += [ "PANDA_WITH_CODEGEN" ] 185 } 186 } else if (is_mac) { 187 defines += [ 188 "PANDA_TARGET_UNIX", 189 "PANDA_TARGET_MACOS", 190 "PANDA_WITH_BYTECODE_OPTIMIZER", 191 "PANDA_WITH_COMPILER", 192 193 # "PANDA_USE_FUTEX", 194 ] 195 if (enable_irtoc) { 196 defines += [ "PANDA_WITH_IRTOC" ] 197 } 198 if (enable_codegen) { 199 defines += [ "PANDA_WITH_CODEGEN" ] 200 } 201 } else if (is_mob) { 202 defines += [ 203 "PANDA_TARGET_UNIX", 204 "PANDA_USE_FUTEX", 205 "PANDA_TARGET_MOBILE", 206 "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", 207 ] 208 } else if (is_ohos) { 209 defines += [ 210 # TODO: use PANDA_TARGET_OHOS instead of PANDA_TARGET_UNIX 211 "PANDA_TARGET_UNIX", 212 "PANDA_WITH_COMPILER", 213 ] 214 if (!is_asan) { 215 defines += [ "PANDA_USE_FUTEX" ] 216 } 217 if (enable_irtoc) { 218 defines += [ "PANDA_WITH_IRTOC" ] 219 } 220 if (enable_codegen) { 221 defines += [ "PANDA_WITH_CODEGEN" ] 222 } 223 } else { 224 defines += [ 225 "PANDA_TARGET_UNIX", 226 "PANDA_USE_FUTEX", 227 ] 228 } 229 230 if (!is_debug) { 231 defines += [ "NDEBUG" ] 232 } 233 234 cflags_cc = [ 235 "-std=c++17", 236 "-pedantic", 237 "-Wall", 238 "-Wextra", 239 "-Werror", 240 "-fno-rtti", 241 "-fno-exceptions", 242 "-Wno-invalid-offsetof", 243 244 "-Wno-gnu-statement-expression", 245 "-Wno-unused-parameter", 246 "-Wno-unused-result", 247 ] 248 249 cflags_c = [] 250 251 if (ark_standalone_build) { 252 cflags_cc += [ "-Wno-bitwise-instead-of-logical" ] 253 } 254 255 if (!is_mac && use_pbqp) { 256 cflags_cc += [ 257 # PBQP regalloc 258 "-mllvm", 259 "-regalloc=pbqp", 260 ] 261 } 262 263 if (is_fastverify) { 264 cflags_cc += [ 265 "-O3", 266 "-ggdb3", 267 "-fno-omit-frame-pointer", 268 "-D_GLIBCXX_ASSERTIONS", 269 ] 270 cflags_c += [ 271 "-O3", 272 "-ggdb3", 273 "-fno-omit-frame-pointer", 274 "-D_GLIBCXX_ASSERTIONS", 275 ] 276 } else if (is_debug) { 277 cflags_cc += [ 278 "-Og", 279 "-ggdb3", 280 "-gdwarf-4", 281 ] 282 } 283 284 if (is_asan) { 285 cflags_cc += [ "-g" ] 286 defines += [ "__SANITIZE_ADDRESS__" ] 287 print("ASAN is enabled") 288 } 289 290 if (enable_relayout_profile) { 291 defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ] 292 } 293 294 configs = plugin_ark_configs 295 296 if (ark_standalone_build) { 297 configs += [ sdk_libc_secshared_config ] 298 } 299 300 if (current_cpu == "arm") { 301 cflags_cc += [ 302 "-march=armv7-a", 303 "-mfloat-abi=${arm_float_abi}", 304 "-marm", 305 "-mfpu=vfp", 306 ] 307 308 if (arm_float_abi == "soft") { 309 defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] 310 } else if (arm_float_abi == "softfp") { 311 defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] 312 } else if (arm_float_abi == "hard") { 313 defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] 314 } 315 316 defines += [ 317 "PANDA_TARGET_32", 318 "PANDA_TARGET_ARM32", 319 ] 320 } else if (current_cpu == "arm64") { 321 defines += [ 322 "PANDA_TARGET_ARM64", 323 "PANDA_TARGET_64", 324 "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", 325 "PANDA_USE_32_BIT_POINTER", 326 ] 327 } else if (current_cpu == "x86") { 328 defines += [ "PANDA_TARGET_X86" ] 329 } else if (current_cpu == "amd64" || current_cpu == "x64" || 330 current_cpu == "x86_64") { 331 defines += [ 332 "PANDA_TARGET_64", 333 "PANDA_TARGET_AMD64", 334 "PANDA_USE_32_BIT_POINTER", 335 ] 336 } 337} 338 339concat_yamls("concat_plugins_yamls") { 340 output_file = ark_plugin_options_yaml 341 default_file = "$ark_root/templates/plugin_options.yaml" 342 add_yamls = plugin_option_yamls 343} 344 345concat_yamls("concat_entrypoints_yamls") { 346 output_file = "$target_gen_dir/runtime/entrypoints.yaml" 347 default_file = "$ark_root/runtime/entrypoints/entrypoints.yaml" 348 add_yamls = plugin_entrypoints_yamls 349} 350 351concat_yamls("concat_inst_templates_yamls") { 352 output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml" 353 default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml" 354 add_yamls = plugin_inst_templates_yamls 355} 356 357merge_yamls("merge_runtime_options_yamls") { 358 output_file = "$target_gen_dir/runtime_options.yaml" 359 add_yamls = 360 [ "$ark_root/runtime/options.yaml" ] + plugin_runtime_options_yamls 361} 362 363merge_yamls("merge_compiler_options_yamls") { 364 output_file = "$target_gen_dir/compiler/generated/compiler_options.yaml" 365 add_yamls = 366 [ "$ark_root/compiler/compiler.yaml" ] + plugin_compiler_options_yamls 367} 368