Commit 6057878f authored by brettw@chromium.org's avatar brettw@chromium.org

Allow the grit GN targets to specify an output name.

This resolves collisions if two grit targets with the same name (often
"resources") end up in the same output directory.

This reverts 289283 and replaces it with the unique output names rather than
the duplicative target names. The original problem was from 289264.

BUG=
R=joaodasilva@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#289691}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289691 0039d316-1c4b-4281-b951-d872f2087c98
parent ce2ea780
......@@ -34,15 +34,24 @@
# List of strings containing extra command-line flags to pass to Grit.
#
# resource_ids (optional)
# Path to a grit "firstidsfile". Default is
# //tools/gritsettings/resource_ids. Set to "" to use the value specified in
# the <grit> nodes of the processed files.
# Path to a grit "firstidsfile". Default is
# //tools/gritsettings/resource_ids. Set to "" to use the value specified
# in the <grit> nodes of the processed files.
#
# output_dir (optional)
# Directory for generated files.
# Directory for generated files. If you specify this, you will often
# want to specify output_name if the target name is not particularly
# unique, since this can cause files from multiple grit targets to
# overwrite each other.
#
# output_name (optiona)
# Provide an alternate base name for the generated files, like the .d
# files. Normally these are based on the target name and go in the
# output_dir, but if multiple targets with the same name end up in
# the same output_dir, they can collide.
#
# use_qualified_include (optional)
# If set, output_dir is not added to include_dirs.
# If set, output_dir is not added to include_dirs.
#
# deps (optional)
# visibility (optional)
......@@ -207,6 +216,12 @@ template("grit") {
output_dir = target_gen_dir
}
if (defined(invoker.output_name)) {
grit_output_name = invoker.output_name
} else {
grit_output_name = target_name
}
# These are all passed as arguments to the script so have to be relative to
# the build directory.
if (resource_ids != "") {
......@@ -229,7 +244,8 @@ template("grit") {
# writing. We write the list to a file (some of the output lists are long
# enough to not fit on a Windows command line) and ask Grit to verify those
# are the actual outputs at runtime.
asserted_list_file = "$target_out_dir/${target_name}_expected_outputs.txt"
asserted_list_file =
"$target_out_dir/${grit_output_name}_expected_outputs.txt"
write_file(asserted_list_file,
rebase_path(invoker.outputs, root_build_dir, output_dir))
assert_files_flags += [
......@@ -241,7 +257,7 @@ template("grit") {
# The config and the action below get this visibility son only the generated
# source set can depend on them. The variable "target_name" will get
# overwritten inside the innter classes so we need to compute it here.
# overwritten inside the inner classes so we need to compute it here.
target_visibility = ":$target_name"
# The current grit setup makes an file in $output_dir/grit/foo.h that
......@@ -262,7 +278,7 @@ template("grit") {
script = "//tools/grit/grit.py"
inputs = grit_inputs
outputs = grit_outputs
depfile = "$output_dir/${target_name}.d"
depfile = "$output_dir/${grit_output_name}.d"
args = [
"-i", source_path, "build",
......@@ -304,8 +320,6 @@ template("grit") {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
if (defined(invoker.output_name)) {
output_name = invoker.output_name
}
output_name = grit_output_name
}
}
......@@ -11,8 +11,8 @@ group("resources") {
# these are just dependencies for the actions themselves, which our actions
# list individually when needed.
"//chrome/browser:resources",
"//chrome/common:common_resources",
"//chrome/renderer:renderer_resources",
"//chrome/common:resources",
"//chrome/renderer:resources",
]
if (enable_extensions) {
......
......@@ -12,9 +12,10 @@ gypi_values = exec_script(
# GYP version: chrome/chrome_resources.gyp:chrome_resources
# (generate_common_resources action)
grit("common_resources") {
grit("resources") {
source = "common_resources.grd"
output_dir = "$root_gen_dir/chrome"
output_name = "common_resources"
outputs = [
"grit/common_resources.h",
"common_resources.pak",
......
......@@ -13,9 +13,10 @@ gypi_values = exec_script(
# GYP version: chrome/chrome_resources.gyp:chrome_resources
# (generate_renderer_resources action)
grit("renderer_resources") {
grit("resources") {
source = "resources/renderer_resources.grd"
output_dir = "$root_gen_dir/chrome"
output_name = "renderer_resources"
outputs = [
"grit/renderer_resources.h",
"renderer_resources_100_percent.pak",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment