1# Copyright (c) 2021-2025 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 16foreach(plugin, enabled_plugins) { 17 print("plugin $plugin is enabled") 18} 19 20group("arkcompiler_params") { 21 deps = [ "libpandafile:arkcompiler_params" ] 22} 23 24group("ark_device_packages") { 25 deps = [ "$ark_root/verifier:libarkverifier" ] 26} 27 28group("ark_packages") { 29 deps = [] 30 if (host_os != "mac") { 31 deps += [ 32 "$ark_root/libpandabase:libarkbase", 33 "$ark_root/libpandafile:libarkfile", 34 "$ark_root/libziparchive:libarkziparchive", 35 ] 36 } 37 38 foreach(plugin, enabled_plugins) { 39 deps += [ "$ark_root/plugins/$plugin:ark_packages" ] 40 } 41} 42 43group("ark_host_linux_tools_packages") { 44 deps = [] 45 if (host_os != "mac") { 46 deps += [ 47 "$ark_root/abc2program:abc2prog(${host_toolchain})", 48 "$ark_root/disassembler:ark_disasm(${host_toolchain})", 49 "$ark_root/libpandabase:libarkbase(${host_toolchain})", 50 "$ark_root/libpandafile:libarkfile(${host_toolchain})", 51 "$ark_root/libziparchive:libarkziparchive(${host_toolchain})", 52 "$ark_root/panda_guard:panda_guard(${host_toolchain})", 53 "$ark_root/verifier:ark_verifier(${host_toolchain})", 54 ] 55 } 56 foreach(plugin, enabled_plugins) { 57 deps += [ "$ark_root/plugins/$plugin:ark_host_linux_tools_packages" ] 58 } 59} 60 61group("ark_host_windows_tools_packages") { 62 deps = [] 63 if (host_os != "mac") { 64 deps += [ 65 "$ark_root/abc2program:abc2prog($build_root/toolchain/mingw:mingw_x86_64)", 66 "$ark_root/disassembler:ark_disasm($build_root/toolchain/mingw:mingw_x86_64)", 67 "$ark_root/panda_guard:panda_guard($build_root/toolchain/mingw:mingw_x86_64)", 68 "$ark_root/verifier:ark_verifier($build_root/toolchain/mingw:mingw_x86_64)", 69 ] 70 } 71 72 foreach(plugin, enabled_plugins) { 73 deps += [ "$ark_root/plugins/$plugin:ark_host_windows_tools_packages" ] 74 } 75} 76 77group("ark_host_mac_tools_packages") { 78 deps = [] 79 if (host_os == "mac") { 80 if (host_cpu == "arm64") { 81 deps += [ 82 "$ark_root/abc2program:abc2prog($build_root/toolchain/mac:clang_arm64)", 83 "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_arm64)", 84 "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_arm64)", 85 "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_arm64)", 86 "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_arm64)", 87 "$ark_root/panda_guard:panda_guard($build_root/toolchain/mac:clang_arm64)", 88 "$ark_root/verifier:ark_verifier($build_root/toolchain/mac:clang_arm64)", 89 ] 90 } else { 91 deps += [ 92 "$ark_root/abc2program:abc2prog($build_root/toolchain/mac:clang_x64)", 93 "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_x64)", 94 "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_x64)", 95 "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_x64)", 96 "$ark_root/libziparchive:libarkziparchive($build_root/toolchain/mac:clang_x64)", 97 "$ark_root/panda_guard:panda_guard($build_root/toolchain/mac:clang_x64)", 98 "$ark_root/verifier:ark_verifier($build_root/toolchain/mac:clang_x64)", 99 ] 100 } 101 } 102 103 foreach(plugin, enabled_plugins) { 104 deps += [ "$ark_root/plugins/$plugin:ark_host_mac_tools_packages" ] 105 } 106} 107 108if (!ark_standalone_build) { 109 group("ark_host_ohos_tools_packages") { 110 deps = [] 111 if (host_os != "mac") { 112 deps += [ "$ark_root/disassembler:ark_disasm($build_root/toolchain/ohos:ohos_clang_arm64)" ] 113 } 114 foreach(plugin, enabled_plugins) { 115 deps += [ "$ark_root/plugins/$plugin:ark_host_ohos_tools_packages" ] 116 } 117 } 118} 119 120# Common config for ark source 121config("ark_config") { 122 visibility = [ 123 "./*", 124 "//arkcompiler/ets_frontend/*", 125 ] 126 127 include_dirs = [ "$ark_root" ] 128 defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ] 129 130 if (is_linux) { 131 defines += [ 132 "PANDA_TARGET_UNIX", 133 "PANDA_TARGET_LINUX", 134 "PANDA_WITH_BYTECODE_OPTIMIZER", 135 "PANDA_WITH_COMPILER", 136 "PANDA_USE_FUTEX", 137 ] 138 } else if (is_mingw) { 139 defines += [ 140 "PANDA_TARGET_WINDOWS", 141 "PANDA_WITH_BYTECODE_OPTIMIZER", 142 "PANDA_WITH_COMPILER", 143 "_CRTBLD", 144 "__LIBMSVCRT__", 145 ] 146 } else if (is_mac) { 147 defines += [ 148 "PANDA_TARGET_UNIX", 149 "PANDA_TARGET_MACOS", 150 "PANDA_WITH_BYTECODE_OPTIMIZER", 151 "PANDA_WITH_COMPILER", 152 ] 153 } else if (target_os == "ios") { 154 defines += [ 155 "PANDA_TARGET_UNIX", 156 "PANDA_TARGET_IOS", 157 "PANDA_WITH_BYTECODE_OPTIMIZER", 158 "PANDA_WITH_COMPILER", 159 ] 160 } else if (is_mob) { 161 defines += [ 162 "PANDA_TARGET_OHOS", 163 "PANDA_TARGET_UNIX", 164 "PANDA_USE_FUTEX", 165 "PANDA_TARGET_MOBILE", 166 "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", 167 ] 168 } else if (is_ohos) { 169 if (is_build_sdk) { 170 defines += [ 171 "PANDA_TARGET_OHOS", 172 "PANDA_TARGET_UNIX", 173 "PANDA_WITH_BYTECODE_OPTIMIZER", 174 "PANDA_USE_FUTEX", 175 ] 176 } else { 177 defines += [ 178 "PANDA_TARGET_OHOS", 179 "PANDA_TARGET_UNIX", 180 "PANDA_USE_FUTEX", 181 ] 182 } 183 } else { 184 defines += [ 185 "PANDA_TARGET_UNIX", 186 "PANDA_USE_FUTEX", 187 ] 188 } 189 190 if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) { 191 defines += [ "PANDA_TARGET_ARKUI_X" ] 192 } 193 194 if (enable_hilog) { 195 defines += [ "ENABLE_HILOG" ] 196 } 197 198 if (!is_debug) { 199 defines += [ "NDEBUG" ] 200 } 201 202 cflags_cc = [ 203 "-std=c++17", 204 "-pedantic", 205 "-Wall", 206 "-Wextra", 207 "-Werror", 208 "-fno-rtti", 209 "-Wno-invalid-offsetof", 210 211 "-Wno-gnu-statement-expression", 212 "-Wno-unused-parameter", 213 "-Wno-unused-result", 214 "-Wno-unused-but-set-variable", 215 ] 216 if (defined(ohos_indep_compiler_enable) && !ohos_indep_compiler_enable) { 217 cflags_cc += [ "-fno-exceptions" ] 218 } 219 220 cflags_c = [] 221 222 if (!is_mac && use_pbqp) { 223 cflags_cc += [ 224 # PBQP regalloc 225 "-mllvm", 226 "-regalloc=pbqp", 227 ] 228 } 229 230 if (is_fastverify) { 231 cflags_cc += [ 232 "-O3", 233 "-ggdb3", 234 "-gdwarf-4", 235 "-fno-omit-frame-pointer", 236 "-D_GLIBCXX_ASSERTIONS", 237 ] 238 cflags_c += [ 239 "-O3", 240 "-ggdb3", 241 "-gdwarf-4", 242 "-fno-omit-frame-pointer", 243 "-D_GLIBCXX_ASSERTIONS", 244 ] 245 } else if (is_debug) { 246 cflags_cc += [ 247 "-Og", 248 "-ggdb3", 249 "-gdwarf-4", 250 ] 251 } 252 253 if (enable_relayout_profile) { 254 defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ] 255 } 256 257 configs = [] 258 foreach(plugin, enabled_plugins) { 259 configs += [ "$ark_root/plugins/$plugin:ark_config" ] 260 } 261 262 if (current_cpu == "arm") { 263 cflags_cc += [ 264 "-march=armv7-a", 265 "-mfloat-abi=${arm_float_abi}", 266 "-marm", 267 "-mfpu=vfp", 268 ] 269 270 if (arm_float_abi == "soft") { 271 defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] 272 } else if (arm_float_abi == "softfp") { 273 defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] 274 } else if (arm_float_abi == "hard") { 275 defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] 276 } 277 278 defines += [ "PANDA_TARGET_ARM32" ] 279 } else if (current_cpu == "arm64") { 280 defines += [ 281 "PANDA_TARGET_ARM64", 282 "PANDA_TARGET_64", 283 "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", 284 "PANDA_USE_32_BIT_POINTER", 285 ] 286 } else if (current_cpu == "x86") { 287 defines += [ "PANDA_TARGET_X86" ] 288 } else if (current_cpu == "amd64" || current_cpu == "x64" || 289 current_cpu == "x86_64") { 290 defines += [ 291 "PANDA_TARGET_64", 292 "PANDA_TARGET_AMD64", 293 "PANDA_USE_32_BIT_POINTER", 294 ] 295 } 296} 297 298plugins_yamls = [] 299foreach(plugin, enabled_plugins) { 300 plugin_dir = "$ark_root/plugins/$plugin" 301 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 302 303 if (defined(source_files.option_yaml_path)) { 304 plugins_yamls += [ "$plugin_dir/${source_files.option_yaml_path}" ] 305 } 306 307 source_files = { 308 } 309} 310 311concat_yamls("concat_plugins_yamls") { 312 output_file = "$target_gen_dir/plugin_options.yaml" 313 default_file = "$ark_root/templates/plugin_options.yaml" 314 add_yamls = plugins_yamls 315} 316 317inst_templates_yamls = [] 318foreach(plugin, enabled_plugins) { 319 plugin_dir = "$ark_root/plugins/$plugin" 320 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 321 if (defined(source_files.inst_templates_yaml_path)) { 322 inst_templates_yamls += 323 [ "$plugin_dir/${source_files.inst_templates_yaml_path}" ] 324 } 325 source_files = { 326 } 327} 328 329concat_yamls("concat_inst_templates_yamls") { 330 output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml" 331 default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml" 332 add_yamls = inst_templates_yamls 333} 334 335group("ark_host_defectscanaux_tools") { 336 deps = [] 337 if (host_os == "linux") { 338 deps += [ ":ark_host_linux_defectscanaux_unittest" ] 339 if (host_cpu != "arm64") { 340 deps += [ ":ark_host_win_defectscanaux_unittest" ] 341 } 342 } else if (host_os == "mac") { 343 deps += [ ":ark_host_mac_defectscanaux_unittest" ] 344 } 345} 346 347group("ark_host_linux_defectscanaux_unittest") { 348 deps = [] 349 if (host_os == "linux") { 350 deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo(${host_toolchain})" ] 351 } 352} 353 354group("ark_host_win_defectscanaux_unittest") { 355 deps = [] 356 if (host_os == "linux") { 357 deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mingw:mingw_x86_64)" ] 358 } 359} 360 361group("ark_host_mac_defectscanaux_unittest") { 362 deps = [] 363 if (host_os == "mac") { 364 if (host_cpu == "arm64") { 365 deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mac:clang_arm64)" ] 366 } else { 367 deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo($build_root/toolchain/mac:clang_x64)" ] 368 } 369 } 370} 371 372group("runtime_core_host_unittest") { 373 testonly = true 374 deps = [ 375 "$ark_root/abc2program/tests:host_unittest", 376 "$ark_root/arkplatform/tests:host_unittest", 377 "$ark_root/assembler/tests:host_unittest", 378 "$ark_root/bytecode_optimizer/tests:host_unittest", 379 "$ark_root/compiler/tests:host_unittest", 380 "$ark_root/disassembler/tests:host_unittest", 381 "$ark_root/libark_defect_scan_aux/tests/unittest:host_unittest", 382 "$ark_root/libpandafile/tests:host_unittest", 383 "$ark_root/libziparchive/tests:host_unittest", 384 "$ark_root/platforms/tests:host_unittest", 385 "$ark_root/verifier/tests:host_unittest", 386 ] 387 if (!ark_standalone_build) { 388 deps += [ 389 "$ark_root/libpandabase/tests:host_unittest", 390 "$ark_root/panda_guard/tests:host_unittest", 391 ] 392 } 393} 394 395if (!ark_standalone_build) { 396 group("runtime_core_unittest") { 397 testonly = true 398 deps = [ 399 "$ark_root/arkplatform/tests:unittest", 400 "$ark_root/libpandabase/tests:unittest", 401 "$ark_root/libpandafile/tests:unittest", 402 "$ark_root/libziparchive/tests:unittest", 403 ] 404 } 405 406 group("verifier_host_unittest") { 407 testonly = true 408 deps = [ "$ark_root/verifier/tests:host_unittest" ] 409 } 410 411 group("compiler_host_unittest") { 412 testonly = true 413 deps = [ "$ark_root/compiler/tests:host_unittest" ] 414 } 415 416 group("arkplatform_host_unittest") { 417 testonly = true 418 deps = [ "$ark_root/arkplatform/tests:host_unittest" ] 419 } 420 421 group("arkplatform_unittest") { 422 testonly = true 423 deps = [ "$ark_root/arkplatform/tests:unittest" ] 424 } 425} 426