Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1692)

Unified Diff: build/config/BUILDCONFIG.gn

Issue 1467413005: GN: Propagate top-level host_toolchain through to all toolchains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix assert Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/BUILDCONFIG.gn
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index 3eed120832f10c091058706af881c439adc0454c..ef8753b4090a2c27397c9988a9c3e767471aea67 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -50,6 +50,13 @@ if (target_cpu == "") {
}
}
+# The current_cpu and current_os variables are empty on the first
+# run through this file. When this file is evaluated again in a
+# specific toolchain context, the toolchain_args() block will have
+# set these explicitly. So them being empty is the best available
+# proxy for a "is this the first time through" predicate.
+buildconfig_in_default_toolchain = current_cpu == "" && current_os == ""
brettw 2015/12/01 22:08:19 I'm not super fond of this hack and I'd prefer to
Roland McGrath 2015/12/01 22:12:18 My concern is that when it goes wrong the failure
+
if (current_cpu == "") {
current_cpu = target_cpu
}
@@ -129,6 +136,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 +155,32 @@ 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"
- } 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"
+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.
+ assert(buildconfig_in_default_toolchain,
+ "All toolchains must plumb through host_toolchain in toolchain_args()")
+
+ if (host_os == "linux") {
+ 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/win:$target_cpu"
+ assert(false, "Unsupported host_os: $host_os")
}
-} else {
- assert(false, "Unsupported host_os: $host_os")
}
_default_toolchain = ""
@@ -200,7 +213,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"
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698