| 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 |
use_libfuzzer = false |
| 14 |
ndk = "" |
| 15 |
|
| 16 |
# Android 5.0, Lollipop |
| 17 |
ndk_api = 21 |
| 18 |
|
| 19 |
sanitize = "" |
| 20 |
|
| 21 |
ar = "ar" |
| 22 |
cc = "cc" |
| 23 |
cxx = "c++" |
| 24 |
|
| 25 |
win_sdk = "C:/Program Files (x86)/Windows Kits/10" |
| 26 |
win_sdk_version = "" |
| 27 |
|
| 28 |
win_vc = "" |
| 29 |
win_toolchain_version = "" |
| 30 |
|
| 31 |
clang_win = "" |
| 32 |
clang_win_version = "" |
| 33 |
|
| 34 |
ios_min_target = "" |
| 35 |
ios_use_simulator = |
| 36 |
target_os == "ios" && (target_cpu == "x86" || target_cpu == "x64") |
| 37 |
|
| 38 |
# Enable -H, which prints the include tree during compilation. |
| 39 |
# For use by external tools for analyzing include files. |
| 40 |
show_includes = false |
| 41 |
} |
| 42 |
declare_args() { |
| 43 |
is_debug = !is_official_build |
| 44 |
|
| 45 |
# This affects Skia's ABI; must be set consistently for Skia and dependents. |
| 46 |
is_trivial_abi = false |
| 47 |
} |
| 48 |
|
| 49 |
assert(!(is_debug && is_official_build)) |
| 50 |
|
| 51 |
if (target_cpu == "wasm") { |
| 52 |
target_os = "wasm" |
| 53 |
} |
| 54 |
|
| 55 |
# Platform detection |
| 56 |
if (target_os == "") { |
| 57 |
target_os = host_os |
| 58 |
if (ndk != "") { |
| 59 |
target_os = "android" |
| 60 |
} |
| 61 |
} |
| 62 |
if (current_os == "") { |
| 63 |
current_os = target_os |
| 64 |
} |
| 65 |
|
| 66 |
is_android = current_os == "android" |
| 67 |
is_ios = current_os == "ios" || current_os == "tvos" |
| 68 |
is_tvos = current_os == "tvos" |
| 69 |
is_linux = current_os == "linux" |
| 70 |
is_mac = current_os == "mac" |
| 71 |
is_wasm = current_os == "wasm" |
| 72 |
is_win = current_os == "win" |
| 73 |
|
| 74 |
# Dawn has references to fuchsia, but Skia's GN rules do not |
| 75 |
is_fuchsia = false |
| 76 |
|
| 77 |
# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux" |
| 78 |
# for ChromeOS, so this variable will not affect Skia proper. |
| 79 |
is_chromeos = false |
| 80 |
|
| 81 |
# This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios. |
| 82 |
is_apple = is_mac || is_ios |
| 83 |
|
| 84 |
if (target_cpu == "") { |
| 85 |
target_cpu = host_cpu |
| 86 |
if (is_android || is_ios) { |
| 87 |
target_cpu = "arm64" |
| 88 |
} |
| 89 |
} |
| 90 |
if (target_cpu == "x86_64") { |
| 91 |
target_cpu = "x64" |
| 92 |
} |
| 93 |
if (current_cpu == "") { |
| 94 |
current_cpu = target_cpu |
| 95 |
} |
| 96 |
|
| 97 |
is_clang = is_android || is_ios || is_mac || is_wasm || |
| 98 |
(cc == "clang" && cxx == "clang++") || clang_win != "" |
| 99 |
if (!is_clang && !is_win) { |
| 100 |
is_clang = exec_script("//gn/is_clang.py", |
| 101 |
[ |
| 102 |
cc, |
| 103 |
cxx, |
| 104 |
], |
| 105 |
"value") |
| 106 |
} |
| 107 |
|
| 108 |
if (is_android) { |
| 109 |
ndk_host = "" |
| 110 |
ndk_target = "" |
| 111 |
|
| 112 |
if (host_os == "linux") { |
| 113 |
ndk_host = "linux-x86_64" |
| 114 |
} else if (host_os == "mac") { |
| 115 |
ndk_host = "darwin-x86_64" |
| 116 |
} else if (host_os == "win") { |
| 117 |
ndk_host = "windows-x86_64" |
| 118 |
} |
| 119 |
|
| 120 |
if (target_cpu == "arm64") { |
| 121 |
ndk_target = "aarch64-linux-android" |
| 122 |
} else if (target_cpu == "arm") { |
| 123 |
ndk_target = "armv7a-linux-androideabi" |
| 124 |
} else if (target_cpu == "x64") { |
| 125 |
ndk_target = "x86_64-linux-android" |
| 126 |
} else if (target_cpu == "x86") { |
| 127 |
ndk_target = "i686-linux-android" |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
if (target_os == "win") { |
| 132 |
# By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a |
| 133 |
# non-default location, you can set win_vc to inform us where it is. |
| 134 |
|
| 135 |
if (win_vc == "") { |
| 136 |
win_vc = exec_script("//gn/find_msvc.py", [], "trim string") |
| 137 |
} |
| 138 |
assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC |
| 139 |
# directory. |
| 140 |
} |
| 141 |
|
| 142 |
if (target_os == "win") { |
| 143 |
if (win_toolchain_version == "") { |
| 144 |
win_toolchain_version = exec_script("//gn/highest_version_dir.py", |
| 145 |
[ |
| 146 |
"$win_vc/Tools/MSVC", |
| 147 |
"[0-9]{2}\.[0-9]{2}\.[0-9]{5}", |
| 148 |
], |
| 149 |
"trim string") |
| 150 |
} |
| 151 |
if (win_sdk_version == "") { |
| 152 |
win_sdk_version = exec_script("//gn/highest_version_dir.py", |
| 153 |
[ |
| 154 |
"$win_sdk/Include", |
| 155 |
"[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", |
| 156 |
], |
| 157 |
"trim string") |
| 158 |
} |
| 159 |
if (clang_win != "" && clang_win_version == "") { |
| 160 |
clang_win_version = exec_script("//gn/highest_version_dir.py", |
| 161 |
[ |
| 162 |
"$clang_win/lib/clang", |
| 163 |
"[0-9]+(\.[0-9]+\.[0-9]+)?", |
| 164 |
], |
| 165 |
"trim string") |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
# A component is either a static or a shared library. |
| 170 |
template("component") { |
| 171 |
_component_mode = "static_library" |
| 172 |
if (is_component_build) { |
| 173 |
_component_mode = "shared_library" |
| 174 |
} |
| 175 |
|
| 176 |
target(_component_mode, target_name) { |
| 177 |
forward_variables_from(invoker, "*") |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
# Default configs |
| 182 |
default_configs = [ |
| 183 |
"//gn/skia:default", |
| 184 |
"//gn/skia:no_exceptions", |
| •185 |
# We want RTTI, otherwise builds *with* RTTI don't work. |
| 186 |
# "//gn/skia:no_rtti", |
| 187 |
"//gn/skia:strict_aliasing", |
| 188 |
] |
| 189 |
if (!is_debug) { |
| 190 |
default_configs += [ |
| 191 |
"//gn/skia:optimize", |
| 192 |
"//gn/skia:NDEBUG", |
| 193 |
] |
| 194 |
} |
| 195 |
if (is_trivial_abi) { |
| 196 |
default_configs += [ "//gn/skia:trivial_abi" ] |
| 197 |
} |
| 198 |
if (!is_official_build) { |
| 199 |
default_configs += [ "//gn/skia:debug_symbols" ] |
| 200 |
} |
| 201 |
default_configs += [ "//gn/skia:extra_flags" ] |
| 202 |
|
| 203 |
set_defaults("executable") { |
| 204 |
configs = [ "//gn/skia:executable" ] + default_configs |
| 205 |
} |
| 206 |
|
| 207 |
set_defaults("source_set") { |
| 208 |
configs = default_configs |
| 209 |
} |
| 210 |
|
| 211 |
set_defaults("static_library") { |
| 212 |
configs = default_configs |
| 213 |
} |
| 214 |
|
| 215 |
set_defaults("shared_library") { |
| 216 |
configs = default_configs |
| 217 |
} |
| 218 |
|
| 219 |
set_defaults("component") { |
| 220 |
configs = default_configs |
| 221 |
if (!is_component_build) { |
| 222 |
complete_static_lib = true |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
skia_target_default_configs = [] |
| 227 |
if (!is_official_build) { |
| 228 |
skia_target_default_configs += [ "//gn/skia:warnings" ] |
| 229 |
} |
| 230 |
|
| 231 |
skia_header_target_default_configs = [] |
| 232 |
if (!is_official_build) { |
| 233 |
skia_header_target_default_configs += |
| 234 |
[ "//gn/skia:warnings_for_public_headers" ] |
| 235 |
} |
| 236 |
|
| 237 |
if (is_win) { |
| 238 |
# Windows tool chain |
| 239 |
set_default_toolchain("//gn/toolchain:msvc") |
| 240 |
default_toolchain_name = "msvc" |
| 241 |
host_toolchain = "msvc_host" |
| 242 |
} else if (is_wasm) { |
| 243 |
set_default_toolchain("//gn/toolchain:wasm") |
| 244 |
default_toolchain_name = "wasm" |
| 245 |
host_toolchain = "wasm" |
| 246 |
} else { |
| 247 |
# GCC-like toolchains, including Clang. |
| 248 |
set_default_toolchain("//gn/toolchain:gcc_like") |
| 249 |
default_toolchain_name = "gcc_like" |
| 250 |
host_toolchain = "gcc_like_host" |
| 251 |
} |