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