1# Copyright (c) 2021-2022 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 = [ 26 "$ark_root/verifier:ark_verifier", 27 "$ark_root/verifier:libarkverifier", 28 ] 29} 30 31group("ark_packages") { 32 deps = [] 33 if (host_os != "mac") { 34 deps += [ 35 "$ark_root/libpandabase:libarkbase", 36 "$ark_root/libpandafile:libarkfile", 37 "$ark_root/libziparchive:libarkziparchive", 38 ] 39 } 40 41 foreach(plugin, enabled_plugins) { 42 deps += [ "$ark_root/plugins/$plugin:ark_packages" ] 43 } 44} 45 46group("ark_host_linux_tools_packages") { 47 deps = [] 48 if (host_os != "mac") { 49 deps += [ 50 "$ark_root/assembler:ark_asm(${host_toolchain})", 51 "$ark_root/disassembler:ark_disasm(${host_toolchain})", 52 "$ark_root/libpandabase:libarkbase(${host_toolchain})", 53 "$ark_root/libpandafile:libarkfile(${host_toolchain})", 54 "$ark_root/libziparchive:libarkziparchive(${host_toolchain})", 55 "$ark_root/verifier:ark_verifier(${host_toolchain})", 56 ] 57 } 58 foreach(plugin, enabled_plugins) { 59 deps += [ "$ark_root/plugins/$plugin:ark_host_linux_tools_packages" ] 60 } 61} 62 63group("ark_host_windows_tools_packages") { 64 deps = [] 65 if (host_os != "mac") { 66 deps += [ 67 "$ark_root/assembler:ark_asm($build_root/toolchain/mingw:mingw_x86_64)", 68 "$ark_root/disassembler:ark_disasm($build_root/toolchain/mingw:mingw_x86_64)", 69 "$ark_root/verifier:ark_verifier($build_root/toolchain/mingw:mingw_x86_64)", 70 ] 71 } 72 73 foreach(plugin, enabled_plugins) { 74 deps += [ "$ark_root/plugins/$plugin:ark_host_windows_tools_packages" ] 75 } 76} 77 78group("ark_host_mac_tools_packages") { 79 deps = [] 80 if (host_os == "mac") { 81 if (host_cpu == "arm64") { 82 deps += [ 83 "$ark_root/assembler:ark_asm($build_root/toolchain/mac:clang_arm64)", 84 "$ark_root/disassembler:ark_disasm($build_root/toolchain/mac:clang_arm64)", 85 "$ark_root/libpandabase:libarkbase($build_root/toolchain/mac:clang_arm64)", 86 "$ark_root/libpandafile:libarkfile($build_root/toolchain/mac:clang_arm64)", 87 "$ark_root/libziparchive:libarkziparchive($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/assembler:ark_asm($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/verifier:ark_verifier($build_root/toolchain/mac:clang_x64)", 98 ] 99 } 100 } 101 102 foreach(plugin, enabled_plugins) { 103 deps += [ "$ark_root/plugins/$plugin:ark_host_mac_tools_packages" ] 104 } 105} 106 107# Common config for ark source 108config("ark_config") { 109 visibility = [ 110 "./*", 111 "//arkcompiler/ets_frontend/*", 112 ] 113 114 include_dirs = [ "$ark_root" ] 115 defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ] 116 117 if (is_linux) { 118 defines += [ 119 "PANDA_TARGET_UNIX", 120 "PANDA_TARGET_LINUX", 121 "PANDA_WITH_BYTECODE_OPTIMIZER", 122 "PANDA_WITH_COMPILER", 123 "PANDA_USE_FUTEX", 124 ] 125 } else if (is_mingw) { 126 defines += [ 127 "PANDA_TARGET_WINDOWS", 128 "PANDA_WITH_BYTECODE_OPTIMIZER", 129 "PANDA_WITH_COMPILER", 130 "_CRTBLD", 131 "__LIBMSVCRT__", 132 ] 133 } else if (is_mac) { 134 defines += [ 135 "PANDA_TARGET_UNIX", 136 "PANDA_TARGET_MACOS", 137 "PANDA_WITH_BYTECODE_OPTIMIZER", 138 "PANDA_WITH_COMPILER", 139 ] 140 } else if (target_os == "ios") { 141 defines += [ 142 "PANDA_TARGET_UNIX", 143 "PANDA_TARGET_IOS", 144 "PANDA_WITH_BYTECODE_OPTIMIZER", 145 "PANDA_WITH_COMPILER", 146 ] 147 } else if (is_mob) { 148 defines += [ 149 "PANDA_TARGET_UNIX", 150 "PANDA_USE_FUTEX", 151 "PANDA_TARGET_MOBILE", 152 "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", 153 ] 154 } else { 155 defines += [ 156 "PANDA_TARGET_UNIX", 157 "PANDA_USE_FUTEX", 158 ] 159 } 160 161 if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) { 162 defines += [ "PANDA_TARGET_ARKUI_X" ] 163 } 164 165 if (enable_hilog) { 166 defines += [ "ENABLE_HILOG" ] 167 } 168 169 if (!is_debug) { 170 defines += [ "NDEBUG" ] 171 } 172 173 cflags_cc = [ 174 "-std=c++17", 175 "-pedantic", 176 "-Wall", 177 "-Wextra", 178 "-Werror", 179 "-fno-rtti", 180 "-fno-exceptions", 181 "-Wno-invalid-offsetof", 182 183 "-Wno-gnu-statement-expression", 184 "-Wno-unused-parameter", 185 "-Wno-unused-result", 186 "-Wno-unused-but-set-variable", 187 ] 188 189 if (!is_mac && use_pbqp) { 190 cflags_cc += [ 191 # PBQP regalloc 192 "-mllvm", 193 "-regalloc=pbqp", 194 ] 195 } 196 197 if (is_debug) { 198 cflags_cc += [ 199 "-Og", 200 "-ggdb3", 201 ] 202 } 203 204 if (enable_relayout_profile) { 205 defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ] 206 } 207 208 configs = [] 209 foreach(plugin, enabled_plugins) { 210 configs += [ "$ark_root/plugins/$plugin:ark_config" ] 211 } 212 213 if (current_cpu == "arm") { 214 cflags_cc += [ 215 "-march=armv7-a", 216 "-mfloat-abi=${arm_float_abi}", 217 "-marm", 218 "-mfpu=vfp", 219 ] 220 221 if (arm_float_abi == "soft") { 222 defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] 223 } else if (arm_float_abi == "softfp") { 224 defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] 225 } else if (arm_float_abi == "hard") { 226 defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] 227 } 228 229 defines += [ "PANDA_TARGET_ARM32" ] 230 } else if (current_cpu == "arm64") { 231 defines += [ 232 "PANDA_TARGET_ARM64", 233 "PANDA_TARGET_64", 234 "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", 235 "PANDA_USE_32_BIT_POINTER", 236 ] 237 } else if (current_cpu == "x86") { 238 defines += [ "PANDA_TARGET_X86" ] 239 } else if (current_cpu == "amd64" || current_cpu == "x64" || 240 current_cpu == "x86_64") { 241 defines += [ 242 "PANDA_TARGET_64", 243 "PANDA_TARGET_AMD64", 244 "PANDA_USE_32_BIT_POINTER", 245 ] 246 } 247} 248 249plugins_yamls = [] 250foreach(plugin, enabled_plugins) { 251 plugin_dir = "$ark_root/plugins/$plugin" 252 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 253 254 if (defined(source_files.option_yaml_path)) { 255 plugins_yamls += [ "$plugin_dir/${source_files.option_yaml_path}" ] 256 } 257 258 source_files = { 259 } 260} 261 262concat_yamls("concat_plugins_yamls") { 263 output_file = "$target_gen_dir/plugin_options.yaml" 264 default_file = "$ark_root/templates/plugin_options.yaml" 265 add_yamls = plugins_yamls 266} 267 268inst_templates_yamls = [] 269foreach(plugin, enabled_plugins) { 270 plugin_dir = "$ark_root/plugins/$plugin" 271 source_files = read_file("$plugin_dir/subproject_sources.gn", "scope") 272 if (defined(source_files.inst_templates_yaml_path)) { 273 inst_templates_yamls += 274 [ "$plugin_dir/${source_files.inst_templates_yaml_path}" ] 275 } 276 source_files = { 277 } 278} 279 280concat_yamls("concat_inst_templates_yamls") { 281 output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml" 282 default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml" 283 add_yamls = inst_templates_yamls 284} 285 286if (!ark_standalone_build) { 287 group("ark_host_linux_defectscanaux_lib") { 288 deps = [] 289 if (host_os == "linux") { 290 deps += [ "$ark_root/libark_defect_scan_aux:libark_defect_scan_aux(${host_toolchain})" ] 291 } 292 } 293 294 group("ark_host_linux_defectscanaux_unittest") { 295 testonly = true 296 deps = [] 297 if (host_os == "linux") { 298 deps += [ "$ark_root/libark_defect_scan_aux/tests/unittest:defect_scan_aux_demo(${host_toolchain})" ] 299 } 300 } 301 302 group("runtime_core_unittest") { 303 testonly = true 304 deps = [ 305 "$ark_root/arkplatform/tests:unittest", 306 "$ark_root/libpandabase/tests:unittest", 307 "$ark_root/libpandafile/tests:unittest", 308 "$ark_root/libziparchive/tests:unittest", 309 ] 310 } 311 312 group("runtime_core_host_unittest") { 313 testonly = true 314 deps = [ 315 "$ark_root/arkplatform/tests:host_unittest", 316 "$ark_root/assembler/tests:host_unittest", 317 "$ark_root/bytecode_optimizer/tests:host_unittest", 318 "$ark_root/compiler/tests:host_unittest", 319 "$ark_root/disassembler/tests:host_unittest", 320 "$ark_root/libark_defect_scan_aux/tests/unittest:host_unittest", 321 "$ark_root/libpandabase/tests:host_unittest", 322 "$ark_root/libpandafile/tests:host_unittest", 323 "$ark_root/libziparchive/tests:host_unittest", 324 "$ark_root/platforms/tests:host_unittest", 325 "$ark_root/verifier/tests:host_unittest", 326 ] 327 } 328 329 group("compiler_host_unittest") { 330 testonly = true 331 deps = [ "$ark_root/compiler/tests:host_unittest" ] 332 } 333 334 group("arkplatform_host_unittest") { 335 testonly = true 336 deps = [ "$ark_root/arkplatform/tests:host_unittest" ] 337 } 338 339 group("arkplatform_unittest") { 340 testonly = true 341 deps = [ "$ark_root/arkplatform/tests:unittest" ] 342 } 343} 344