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 if (is_linux) { 98 defines += [ 99 "PANDA_TARGET_UNIX", 100 "PANDA_TARGET_LINUX", 101 "PANDA_USE_FUTEX", 102 ] 103 } else if (is_mingw) { 104 cflags_cc += [ 105 "-std=c++17", 106 "-Wno-ignored-attributes", 107 ] 108 defines += [ 109 "PANDA_TARGET_WINDOWS", 110 "_CRTBLD", 111 "__LIBMSVCRT__", 112 ] 113 } else if (is_mac) { 114 defines += [ 115 "PANDA_TARGET_UNIX", 116 "PANDA_TARGET_MACOS", 117 ] 118 } else if (target_os == "android") { 119 defines += [ 120 "PANDA_TARGET_ANDROID", 121 "PANDA_TARGET_UNIX", 122 "PANDA_USE_FUTEX", 123 ] 124 if (!ark_standalone_build) { 125 defines += [ "ENABLE_ANLOG" ] 126 } 127 } else if (target_os == "ios") { 128 defines += [ 129 "PANDA_TARGET_UNIX", 130 "PANDA_TARGET_IOS", 131 ] 132 } else { 133 defines += [ 134 "PANDA_TARGET_UNIX", 135 "PANDA_USE_FUTEX", 136 ] 137 if (!is_standard_system && (current_cpu != "arm" || is_wearable_product)) { 138 defines += [ "PANDA_TARGET_MOBILE" ] 139 } 140 } 141 142 if (is_debug) { 143 cflags_cc += [ 144 "-O0", 145 "-ggdb3", 146 ] 147 } else { 148 defines += [ "NDEBUG" ] 149 } 150} 151 152config("ark_toolchain_public_config") { 153 defines = [] 154 155 # debug is not compatible with ios for now 156 if (!is_mingw && !is_mac && target_os != "ios") { 157 defines += [ 158 "ECMASCRIPT_SUPPORT_CPUPROFILER", 159 "ECMASCRIPT_SUPPORT_HEAPPROFILER", 160 "ECMASCRIPT_SUPPORT_HEAPSAMPLING", 161 "ECMASCRIPT_SUPPORT_SNAPSHOT", 162 "ECMASCRIPT_SUPPORT_DEBUGGER", 163 "ECMASCRIPT_SUPPORT_TRACING", 164 ] 165 } else if (target_os == "android") { 166 defines += [ 167 "ECMASCRIPT_SUPPORT_CPUPROFILER", 168 "ECMASCRIPT_SUPPORT_DEBUGGER", 169 "ECMASCRIPT_SUPPORT_TRACING", 170 ] 171 } 172 173 include_dirs = [ 174 # Dependent on runtime_core include 175 "$ark_root", 176 "$js_root", 177 ".", 178 ] 179} 180 181# ecmascript unit testcase config 182config("toolchain_test_config") { 183 visibility = [ 184 "./test/fuzztest/*", 185 "./tooling/test/*", 186 "./websocket/test/*", 187 ] 188 189 configs = [ ":ark_toolchain_common_config" ] 190 191 ldflags = [ "-Wl,-rpath=\$ORIGIN/" ] 192} 193 194group("ark_toolchain_packages") { 195 deps = [] 196 if (host_os != "mac") { 197 deps += [ 198 "./inspector:ark_debugger", 199 "./inspector:connectserver_debugger", 200 "./tooling:libark_ecma_debugger", 201 "./tooling/client:libark_client", 202 "./tooling/client/ark_cli:arkdb", 203 ] 204 } 205} 206 207group("ark_toolchain_unittest") { 208 testonly = true 209 deps = [] 210 if (host_os != "mac") { 211 deps += [ 212 "//arkcompiler/toolchain/tooling/test:unittest", 213 "//arkcompiler/toolchain/websocket/test:unittest", 214 ] 215 if (is_ohos && is_standard_system) { 216 deps += [ "//arkcompiler/toolchain/test/fuzztest:fuzztest" ] 217 } 218 } 219} 220 221group("ark_toolchain_host_unittest") { 222 testonly = true 223 deps = [] 224 if (host_os != "mac" && !is_debug) { 225 # js unittest 226 deps += [ 227 "//arkcompiler/toolchain/tooling/test:host_unittest", 228 "//arkcompiler/toolchain/websocket/test:host_unittest", 229 ] 230 } 231} 232 233group("ark_js_host_unittest") { 234 testonly = true 235 deps = [ 236 "//arkcompiler/ets_runtime:ark_runtime_host_unittest", 237 "//arkcompiler/toolchain:ark_toolchain_host_unittest", 238 ] 239} 240