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/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 "-fno-omit-frame-pointer", 173 "-D_GLIBCXX_ASSERTIONS", 174 ] 175 cflags_c += [ 176 "-O3", 177 "-ggdb3", 178 "-fno-omit-frame-pointer", 179 "-D_GLIBCXX_ASSERTIONS", 180 ] 181 } else if (is_debug) { 182 cflags_cc += [ 183 "-O0", 184 "-ggdb3", 185 ] 186 } else { 187 defines += [ "NDEBUG" ] 188 } 189} 190 191config("ark_toolchain_public_config") { 192 defines = [] 193 194 # debug is not compatible with ios for now 195 if (!is_mingw && !is_mac && target_os != "ios") { 196 defines += [ 197 "ECMASCRIPT_SUPPORT_CPUPROFILER", 198 "ECMASCRIPT_SUPPORT_HEAPPROFILER", 199 "ECMASCRIPT_SUPPORT_HEAPSAMPLING", 200 "ECMASCRIPT_SUPPORT_SNAPSHOT", 201 "ECMASCRIPT_SUPPORT_DEBUGGER", 202 "ECMASCRIPT_SUPPORT_TRACING", 203 ] 204 } else if (target_os == "android") { 205 defines += [ 206 "ECMASCRIPT_SUPPORT_CPUPROFILER", 207 "ECMASCRIPT_SUPPORT_DEBUGGER", 208 "ECMASCRIPT_SUPPORT_TRACING", 209 ] 210 } 211 212 include_dirs = [ "." ] 213} 214 215# ecmascript unit testcase config 216config("toolchain_test_config") { 217 visibility = [ 218 "./inspector/test/*", 219 "./test/fuzztest/*", 220 "./tooling/test/*", 221 "./websocket/test/*", 222 ] 223 224 configs = [ ":ark_toolchain_common_config" ] 225 226 if (!is_mac) { 227 ldflags = [ "-Wl,-rpath=\$ORIGIN/" ] 228 } 229} 230 231group("ark_toolchain_packages") { 232 deps = [] 233 deps += [ 234 "./inspector:ark_debugger", 235 "./inspector:connectserver_debugger", 236 "./tooling:libark_ecma_debugger", 237 "./tooling/client:libark_client", 238 "./tooling/client/ark_cli:arkdb", 239 "./tooling/client/ark_multi:ark_multi", 240 ] 241} 242 243group("ark_toolchain_unittest") { 244 testonly = true 245 deps = [] 246 deps += [ 247 "./inspector/test:unittest", 248 "./tooling/test:unittest", 249 "./websocket/test:unittest", 250 ] 251 if (is_ohos && is_standard_system) { 252 deps += [ "./test/fuzztest:fuzztest" ] 253 } 254} 255 256group("ark_toolchain_host_unittest") { 257 testonly = true 258 deps = [] 259 260 # js unittest 261 deps += [ 262 "./inspector/test:host_unittest", 263 "./tooling/test:host_unittest", 264 "./websocket/test:host_unittest", 265 ] 266} 267 268group("ark_js_host_unittest") { 269 testonly = true 270 deps = [ 271 "//arkcompiler/ets_runtime:ark_runtime_host_unittest", 272 "//arkcompiler/toolchain:ark_toolchain_host_unittest", 273 ] 274} 275