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