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

Unified Diff: build/toolchain/mac/BUILD.gn

Issue 2219953002: Use new toolchain_args variable in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toolchain_args
Patch Set: v8 Created 4 years, 4 months 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
Index: build/toolchain/mac/BUILD.gn
diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
index dea16ebbcabc9158125d2175cd8ea41d5cb1e0b3..b2524e61b0b03b4f6bc053a45ee319046a0bba7b 100644
--- a/build/toolchain/mac/BUILD.gn
+++ b/build/toolchain/mac/BUILD.gn
@@ -61,37 +61,67 @@ tool_versions =
# Work around for unused variable warning in template https://crbug.com/395883.
assert(tool_versions != "")
-# Shared toolchain definition. Invocations should set toolchain_os to set the
+# Shared toolchain definition. Invocations should set current_os to set the
# build args in this definition.
template("mac_toolchain") {
toolchain(target_name) {
- assert(defined(invoker.toolchain_cpu),
- "mac_toolchain() must specify a \"toolchain_cpu\"")
- assert(defined(invoker.toolchain_os),
- "mac_toolchain() must specify a \"toolchain_os\"")
-
- if (use_goma) {
- assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.")
- _compiler_prefix = "$goma_dir/gomacc "
- } else if (cc_wrapper != "") {
- _compiler_prefix = cc_wrapper + " "
+ # When invoking this toolchain not as the default one, these args will be
+ # passed to the build. They are ignored when this is the default toolchain.
+ toolchain_args = {
+ # Populate toolchain args from the invoker.
+ if (defined(invoker.toolchain_args)) {
+ forward_variables_from(invoker.toolchain_args, "*")
+ }
+
+ # These values need to be passed through unchanged to all secondary
+ # toolchains. BUILDCONFIG.gn sets some defaults based on the values of
+ # the operating system and compiler, and we want to force the values to
+ # be consistent if re-running the computation in another context leads
+ # to different defaults.
+ host_toolchain = host_toolchain
+ target_os = target_os
+ target_cpu = target_cpu
+ }
+
+ # When the invoker has explicitly overridden use_goma or cc_wrapper in the
+ # toolchain args, use those values, otherwise default to the global one.
+ # This works because the only reasonable override that toolchains might
+ # supply for these values are to force-disable them.
+ if (defined(toolchain_args.use_goma)) {
+ toolchain_uses_goma = toolchain_args.use_goma
+ } else {
+ toolchain_uses_goma = use_goma
+ }
+ if (defined(toolchain_args.cc_wrapper)) {
+ toolchain_cc_wrapper = toolchain_args.cc_wrapper
+ } else {
+ toolchain_cc_wrapper = cc_wrapper
+ }
+
+ # Compute the compiler prefix.
+ if (toolchain_uses_goma) {
+ assert(toolchain_cc_wrapper == "",
+ "Goma and cc_wrapper can't be used together.")
+ compiler_prefix = "$goma_dir/gomacc "
+ } else if (toolchain_cc_wrapper != "") {
+ compiler_prefix = toolchain_cc_wrapper + " "
} else {
- _compiler_prefix = ""
+ compiler_prefix = ""
}
- if (invoker.toolchain_os != "ios" || !use_xcode_clang) {
- _compiler_prefix += rebase_path("$clang_base_path/bin/", root_build_dir)
+ if (toolchain_args.current_os != "ios" || !use_xcode_clang) {
+ compiler_prefix += rebase_path("$clang_base_path/bin/", root_build_dir)
}
- cc = "${_compiler_prefix}clang"
- cxx = "${_compiler_prefix}clang++"
+ cc = "${compiler_prefix}clang"
+ cxx = "${compiler_prefix}clang++"
ld = cxx
linker_driver =
"TOOL_VERSION=${tool_versions.linker_driver} " +
rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir)
- if (invoker.toolchain_os == "ios" && additional_toolchains != []) {
+ if (toolchain_args.current_os == "ios" && additional_toolchains != []) {
# For a fat build, the generation of dSYM needs to be performed after the
# generation of the fat binaries using "lipo". So disable the generation
# of the dSYM for intermediate architecture specific binaries.
@@ -378,48 +408,49 @@ template("mac_toolchain") {
description = "COMPILE_XCASSETS {{output}}"
pool = ":bundle_pool($default_toolchain)"
}
-
- toolchain_args() {
- current_cpu = invoker.toolchain_cpu
- 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
- is_clang = true
- }
}
}
mac_toolchain("clang_arm") {
- toolchain_cpu = "arm"
- toolchain_os = "mac"
+ toolchain_args = {
+ current_cpu = "arm"
+ current_os = "mac"
+ }
}
mac_toolchain("clang_x64") {
- toolchain_cpu = "x64"
- toolchain_os = "mac"
+ toolchain_args = {
+ current_cpu = "x64"
+ current_os = "mac"
+ }
}
if (is_ios) {
mac_toolchain("ios_clang_arm") {
- toolchain_cpu = "arm"
- toolchain_os = "ios"
+ toolchain_args = {
+ current_cpu = "arm"
+ current_os = "ios"
+ }
}
mac_toolchain("ios_clang_arm64") {
- toolchain_cpu = "arm64"
- toolchain_os = "ios"
+ toolchain_args = {
+ current_cpu = "arm64"
+ current_os = "ios"
+ }
}
mac_toolchain("ios_clang_x86") {
- toolchain_cpu = "x86"
- toolchain_os = "ios"
+ toolchain_args = {
+ current_cpu = "x86"
+ current_os = "ios"
+ }
}
mac_toolchain("ios_clang_x64") {
- toolchain_cpu = "x64"
- toolchain_os = "ios"
+ toolchain_args = {
+ current_cpu = "x64"
+ current_os = "ios"
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698