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/toolchain/toolchain.gni") 15 16config("hiviewdfx_config") { 17 defines = [] 18 if (enable_dump_in_faultlog) { 19 defines += [ "ENABLE_DUMP_IN_FAULTLOG" ] 20 } 21 if (enable_bytrace) { 22 defines += [ "ENABLE_BYTRACE" ] 23 cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] 24 } 25 if (enable_hitrace) { 26 defines += [ "ENABLE_HITRACE" ] 27 } 28 if (enable_hilog) { 29 defines += [ "ENABLE_HILOG" ] 30 } 31 32 include_dirs = [ "$hilog_root/include" ] 33} 34 35config("ark_platform_config") { 36 configs = [ ":hiviewdfx_config" ] 37 defines = [] 38 if (is_ohos) { 39 defines += [ 40 "OHOS_PLATFORM", 41 "UNIX_PLATFORM", 42 ] 43 } else if (is_linux) { 44 defines += [ 45 "LINUX_PLATFORM", 46 "UNIX_PLATFORM", 47 ] 48 } else if (is_mingw) { 49 defines += [ "WINDOWS_PLATFORM" ] 50 } else if (target_os == "android") { 51 if (!ark_standalone_build) { 52 defines += [ 53 "ANDROID_PLATFORM", 54 "UNIX_PLATFORM", 55 ] 56 } else { 57 defines += [ "UNIX_PLATFORM" ] 58 } 59 } else if (target_os == "ios") { 60 defines += [ 61 "UNIX_PLATFORM", 62 "IOS_PLATFORM", 63 ] 64 } else if (is_mac) { 65 defines += [ 66 "MAC_PLATFORM", 67 "UNIX_PLATFORM", 68 ] 69 } else { 70 defines += [ "UNIX_PLATFORM" ] 71 } 72} 73 74config("ark_toolchain_common_config") { 75 configs = [ 76 ":ark_platform_config", 77 ":ark_toolchain_public_config", 78 ":hiviewdfx_config", 79 ] 80 81 defines = [ "PANDA_ENABLE_LTO" ] 82 cflags_cc = [ 83 "-Wall", 84 "-Wshadow", 85 "-Werror", 86 "-Wextra", 87 "-pedantic", 88 "-Wno-invalid-offsetof", 89 "-Wno-gnu-statement-expression", 90 "-pipe", 91 "-Wdate-time", 92 "-funwind-tables", 93 "-fasynchronous-unwind-tables", 94 "-Wformat=2", 95 ] 96 97 cflags_c = [] 98 99 if (is_linux) { 100 defines += [ 101 "PANDA_TARGET_UNIX", 102 "PANDA_TARGET_LINUX", 103 "PANDA_USE_FUTEX", 104 ] 105 } else if (is_mingw) { 106 cflags_cc += [ 107 "-std=c++17", 108 "-Wno-ignored-attributes", 109 ] 110 defines += [ 111 "PANDA_TARGET_WINDOWS", 112 "_CRTBLD", 113 "__LIBMSVCRT__", 114 ] 115 } else if (is_mac) { 116 defines += [ 117 "PANDA_TARGET_UNIX", 118 "PANDA_TARGET_MACOS", 119 ] 120 } else if (target_os == "android") { 121 defines += [ 122 "PANDA_TARGET_ANDROID", 123 "PANDA_TARGET_UNIX", 124 "PANDA_USE_FUTEX", 125 ] 126 if (!ark_standalone_build) { 127 defines += [ "ENABLE_ANLOG" ] 128 } 129 } else if (target_os == "ios") { 130 defines += [ 131 "PANDA_TARGET_UNIX", 132 "PANDA_TARGET_IOS", 133 ] 134 } else { 135 defines += [ 136 "PANDA_TARGET_UNIX", 137 "PANDA_USE_FUTEX", 138 ] 139 if (!is_standard_system && (current_cpu != "arm" || is_wearable_product)) { 140 defines += [ "PANDA_TARGET_MOBILE" ] 141 } 142 } 143 144 if (current_cpu == "arm") { 145 defines += [ 146 "PANDA_TARGET_ARM32_ABI_SOFT=1", 147 "PANDA_TARGET_ARM32", 148 "PANDA_TARGET_32", 149 ] 150 } else if (current_cpu == "arm64") { 151 defines += [ 152 "PANDA_TARGET_ARM64", 153 "PANDA_TARGET_64", 154 "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", 155 "PANDA_USE_32_BIT_POINTER", 156 ] 157 } else if (current_cpu == "x86") { 158 defines += [ "PANDA_TARGET_X86" ] 159 } else if (current_cpu == "amd64" || current_cpu == "x64" || 160 current_cpu == "x86_64") { 161 defines += [ 162 "PANDA_TARGET_64", 163 "PANDA_TARGET_AMD64", 164 "PANDA_USE_32_BIT_POINTER", 165 ] 166 } 167 168 if (is_fastverify) { 169 cflags_cc += [ 170 "-O3", 171 "-ggdb3", 172 "-gdwarf-4", 173 "-fno-omit-frame-pointer", 174 "-D_GLIBCXX_ASSERTIONS", 175 ] 176 cflags_c += [ 177 "-O3", 178 "-ggdb3", 179 "-gdwarf-4", 180 "-fno-omit-frame-pointer", 181 "-D_GLIBCXX_ASSERTIONS", 182 ] 183 } else if (is_debug) { 184 cflags_cc += [ 185 "-O0", 186 "-ggdb3", 187 "-gdwarf-4", 188 ] 189 } else { 190 defines += [ "NDEBUG" ] 191 } 192} 193 194config("ark_toolchain_public_config") { 195 defines = [] 196 197 cflags_cc = [ 198 "-Wno-unused-command-line-argument", 199 "-Wno-variadic-macros", 200 "-Wno-gnu-anonymous-struct", 201 "-Wno-zero-length-array", 202 "-Wno-nested-anon-types", 203 "-Wno-c99-extensions", 204 "-Wno-unused-parameter", 205 "-Wno-shadow", 206 "-Wno-pedantic", 207 "-Wno-gnu-zero-variadic-macro-arguments", 208 "-Wno-unused-lambda-capture", 209 "-Wno-unused-function", 210 "-Wno-unused-variable", 211 ] 212 213 # debug is not compatible with ios for now 214 if (!is_mingw && !is_mac && target_os != "ios") { 215 defines += [ 216 "ECMASCRIPT_SUPPORT_CPUPROFILER", 217 "ECMASCRIPT_SUPPORT_HEAPPROFILER", 218 "ECMASCRIPT_SUPPORT_HEAPSAMPLING", 219 "ECMASCRIPT_SUPPORT_SNAPSHOT", 220 "ECMASCRIPT_SUPPORT_DEBUGGER", 221 "ECMASCRIPT_SUPPORT_TRACING", 222 ] 223 } else if (target_os == "android") { 224 defines += [ 225 "ECMASCRIPT_SUPPORT_CPUPROFILER", 226 "ECMASCRIPT_SUPPORT_DEBUGGER", 227 "ECMASCRIPT_SUPPORT_TRACING", 228 ] 229 } 230 231 include_dirs = [ "." ] 232} 233 234# ecmascript unit testcase config 235config("toolchain_test_config") { 236 visibility = [ 237 "./inspector/test/*", 238 "./test/fuzztest/*", 239 "./tooling/dynamic/test/*", 240 "./websocket/test/*", 241 ] 242 243 configs = [ ":ark_toolchain_common_config" ] 244 245 if (!is_mac) { 246 ldflags = [ "-Wl,-rpath=\$ORIGIN/" ] 247 } 248} 249 250group("ark_toolchain_packages") { 251 deps = [] 252 deps += [ 253 "./inspector:ark_debugger", 254 "./inspector:connectserver_debugger", 255 "./tooling:libark_ecma_debugger", 256 "./tooling:libarkinspector_plus", 257 "./tooling/dynamic/client:libark_client", 258 "./tooling/dynamic/client/ark_cli:arkdb", 259 "./tooling/dynamic/client/ark_multi:ark_multi", 260 ] 261} 262 263group("ark_toolchain_unittest") { 264 testonly = true 265 deps = [] 266 deps += [ 267 "./inspector/test:unittest", 268 "./tooling/dynamic/test:unittest", 269 "./websocket/test:unittest", 270 ] 271 if (is_ohos && is_standard_system) { 272 deps += [ "./test/fuzztest:fuzztest" ] 273 } 274} 275 276group("ark_toolchain_host_unittest") { 277 testonly = true 278 deps = [] 279 280 # js unittest 281 deps += [ 282 "./inspector/test:host_unittest", 283 "./tooling/dynamic/test:host_unittest", 284 "./websocket/test:host_unittest", 285 ] 286} 287 288group("runtime_core_host_ut") { 289 testonly = true 290 if (ark_standalone_build) { 291 deps = [ "$ark_root:runtime_core_host_unittest" ] 292 } 293} 294