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