Index: build/toolchain/gcc_toolchain.gni |
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni |
index ae9599a461c16c4dde930746eb5861609c00ca32..e2cbe1c4192dccd939e6510f58f616805e18105a 100644 |
--- a/build/toolchain/gcc_toolchain.gni |
+++ b/build/toolchain/gcc_toolchain.gni |
@@ -42,14 +42,19 @@ template("gcc_toolchain") { |
assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") |
assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") |
assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") |
- assert(defined(invoker.readelf), |
- "gcc_toolchain() must specify a \"readelf\" value") |
- assert(defined(invoker.nm), "gcc_toolchain() must specify a \"nm\" value") |
assert(defined(invoker.toolchain_cpu), |
"gcc_toolchain() must specify a \"toolchain_cpu\"") |
assert(defined(invoker.toolchain_os), |
"gcc_toolchain() must specify a \"toolchain_os\"") |
+ # This define changes when the toolchain changes, forcing a rebuild. |
+ # Nothing should ever use this define. |
+ if (defined(invoker.rebuild_define)) { |
+ rebuild_string = "-D" + invoker.rebuild_define + " " |
+ } else { |
+ rebuild_string = "" |
+ } |
+ |
# We can't do string interpolation ($ in strings) on things with dots in |
# them. To allow us to use $cc below, for example, we create copies of |
# these values in our scope. |
@@ -57,8 +62,22 @@ template("gcc_toolchain") { |
cxx = invoker.cxx |
ar = invoker.ar |
ld = invoker.ld |
- readelf = invoker.readelf |
- nm = invoker.nm |
+ if (defined(invoker.readelf)) { |
+ readelf = invoker.readelf |
+ } else { |
+ readelf = "readelf" |
+ } |
+ if (defined(invoker.nm)) { |
+ nm = invoker.nm |
+ } else { |
+ nm = "nm" |
+ } |
+ |
+ if (defined(invoker.executable_extension)) { |
+ default_executable_extension = invoker.executable_extension |
+ } else { |
+ default_executable_extension = "" |
+ } |
# Bring these into our scope for string interpolation with default values. |
if (defined(invoker.libs_section_prefix)) { |
@@ -91,7 +110,7 @@ template("gcc_toolchain") { |
tool("cc") { |
depfile = "{{output}}.d" |
- command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
+ command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CC {{output}}" |
outputs = [ |
@@ -101,7 +120,7 @@ template("gcc_toolchain") { |
tool("cxx") { |
depfile = "{{output}}.d" |
- command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
+ command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CXX {{output}}" |
outputs = [ |
@@ -112,7 +131,7 @@ template("gcc_toolchain") { |
tool("asm") { |
# For GCC we can just use the C compiler to compile assembly. |
depfile = "{{output}}.d" |
- command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
+ command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "ASM {{output}}" |
outputs = [ |
@@ -185,6 +204,9 @@ template("gcc_toolchain") { |
outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
rspfile = "$outfile.rsp" |
command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
+ |
+ default_output_extension = default_executable_extension |
+ |
if (defined(invoker.postlink)) { |
command += " && " + invoker.postlink |
} |
@@ -218,13 +240,13 @@ template("gcc_toolchain") { |
target_os = target_os |
target_cpu = target_cpu |
- if (defined(invoker.is_clang)) { |
- is_clang = invoker.is_clang |
- } |
+ forward_variables_from(invoker, |
+ [ |
+ "is_clang", |
+ "is_component_build", |
+ ]) |
} |
- if (defined(invoker.deps)) { |
- deps = invoker.deps |
- } |
+ forward_variables_from(invoker, [ "deps" ]) |
} |
} |