GN: Propagate top-level host_toolchain through to all toolchains

The logic to choose host_toolchain depends on variables like
is_clang that might be overridden in toolchain_args() as well as
set as a build argument by the user.  Only the top-level build
arguments should affect the host_toolchain value, not anything
set in some toolchain's toolchain_args() block.  To achieve this,
set host_toolchain once at top level and then make each toolchain
propagate that value down in its toolchain_args() block.

BUG= 512869
R=dpranke@chromium.org

Review URL: https://codereview.chromium.org/1467413005

Cr-Original-Commit-Position: refs/heads/master@{#362758}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e393ea6912a747e8c340fc5a53f2be45028d70c1
This commit is contained in:
mcgrathr 2015-12-02 10:52:18 -08:00 коммит произвёл Commit bot
Родитель 5b08a08671
Коммит 6b6e368a32
4 изменённых файлов: 40 добавлений и 23 удалений

Просмотреть файл

@ -129,6 +129,10 @@ declare_args() {
# argument, and set as the default toolchain.
custom_toolchain = ""
# This should not normally be set as a build argument. It's here so that
# every toolchain can pass through the "global" value via toolchain_args().
host_toolchain = ""
# DON'T ADD MORE FLAGS HERE. Read the comment above.
}
@ -144,30 +148,38 @@ declare_args() {
# We do this before anything else to make sure we complain about any
# unsupported os/cpu combinations as early as possible.
if (host_os == "linux") {
if (target_os != "linux") {
# TODO(dpranke) - is_clang normally applies only to the target
# build, and there is no way to indicate that you want to override
# it for both the target build *and* the host build. Do we need to
# support this?
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
} else if (is_clang) {
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
if (host_toolchain == "") {
# This should only happen in the top-level context.
# In a specific toolchain context, the toolchain_args()
# block should have propagated a value down.
# TODO(dpranke): Add some sort of assert here that verifies that
# no toolchain omitted host_toolchain from its toolchain_args().
if (host_os == "linux") {
if (target_os != "linux") {
# TODO(dpranke) - is_clang normally applies only to the target
# build, and there is no way to indicate that you want to override
# it for both the target build *and* the host build. Do we need to
# support this?
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
} else if (is_clang) {
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
} else {
host_toolchain = "//build/toolchain/linux:$host_cpu"
}
} else if (host_os == "mac") {
host_toolchain = "//build/toolchain/mac:clang_$host_cpu"
} else if (host_os == "win") {
# TODO(crbug.com/467159): win cross-compiles don't actually work yet, so
# use the target_cpu instead of the host_cpu.
if (is_clang) {
host_toolchain = "//build/toolchain/win:clang_$target_cpu"
} else {
host_toolchain = "//build/toolchain/win:$target_cpu"
}
} else {
host_toolchain = "//build/toolchain/linux:$host_cpu"
assert(false, "Unsupported host_os: $host_os")
}
} else if (host_os == "mac") {
host_toolchain = "//build/toolchain/mac:clang_$host_cpu"
} else if (host_os == "win") {
# TODO(crbug.com/467159): win cross-compiles don't actually work yet, so
# use the target_cpu instead of the host_cpu.
if (is_clang) {
host_toolchain = "//build/toolchain/win:clang_$target_cpu"
} else {
host_toolchain = "//build/toolchain/win:$target_cpu"
}
} else {
assert(false, "Unsupported host_os: $host_os")
}
_default_toolchain = ""
@ -200,7 +212,7 @@ if (target_os == "android") {
assert(host_os == "mac", "Mac cross-compiles are unsupported.")
_default_toolchain = host_toolchain
} else if (target_os == "win") {
# On windows we use the same toolchain for host and target by default.
# On Windows we use the same toolchain for host and target by default.
assert(target_os == host_os, "Win cross-compiles only work on win hosts.")
if (is_clang) {
_default_toolchain = "//build/toolchain/win:clang_$target_cpu"

Просмотреть файл

@ -387,6 +387,7 @@ template("gcc_toolchain") {
current_os = invoker.toolchain_os
# These values need to be passed through unchanged.
host_toolchain = host_toolchain
target_os = target_os
target_cpu = target_cpu

Просмотреть файл

@ -237,6 +237,7 @@ template("mac_toolchain") {
current_os = invoker.toolchain_os
# These values need to be passed through unchanged.
host_toolchain = host_toolchain
target_os = target_os
target_cpu = target_cpu

Просмотреть файл

@ -220,6 +220,9 @@ template("msvc_toolchain") {
is_clang = invoker.is_clang
}
current_os = invoker.current_os
# This value needs to be passed through unchanged.
host_toolchain = host_toolchain
}
}
}