1 # Copyright 2016 Google Inc. 2 # 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 is_skia_standalone = true 7 8 # It's best to keep the names and defaults of is_foo flags consistent with Chrome. 9 10 declare_args() { 11 is_official_build = false 12 is_component_build = false 13 ndk = "" 14 15 # It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't. 16 if (target_cpu == "x86" || target_cpu == "arm") { 17 ndk_api = 16 18 } else { 19 ndk_api = 21 20 } 21 22 sanitize = "" 23 24 ar = "ar" 25 cc = "cc" 26 cxx = "c++" 27 28 win_sdk = "C:/Program Files (x86)/Windows Kits/10" 29 win_sdk_version = "" 30 31 win_vc = "" 32 win_toolchain_version = "" 33 34 clang_win = "" 35 } 36 declare_args() { 37 is_debug = !is_official_build 38 } 39 40 assert(!(is_debug && is_official_build)) 41 42 if (target_cpu == "wasm") { 43 target_os = "wasm" 44 } 45 46 # Platform detection 47 if (target_os == "") { 48 target_os = host_os 49 if (ndk != "") { 50 target_os = "android" 51 } 52 } 53 if (current_os == "") { 54 current_os = target_os 55 } 56 57 is_android = current_os == "android" 58 is_fuchsia = current_os == "fuchsia" 59 is_ios = current_os == "ios" || current_os == "tvos" 60 is_tvos = current_os == "tvos" 61 is_linux = current_os == "linux" 62 is_mac = current_os == "mac" 63 is_win = current_os == "win" 64 65 if (target_cpu == "") { 66 target_cpu = host_cpu 67 if (is_android || is_ios) { 68 target_cpu = "arm64" 69 } 70 } 71 if (target_cpu == "x86_64") { 72 target_cpu = "x64" 73 } 74 if (current_cpu == "") { 75 current_cpu = target_cpu 76 } 77 78 is_clang = is_android || is_ios || is_mac || 79 (cc == "clang" && cxx == "clang++") || clang_win != "" 80 if (!is_clang && !is_win) { 81 is_clang = exec_script("gn/is_clang.py", 82 [ 83 cc, 84 cxx, 85 ], 86 "value") 87 } 88 89 if (is_android) { 90 ndk_host = "" 91 ndk_target = "" 92 ndk_platform = "" 93 ndk_stdlib = "" 94 ndk_gccdir = "" 95 ndk_gdbserver = "" 96 97 if (host_os == "linux") { 98 ndk_host = "linux-x86_64" 99 } else if (host_os == "mac") { 100 ndk_host = "darwin-x86_64" 101 } else if (host_os == "win") { 102 ndk_host = "windows-x86_64" 103 } 104 105 if (target_cpu == "arm64") { 106 ndk_target = "aarch64-linux-android" 107 ndk_platform = "android-${ndk_api}/arch-arm64" 108 ndk_stdlib = "arm64-v8a" 109 ndk_gccdir = ndk_target 110 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver" 111 } else if (target_cpu == "arm") { 112 ndk_target = "arm-linux-androideabi" 113 ndk_platform = "android-${ndk_api}/arch-arm" 114 ndk_stdlib = "armeabi-v7a" 115 ndk_gccdir = ndk_target 116 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" 117 } else if (target_cpu == "x64") { 118 ndk_target = "x86_64-linux-android" 119 ndk_platform = "android-${ndk_api}/arch-x86_64" 120 ndk_stdlib = "x86_64" 121 ndk_gccdir = ndk_stdlib 122 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" 123 } else if (target_cpu == "x86") { 124 ndk_target = "i686-linux-android" 125 ndk_platform = "android-${ndk_api}/arch-x86" 126 ndk_stdlib = "x86" 127 ndk_gccdir = ndk_stdlib 128 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" 129 } 130 } 131 132 msvc = "" 133 if (target_os == "win") { 134 # By default we look for 2017, then 2015. If MSVC is installed in a non-default 135 # location, you can set win_vc to inform us where it is. 136 vc_2017_default = 137 "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC" 138 vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC" 139 140 if (win_vc == "") { 141 if ("True" == 142 exec_script("//gn/checkdir.py", [ "$vc_2017_default" ], "trim string")) { 143 win_vc = vc_2017_default 144 msvc = 2017 145 } else if ("True" == exec_script("//gn/checkdir.py", 146 [ "$vc_2015_default" ], 147 "trim string")) { 148 win_vc = vc_2015_default 149 msvc = 2015 150 } 151 } 152 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory. 153 154 if (msvc == "") { 155 if ("True" == 156 exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) { 157 msvc = 2017 158 } else { 159 msvc = 2015 160 } 161 } 162 } 163 164 if (target_os == "win") { 165 if (msvc == 2017 && win_toolchain_version == "") { 166 win_toolchain_version = exec_script("//gn/highest_version_dir.py", 167 [ 168 "$win_vc/Tools/MSVC", 169 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}", 170 ], 171 "trim string") 172 } 173 if (win_sdk_version == "") { 174 win_sdk_version = exec_script("//gn/highest_version_dir.py", 175 [ 176 "$win_sdk/Include", 177 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", 178 ], 179 "trim string") 180 } 181 } 182 183 # A component is either a static or a shared library. 184 template("component") { 185 _component_mode = "static_library" 186 if (is_component_build) { 187 _component_mode = "shared_library" 188 } 189 190 target(_component_mode, target_name) { 191 forward_variables_from(invoker, "*") 192 } 193 } 194 195 # Default configs 196 default_configs = [ 197 "//gn:default", 198 "//gn:no_exceptions", 199 "//gn:no_rtti", 200 "//gn:warnings", 201 "//gn:warnings_except_public_headers", 202 ] 203 if (!is_debug) { 204 default_configs += [ "//gn:release" ] 205 } 206 if (!is_official_build) { 207 default_configs += [ "//gn:debug_symbols" ] 208 } 209 default_configs += [ "//gn:extra_flags" ] 210 211 set_defaults("executable") { 212 configs = [ "//gn:executable" ] + default_configs 213 } 214 215 set_defaults("source_set") { 216 configs = default_configs 217 } 218 219 set_defaults("static_library") { 220 configs = default_configs 221 } 222 223 set_defaults("shared_library") { 224 configs = default_configs 225 } 226 227 set_defaults("component") { 228 configs = default_configs 229 if (!is_component_build) { 230 complete_static_lib = true 231 } 232 } 233 234 if (is_win) { 235 # Windows tool chain 236 set_default_toolchain("//gn/toolchain:msvc") 237 default_toolchain_name = "msvc" 238 host_toolchain = "msvc" 239 } else { 240 # GCC-like toolchains, including Clang. 241 set_default_toolchain("//gn/toolchain:gcc_like") 242 default_toolchain_name = "gcc_like" 243 host_toolchain = "gcc_like_host" 244 } 245