2017-06-29 14:03:38 +00:00
|
|
|
declare_args() {
|
|
|
|
host_ar = ar
|
|
|
|
host_cc = cc
|
|
|
|
host_cxx = cxx
|
|
|
|
|
|
|
|
if (is_android) {
|
|
|
|
if (host_os == "win") {
|
|
|
|
target_ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar.exe"
|
|
|
|
target_cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang.exe"
|
|
|
|
target_cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++.exe"
|
|
|
|
} else {
|
|
|
|
target_ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
|
|
|
|
target_cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
|
|
|
|
target_cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target_ar = ar
|
|
|
|
target_cc = cc
|
|
|
|
target_cxx = cxx
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_wrapper = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_os == "win") {
|
|
|
|
stamp = "cmd.exe /c echo >"
|
|
|
|
} else {
|
|
|
|
stamp = "touch"
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchain("msvc") {
|
|
|
|
lib_dir_switch = "/LIBPATH:"
|
|
|
|
|
|
|
|
if (msvc == 2015) {
|
2018-03-16 12:45:35 +00:00
|
|
|
if (target_cpu == "x86") {
|
2018-12-10 15:10:55 +00:00
|
|
|
bin = "$win_vc/bin"
|
2018-03-16 12:45:35 +00:00
|
|
|
} else {
|
2018-12-10 15:10:55 +00:00
|
|
|
bin = "$win_vc/bin/amd64"
|
2018-03-16 12:45:35 +00:00
|
|
|
}
|
2017-06-29 14:03:38 +00:00
|
|
|
} else {
|
2018-12-10 15:10:55 +00:00
|
|
|
bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$target_cpu"
|
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-07 21:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
env_setup = ""
|
|
|
|
if (target_cpu == "x86") {
|
|
|
|
# Toolchain asset includes a script that configures for x86 building.
|
|
|
|
# We don't support x86 builds with local MSVC installations.
|
|
|
|
env_setup = "cmd /c $win_sdk/bin/SetEnv.cmd /x86 && "
|
2018-12-07 20:30:43 +00:00
|
|
|
} else if (target_cpu == "arm64") {
|
|
|
|
# ARM64 compiler is incomplete - it relies on DLLs located in the host toolchain directory.
|
2018-12-10 15:10:55 +00:00
|
|
|
env_setup = "cmd /C set \"PATH=%PATH%;$win_vc\\Tools\\MSVC\\$win_toolchain_version\\bin\\HostX64\\x64\" && "
|
2017-06-29 14:03:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-13 19:11:14 +00:00
|
|
|
cl_m32_flag = ""
|
2018-12-10 12:51:54 +00:00
|
|
|
|
2017-07-31 15:57:21 +00:00
|
|
|
if (clang_win != "") {
|
2018-03-13 19:11:14 +00:00
|
|
|
if (target_cpu == "x86") {
|
|
|
|
# cl.exe knows implicitly by the choice of executable that it's targeting
|
|
|
|
# x86, but clang-cl.exe needs to be told when targeting non-host
|
|
|
|
# platforms. (All our builders are x86-64, so x86 is always non-host.)
|
|
|
|
cl_m32_flag = "-m32"
|
|
|
|
}
|
2018-12-10 12:51:54 +00:00
|
|
|
if (host_os == "win") {
|
2018-12-10 13:48:03 +00:00
|
|
|
cl = "\"$clang_win/bin/clang-cl.exe\""
|
|
|
|
lib = "\"$clang_win/bin/lld-link.exe\" /lib"
|
|
|
|
link = "\"$clang_win/bin/lld-link.exe\""
|
2018-12-10 12:51:54 +00:00
|
|
|
} else {
|
2018-12-10 15:10:55 +00:00
|
|
|
cl = "\"$clang_win/bin/clang-cl\""
|
|
|
|
lib = "\"$clang_win/bin/lld-link\" /lib"
|
|
|
|
link = "\"$clang_win/bin/lld-link\""
|
2018-12-10 12:51:54 +00:00
|
|
|
}
|
2017-07-31 15:57:21 +00:00
|
|
|
} else {
|
2018-12-10 13:48:03 +00:00
|
|
|
cl = "\"$bin/cl.exe\""
|
|
|
|
lib = "\"$bin/lib.exe\""
|
|
|
|
link = "\"$bin/link.exe\""
|
2017-07-31 15:57:21 +00:00
|
|
|
}
|
|
|
|
|
2017-06-29 14:03:38 +00:00
|
|
|
tool("asm") {
|
|
|
|
_ml = "ml"
|
|
|
|
if (target_cpu == "x64") {
|
|
|
|
_ml += "64"
|
|
|
|
}
|
2018-12-07 20:30:43 +00:00
|
|
|
command = "$env_setup \"$bin/$_ml.exe\" {{asmflags}} /nologo /c /Fo {{output}} {{source}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
|
|
|
|
]
|
|
|
|
description = "assemble {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("cc") {
|
|
|
|
precompiled_header_type = "msvc"
|
|
|
|
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
|
|
|
|
|
|
|
|
# Label names may have spaces so pdbname must be quoted.
|
2018-12-10 13:48:03 +00:00
|
|
|
command = "$env_setup $cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
|
2017-06-29 14:03:38 +00:00
|
|
|
depsformat = "msvc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("cxx") {
|
|
|
|
precompiled_header_type = "msvc"
|
|
|
|
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
|
|
|
|
|
|
|
|
# Label names may have spaces so pdbname must be quoted.
|
2018-12-10 13:48:03 +00:00
|
|
|
command = "$env_setup $cc_wrapper $cl /nologo /showIncludes /FC {{defines}} {{include_dirs}} {{cflags}} $cl_m32_flag {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
|
2017-06-29 14:03:38 +00:00
|
|
|
depsformat = "msvc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("alink") {
|
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
|
2018-12-10 12:51:54 +00:00
|
|
|
command = "$env_setup $lib /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
# Ignore {{output_extension}} and always use .lib, there's no reason to
|
|
|
|
# allow targets to override this extension on Windows.
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
|
|
|
default_output_extension = ".lib"
|
|
|
|
default_output_dir = "{{target_out_dir}}"
|
|
|
|
|
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
|
|
|
rspfile_content = "{{inputs_newline}}"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("solink") {
|
|
|
|
dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
|
|
|
libname = "${dllname}.lib"
|
|
|
|
pdbname = "${dllname}.pdb"
|
|
|
|
rspfile = "${dllname}.rsp"
|
|
|
|
|
2018-12-10 12:51:54 +00:00
|
|
|
command = "$env_setup $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
dllname,
|
|
|
|
libname,
|
|
|
|
pdbname,
|
|
|
|
]
|
|
|
|
default_output_extension = ".dll"
|
|
|
|
default_output_dir = "{{root_out_dir}}"
|
|
|
|
|
|
|
|
link_output = libname
|
|
|
|
depend_output = libname
|
|
|
|
runtime_outputs = [
|
|
|
|
dllname,
|
|
|
|
pdbname,
|
|
|
|
]
|
|
|
|
|
|
|
|
# I don't quite understand this. Aping Chrome's toolchain/win/BUILD.gn.
|
|
|
|
restat = true
|
|
|
|
|
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
|
|
|
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("link") {
|
|
|
|
exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
|
|
|
|
pdbname = "$exename.pdb"
|
|
|
|
rspfile = "$exename.rsp"
|
|
|
|
|
2018-12-10 12:51:54 +00:00
|
|
|
command = "$env_setup $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
|
2017-06-29 14:03:38 +00:00
|
|
|
default_output_extension = ".exe"
|
|
|
|
default_output_dir = "{{root_out_dir}}"
|
|
|
|
outputs = [
|
|
|
|
exename,
|
|
|
|
]
|
|
|
|
|
|
|
|
# inputs_newline works around a fixed per-line buffer size in the linker.
|
|
|
|
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("stamp") {
|
|
|
|
command = "$stamp {{output}}"
|
|
|
|
description = "stamp {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("copy") {
|
|
|
|
cp_py = rebase_path("../cp.py")
|
2018-06-19 14:34:32 +00:00
|
|
|
command = "python $cp_py {{source}} {{output}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
description = "copy {{source}} {{output}}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template("gcc_like_toolchain") {
|
|
|
|
toolchain(target_name) {
|
|
|
|
ar = invoker.ar
|
|
|
|
cc = invoker.cc
|
|
|
|
cxx = invoker.cxx
|
|
|
|
lib_switch = "-l"
|
|
|
|
lib_dir_switch = "-L"
|
|
|
|
|
|
|
|
tool("cc") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("cxx") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("objc") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("objcxx") {
|
|
|
|
depfile = "{{output}}.d"
|
2017-07-12 20:21:09 +00:00
|
|
|
command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "compile {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("asm") {
|
|
|
|
depfile = "{{output}}.d"
|
|
|
|
command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
|
|
|
|
depsformat = "gcc"
|
|
|
|
outputs = [
|
|
|
|
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
|
|
|
]
|
|
|
|
description = "assemble {{source}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("alink") {
|
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
rspfile_content = "{{inputs}}"
|
|
|
|
ar_py = rebase_path("../ar.py")
|
2018-06-19 14:34:32 +00:00
|
|
|
command = "python $ar_py $ar {{output}} $rspfile"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
|
|
|
default_output_extension = ".a"
|
|
|
|
output_prefix = "lib"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("solink") {
|
|
|
|
soname = "{{target_output_name}}{{output_extension}}"
|
|
|
|
|
|
|
|
rpath = "-Wl,-soname,$soname"
|
|
|
|
if (is_mac) {
|
|
|
|
rpath = "-Wl,-install_name,@rpath/$soname"
|
|
|
|
}
|
|
|
|
|
2018-02-09 19:45:09 +00:00
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
rspfile_content = "{{inputs}}"
|
2019-02-28 16:05:01 +00:00
|
|
|
|
|
|
|
# --start-group/--end-group let us link multiple .a {{inputs}}
|
|
|
|
# without worrying about their relative order on the link line.
|
|
|
|
#
|
|
|
|
# This is mostly important for traditional linkers like GNU ld and Gold.
|
|
|
|
# The Mac/iOS linker neither needs nor accepts these flags.
|
|
|
|
# LLD doesn't need these flags, but accepts and ignores them.
|
|
|
|
_start_group = "-Wl,--start-group"
|
|
|
|
_end_group = "-Wl,--end-group"
|
|
|
|
if (is_mac || is_ios) {
|
|
|
|
_start_group = ""
|
|
|
|
_end_group = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
command = "$cc_wrapper $cxx -shared {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{libs}} $rpath -o {{output}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/$soname",
|
|
|
|
]
|
|
|
|
output_prefix = "lib"
|
|
|
|
default_output_extension = ".so"
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("link") {
|
2018-02-09 19:45:09 +00:00
|
|
|
rspfile = "{{output}}.rsp"
|
|
|
|
rspfile_content = "{{inputs}}"
|
2018-08-06 19:19:19 +00:00
|
|
|
|
|
|
|
# --start-group/--end-group let us link multiple .a {{inputs}}
|
|
|
|
# without worrying about their relative order on the link line.
|
|
|
|
#
|
|
|
|
# This is mostly important for traditional linkers like GNU ld and Gold.
|
|
|
|
# The Mac/iOS linker neither needs nor accepts these flags.
|
|
|
|
# LLD doesn't need these flags, but accepts and ignores them.
|
|
|
|
_start_group = "-Wl,--start-group"
|
|
|
|
_end_group = "-Wl,--end-group"
|
|
|
|
if (is_mac || is_ios) {
|
|
|
|
_start_group = ""
|
|
|
|
_end_group = ""
|
|
|
|
}
|
|
|
|
command = "$cc_wrapper $cxx {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{libs}} -o {{output}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
outputs = [
|
|
|
|
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
|
|
|
|
]
|
|
|
|
description = "link {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("stamp") {
|
|
|
|
command = "$stamp {{output}}"
|
|
|
|
description = "stamp {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
tool("copy") {
|
|
|
|
cp_py = rebase_path("../cp.py")
|
2018-06-19 14:34:32 +00:00
|
|
|
command = "python $cp_py {{source}} {{output}}"
|
2017-06-29 14:03:38 +00:00
|
|
|
description = "copy {{source}} {{output}}"
|
|
|
|
}
|
|
|
|
|
2017-11-28 14:45:26 +00:00
|
|
|
tool("copy_bundle_data") {
|
|
|
|
cp_py = rebase_path("../cp.py")
|
2018-06-19 14:34:32 +00:00
|
|
|
command = "python $cp_py {{source}} {{output}}"
|
2017-11-28 14:45:26 +00:00
|
|
|
description = "copy_bundle_data {{source}} {{output}}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# We don't currently have any xcasset files so make this a NOP
|
|
|
|
tool("compile_xcassets") {
|
|
|
|
command = "true"
|
|
|
|
description = "compile_xcassets {{output}}"
|
|
|
|
}
|
|
|
|
|
2017-06-29 14:03:38 +00:00
|
|
|
toolchain_args = {
|
|
|
|
current_cpu = invoker.cpu
|
|
|
|
current_os = invoker.os
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gcc_like_toolchain("gcc_like") {
|
|
|
|
cpu = current_cpu
|
|
|
|
os = current_os
|
|
|
|
ar = target_ar
|
|
|
|
cc = target_cc
|
|
|
|
cxx = target_cxx
|
|
|
|
}
|
|
|
|
|
|
|
|
gcc_like_toolchain("gcc_like_host") {
|
|
|
|
cpu = host_cpu
|
|
|
|
os = host_os
|
|
|
|
ar = host_ar
|
|
|
|
cc = host_cc
|
|
|
|
cxx = host_cxx
|
|
|
|
}
|