skia2/gn/BUILDCONFIG.gn
Brian Osman 852ca318a1 Updated MSVC toolchain to 2017, and further refactored GN
'windk' is no longer a thing. There are two separate variables to point
at your compiler (win_vc), and SDK (win_sdk).

'msvc' is no longer a thing, either. By default, we look for 2017 and
then 2015 (in the default locations). If neither is located, use an
assert to let users know they should set win_vc. Then, detect if win_vc
points at a 2017 or 2015 installation, and configure it automatically.

Because the toolchain is now 2017, update the GN files to handle building
x86 in that configuration. In fact, we only support x86 builds (with 2017
or 2015) using the toolchain assets. Keep a 2015 toolchain around as a
new asset, so we can add bot coverage.

Docs-Preview: https://skia.org/?cl=81841
Bug: skia:
Change-Id: I8c68a6f949e54c0e798a219450bbb9406f8dc6ac
Reviewed-on: https://skia-review.googlesource.com/81841
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-08 01:46:30 +00:00

239 lines
5.8 KiB
Plaintext

# 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
ndk = ""
# It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't.
if (target_cpu == "x86" || target_cpu == "arm") {
ndk_api = 16
} else {
ndk_api = 21
}
sanitize = ""
ar = "ar"
cc = "cc"
cxx = "c++"
win_sdk = "C:/Program Files (x86)/Windows Kits/10"
win_sdk_version = ""
win_vc = ""
win_toolchain_version = ""
clang_win = ""
}
declare_args() {
is_debug = !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"
is_tvos = current_os == "tvos"
is_linux = current_os == "linux"
is_mac = current_os == "mac"
is_win = current_os == "win"
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 ||
(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_platform = ""
ndk_stdlib = ""
ndk_gccdir = ""
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_platform = "android-${ndk_api}/arch-arm64"
ndk_stdlib = "arm64-v8a"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
} else if (target_cpu == "arm") {
ndk_target = "arm-linux-androideabi"
ndk_platform = "android-${ndk_api}/arch-arm"
ndk_stdlib = "armeabi-v7a"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
} else if (target_cpu == "x64") {
ndk_target = "x86_64-linux-android"
ndk_platform = "android-${ndk_api}/arch-x86_64"
ndk_stdlib = "x86_64"
ndk_gccdir = ndk_stdlib
ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
} else if (target_cpu == "x86") {
ndk_target = "i686-linux-android"
ndk_platform = "android-${ndk_api}/arch-x86"
ndk_stdlib = "x86"
ndk_gccdir = ndk_stdlib
ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
}
}
msvc = ""
if (target_os == "win") {
# By default we look for 2017, then 2015. If MSVC is installed in a non-default
# location, you can set win_vc to inform us where it is.
vc_2017_default =
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC"
vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
if (win_vc == "") {
if ("True" ==
exec_script("//gn/checkdir.py", [ "$vc_2017_default" ], "trim string")) {
win_vc = vc_2017_default
msvc = 2017
} else if ("True" == exec_script("//gn/checkdir.py",
[ "$vc_2015_default" ],
"trim string")) {
win_vc = vc_2015_default
msvc = 2015
}
}
assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory.
if (msvc == "") {
if ("True" ==
exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) {
msvc = 2017
} else {
msvc = 2015
}
}
}
if (target_os == "win") {
if (msvc == 2017 && win_toolchain_version == "") {
win_toolchain_version = exec_script("//gn/highest_version_dir.py",
[ "$win_vc/Tools/MSVC" ],
"trim string")
}
if (win_sdk_version == "") {
win_sdk_version = exec_script("//gn/highest_version_dir.py",
[ "$win_sdk/Include" ],
"trim string")
}
}
# 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, "*")
}
}
# Default configs
default_configs = [
"//gn:default",
"//gn:no_exceptions",
"//gn:no_rtti",
"//gn:warnings",
"//gn:warnings_except_public_headers",
]
if (!is_debug) {
default_configs += [ "//gn:release" ]
}
if (!is_official_build) {
default_configs += [ "//gn:debug_symbols" ]
}
default_configs += [ "//gn:extra_flags" ]
set_defaults("executable") {
configs = [ "//gn: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
}
}
if (is_win) {
# Windows tool chain
set_default_toolchain("//gn/toolchain:msvc")
default_toolchain_name = "msvc"
host_toolchain = "msvc"
} else {
# GCC-like toolchains, including Clang.
set_default_toolchain("//gn/toolchain:gcc_like")
default_toolchain_name = "gcc_like"
host_toolchain = "gcc_like_host"
}