forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathBUILDCONFIG.gn
300 lines (258 loc) · 7.96 KB
/
BUILDCONFIG.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
is_skia_standalone = true
# It's best to keep the names and defaults of is_foo flags consistent with Chrome.
declare_args() {
is_official_build = false
is_component_build = false
is_static_skiasharp = false
ndk = ""
# Android 5.0, Lollipop
ndk_api = 21
linux_soname_version = ""
sanitize = ""
ar = "ar"
cc = "cc"
cxx = "c++"
win_sdk = ""
min_win_sdk_version = "10.0.16299.0"
win_sdk_version = ""
win_vc = ""
win_toolchain_version = ""
win_vcvars_version = ""
clang_win = ""
clang_win_version = ""
ncli = ""
ncli_version = "4.0"
ncli_gcc_version = "9.2.0"
ncli_gcc_version_short = "9.2"
ncli_llvm_version = "10"
ios_min_target = ""
min_ios_version = "8.0"
min_tvos_version = "9.0"
min_watchos_version = "2.0"
min_macos_version = "10.8"
min_maccatalyst_version = "13.0"
ios_use_simulator =
(target_os == "ios" || target_os == "tvos" || target_os == "watchos") &&
(target_cpu == "x86" || target_cpu == "x64")
}
declare_args() {
is_debug = !is_official_build
# This affects Skia's ABI; must be set consistently for Skia and dependents.
is_trivial_abi = !is_official_build
}
assert(!(is_debug && is_official_build))
if (target_cpu == "wasm") {
target_os = "wasm"
}
# Platform detection
if (target_os == "") {
target_os = host_os
if (ndk != "") {
target_os = "android"
}
}
if (current_os == "") {
current_os = target_os
}
is_android = current_os == "android"
is_fuchsia = current_os == "fuchsia"
is_ios = current_os == "ios" || current_os == "tvos" || current_os == "watchos" || current_os == "maccatalyst"
is_tvos = current_os == "tvos"
is_watchos = current_os == "watchos"
is_maccatalyst = current_os == "maccatalyst"
is_linux = current_os == "linux" || current_os == "tizen"
is_mac = current_os == "mac"
is_wasm = current_os == "wasm"
is_win = current_os == "win" || current_os == "winrt"
is_winrt = current_os == "winrt"
is_tizen = current_os == "tizen"
# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux"
# for ChromeOS, so this variable will not affect Skia proper.
is_chromeos = false
# This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios.
is_apple = is_mac || is_ios
if (target_cpu == "") {
target_cpu = host_cpu
if (is_android || is_ios) {
target_cpu = "arm64"
}
}
if (target_cpu == "x86_64") {
target_cpu = "x64"
}
if (current_cpu == "") {
current_cpu = target_cpu
}
is_clang = is_android || is_ios || is_mac || is_fuchsia || is_tizen || is_wasm ||
(cc == "clang" && cxx == "clang++") || clang_win != ""
if (!is_clang && !is_win) {
is_clang = exec_script("//gn/is_clang.py",
[
cc,
cxx,
],
"value")
}
if (is_android) {
ndk_host = ""
ndk_target = ""
ndk_gdbserver = ""
if (host_os == "linux") {
ndk_host = "linux-x86_64"
} else if (host_os == "mac") {
ndk_host = "darwin-x86_64"
} else if (host_os == "win") {
ndk_host = "windows-x86_64"
}
if (target_cpu == "arm64") {
ndk_target = "aarch64-linux-android"
ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
} else if (target_cpu == "arm") {
ndk_target = "armv7a-linux-androideabi"
ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
} else if (target_cpu == "x64") {
ndk_target = "x86_64-linux-android"
ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
} else if (target_cpu == "x86") {
ndk_target = "i686-linux-android"
ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
}
}
if (is_win) {
# By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
# non-default location, you can set win_vc to inform us where it is.
if (win_vc == "") {
win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
}
if (win_vc != "") {
if (win_toolchain_version == "") {
if (win_vcvars_version != "") {
win_toolchain_version = exec_script("//gn/highest_version_dir.py", [ "$win_vc/Tools/MSVC", "$win_vcvars_version[0-9]{1}\.[0-9]{5}" ], "trim string")
} else {
win_toolchain_version = exec_script("//gn/highest_version_dir.py", [ "$win_vc/Tools/MSVC", "[0-9]{2}\.[0-9]{2}\.[0-9]{5}" ], "trim string")
}
}
if (win_vcvars_version == "") {
win_vcvars_version = exec_script("//gn/get_vcvars_version.py", [ win_toolchain_version ], "trim string")
}
}
if (win_sdk == "") {
win_sdk = exec_script("//gn/find_winsdk.py", [], "trim string")
}
if (win_sdk != "" && win_sdk_version == "") {
win_sdk_version = exec_script("//gn/lowest_version_dir.py", [ "$win_sdk/Include", "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", min_win_sdk_version ], "trim string")
}
if (clang_win != "" && clang_win_version == "") {
clang_win_version = exec_script("//gn/highest_version_dir.py",
[
"$clang_win/lib/clang",
"[0-9]+\.[0-9]+\.[0-9]+",
],
"trim string")
}
}
if (is_tizen) {
ncli_target = ""
ncli_platform = ""
ncli_gccdir = ""
if (target_cpu == "arm") {
ncli_target = "arm-tizen-linux-gnueabi"
ncli_platform = "tizen-${ncli_version}/mobile/rootstraps/mobile-${ncli_version}-device.core"
ncli_gccdir = "arm-linux-gnueabi-gcc-${ncli_gcc_version_short}"
} else if (target_cpu == "x86") {
ncli_target = "i586-tizen-linux-gnueabi"
ncli_platform = "tizen-${ncli_version}/mobile/rootstraps/mobile-${ncli_version}-emulator.core"
ncli_gccdir = "i586-linux-gnueabi-gcc-${ncli_gcc_version_short}"
}
}
# A component is either a static or a shared library.
template("component") {
_component_mode = "static_library"
if (is_component_build) {
_component_mode = "shared_library"
}
target(_component_mode, target_name) {
forward_variables_from(invoker, "*")
}
}
# SkiaSharp differs depending on the platform
template("skiasharp_build") {
_skiasharp_mode = "shared_library"
if (is_static_skiasharp) {
_skiasharp_mode = "static_library"
}
target(_skiasharp_mode, target_name) {
forward_variables_from(invoker, "*")
}
}
# Default configs
default_configs = [
"//gn/skia:default",
"//gn/skia:no_exceptions",
"//gn/skia:no_rtti",
]
if (!is_debug) {
default_configs += [
"//gn/skia:optimize",
"//gn/skia:NDEBUG",
]
}
if (is_trivial_abi) {
default_configs += [ "//gn/skia:trivial_abi" ]
}
if (!is_official_build) {
default_configs += [ "//gn/skia:debug_symbols" ]
}
default_configs += [ "//gn/skia:extra_flags" ]
set_defaults("executable") {
configs = [ "//gn/skia:executable" ] + default_configs
}
set_defaults("source_set") {
configs = default_configs
}
set_defaults("static_library") {
configs = default_configs
}
set_defaults("shared_library") {
configs = default_configs
}
set_defaults("component") {
configs = default_configs
if (!is_component_build) {
complete_static_lib = true
}
}
skia_target_default_configs = []
if (!is_official_build) {
skia_target_default_configs += [ "//gn/skia:warnings" ]
}
skia_header_target_default_configs = []
if (!is_official_build) {
skia_header_target_default_configs +=
[ "//gn/skia:warnings_for_public_headers" ]
}
if (is_win) {
# Windows tool chain
set_default_toolchain("//gn/toolchain:msvc")
default_toolchain_name = "msvc"
host_toolchain = "msvc"
} else if (is_wasm) {
set_default_toolchain("//gn/toolchain:wasm")
default_toolchain_name = "wasm"
host_toolchain = "wasm"
} else {
# GCC-like toolchains, including Clang.
set_default_toolchain("//gn/toolchain:gcc_like")
default_toolchain_name = "gcc_like"
host_toolchain = "gcc_like_host"
}
set_defaults("skiasharp_build") {
configs = default_configs
if (is_static_skiasharp) {
complete_static_lib = true
}
}