1# Copyright (c) 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("//build/ohos.gni") 15import("ark_common_config.gni") 16 17config("ark_common_config") { 18 include_dirs = [ 19 "$ark_root", 20 get_label_info(":create_pipeline(${default_toolchain})", "target_gen_dir"), 21 ] 22 defines = [] 23 if (is_ohos && is_standard_system) { 24 defines += [ "PANDA_TARGET_OHOS" ] 25 # include_dirs += [ "$hilog_root/include" ] 26 } 27 28 if (is_linux) { 29 defines += [ 30 "PANDA_TARGET_UNIX", 31 "PANDA_TARGET_LINUX", 32 "PANDA_WITH_BYTECODE_OPTIMIZER", 33 "PANDA_WITH_COMPILER", 34 ] 35 if (!is_asan) { 36 defines += [ "PANDA_USE_FUTEX" ] 37 } 38 } else if (is_mingw) { 39 defines += [ 40 "PANDA_TARGET_WINDOWS", 41 "PANDA_WITH_BYTECODE_OPTIMIZER", 42 "PANDA_WITH_COMPILER", 43 "__LIBMSVCRT__", 44 ] 45 } else if (is_mac) { 46 defines += [ 47 "PANDA_TARGET_UNIX", 48 "PANDA_TARGET_MACOS", 49 "PANDA_WITH_BYTECODE_OPTIMIZER", 50 "PANDA_WITH_COMPILER", 51 52 # "PANDA_USE_FUTEX", 53 ] 54 } else if (is_mob) { 55 defines += [ 56 "PANDA_TARGET_UNIX", 57 "PANDA_USE_FUTEX", 58 "PANDA_TARGET_MOBILE", 59 "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", 60 ] 61 } else if (is_ohos) { 62 defines += [ 63 # TODO: use PANDA_TARGET_OHOS instead of PANDA_TARGET_UNIX 64 "PANDA_TARGET_UNIX", 65 "PANDA_WITH_COMPILER", 66 ] 67 if (!is_asan) { 68 defines += [ "PANDA_USE_FUTEX" ] 69 } 70 } else { 71 defines += [ 72 "PANDA_TARGET_UNIX", 73 "PANDA_USE_FUTEX", 74 ] 75 } 76 77 if (!is_debug) { 78 defines += [ "NDEBUG" ] 79 } 80 81 cflags_cc = [ 82 "-std=c++17", 83 "-pedantic", 84 "-Wall", 85 "-Wextra", 86 "-Werror", 87 "-fno-rtti", 88 "-fno-exceptions", 89 "-Wno-invalid-offsetof", 90 91 "-Wno-gnu-statement-expression", 92 "-Wno-unused-parameter", 93 "-Wno-unused-result", 94 ] 95 96 cflags_c = [] 97 98 if (!is_mac && use_pbqp) { 99 cflags_cc += [ 100 # PBQP regalloc 101 "-mllvm", 102 "-regalloc=pbqp", 103 ] 104 } 105 106 if (is_fastverify) { 107 cflags_cc += [ 108 "-O3", 109 "-ggdb3", 110 "-fno-omit-frame-pointer", 111 "-D_GLIBCXX_ASSERTIONS", 112 ] 113 cflags_c += [ 114 "-O3", 115 "-ggdb3", 116 "-fno-omit-frame-pointer", 117 "-D_GLIBCXX_ASSERTIONS", 118 ] 119 } else if (is_debug) { 120 cflags_cc += [ 121 "-Og", 122 "-ggdb3", 123 "-gdwarf-4", 124 ] 125 } 126 127 if (is_asan) { 128 cflags_cc += [ "-g" ] 129 if (defined(use_hwasan) && use_hwasan) { 130 defines += [ "__SANITIZE_HWADDRESS__" ] 131 } else { 132 defines += [ "__SANITIZE_ADDRESS__" ] 133 } 134 print("ASAN is enabled") 135 } 136 137 defines += [ "PANDA_WITH_ETS" ] 138 139 configs = [] 140 141 if (current_cpu == "arm") { 142 cflags_cc += [ 143 "-march=armv7-a", 144 "-mfloat-abi=${arm_float_abi}", 145 "-marm", 146 "-mfpu=vfp", 147 ] 148 149 if (arm_float_abi == "soft") { 150 defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] 151 } else if (arm_float_abi == "softfp") { 152 defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] 153 } else if (arm_float_abi == "hard") { 154 defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] 155 } 156 157 defines += [ 158 "PANDA_TARGET_32", 159 "PANDA_TARGET_ARM32", 160 ] 161 } else if (current_cpu == "arm64") { 162 defines += [ 163 "PANDA_TARGET_ARM64", 164 "PANDA_TARGET_64", 165 "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", 166 "PANDA_USE_32_BIT_POINTER", 167 ] 168 } else if (current_cpu == "x86") { 169 defines += [ "PANDA_TARGET_X86" ] 170 } else if (current_cpu == "amd64" || current_cpu == "x64" || 171 current_cpu == "x86_64") { 172 defines += [ 173 "PANDA_TARGET_64", 174 "PANDA_TARGET_AMD64", 175 "PANDA_USE_32_BIT_POINTER", 176 ] 177 } 178} 179