Index: build/toolchain/gcc_toolchain.gni |
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni |
index eecb409a71c35d58e5461b356139785fa1d82bba..2ac3e48b760a92d2a32234866e61d1b837b54da9 100644 |
--- a/build/toolchain/gcc_toolchain.gni |
+++ b/build/toolchain/gcc_toolchain.gni |
@@ -9,6 +9,7 @@ import("//build/config/v8_target_cpu.gni") |
import("//build/toolchain/cc_wrapper.gni") |
import("//build/toolchain/goma.gni") |
import("//build/toolchain/toolchain.gni") |
+import("//tools/grit/grit_rule.gni") |
# This template defines a toolchain for something that works like gcc |
# (including clang). |
@@ -220,23 +221,41 @@ template("gcc_toolchain") { |
object_subdir = "{{target_out_dir}}/{{label_name}}" |
tool("cc") { |
+ whitelist_flag = " " |
+ if (enable_resource_whitelist_generation) { |
+ whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\"" |
+ } |
depfile = "{{output}}.d" |
command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CC {{output}}" |
outputs = [ |
+ # The whitelist file is also an output, but ninja does not |
+ # currently support multiple outputs for tool("cc"). |
"$object_subdir/{{source_name_part}}.o", |
] |
+ compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", |
+ root_build_dir) |
+ command = "$python_path \"$compile_wrapper\"$whitelist_flag $command" |
} |
tool("cxx") { |
+ whitelist_flag = " " |
+ if (enable_resource_whitelist_generation) { |
+ whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\"" |
+ } |
depfile = "{{output}}.d" |
command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CXX {{output}}" |
outputs = [ |
+ # The whitelist file is also an output, but ninja does not |
+ # currently support multiple outputs for tool("cxx"). |
"$object_subdir/{{source_name_part}}.o", |
] |
+ compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", |
+ root_build_dir) |
+ command = "$python_path \"$compile_wrapper\"$whitelist_flag $command" |
} |
tool("asm") { |
@@ -252,13 +271,17 @@ template("gcc_toolchain") { |
tool("alink") { |
rspfile = "{{output}}.rsp" |
+ whitelist_flag = " " |
+ if (enable_resource_whitelist_generation) { |
+ whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\"" |
+ } |
# This needs a Python script to avoid using simple sh features in this |
# command, in case the host does not use a POSIX shell (e.g. compiling |
# POSIX-like toolchains such as NaCl on Windows). |
ar_wrapper = |
rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
- command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\"" |
+ command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\"" |
description = "AR {{output}}" |
rspfile_content = "{{inputs}}" |
outputs = [ |
@@ -277,6 +300,11 @@ template("gcc_toolchain") { |
sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. |
rspfile = sofile + ".rsp" |
pool = "//build/toolchain:link_pool($default_toolchain)" |
+ whitelist_flag = " " |
+ if (enable_resource_whitelist_generation) { |
+ whitelist_file = "$sofile.whitelist" |
+ whitelist_flag = " --resource-whitelist=\"$whitelist_file\"" |
+ } |
if (defined(invoker.strip)) { |
unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
@@ -303,7 +331,7 @@ template("gcc_toolchain") { |
# requiring sh control structures, pipelines, and POSIX utilities. |
# The host might not have a POSIX shell and utilities (e.g. Windows). |
solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") |
- command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --output=\"$sofile\" -- $link_command" |
+ command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --output=\"$sofile\"$whitelist_flag -- $link_command" |
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
@@ -332,6 +360,9 @@ template("gcc_toolchain") { |
sofile, |
tocfile, |
] |
+ if (enable_resource_whitelist_generation) { |
+ outputs += [ whitelist_file ] |
+ } |
if (sofile != unstripped_sofile) { |
outputs += [ unstripped_sofile ] |
} |