Commit a3727f9e authored by Dirk Pranke's avatar Dirk Pranke Committed by Commit Bot

set compute_grit_inputs_for_analyze=True in the analyze step.

Normally when grit actions are defined during `gn gen`, we don't
include all of the files that the .grd file depends on as inputs,
because we don't need to; grit generates a .d file for dependencies
so that rebuilds will happen correctly. And, computing the 
dependencies is slow (it's equivalent to calling grit).

However, if we don't include the dependencies in the gn build graph,
then `analyze` doesn't know about them, and hence a change to a file
that grit dependencies on will be ignored.

This CL changes things such that when `gn gen` is being run as part
of the `analyze` step, we do set the extra flag to compute the
dependencies. This'll slow GN down, but that's better than 
misreporting dependencies.

In some cases, the .grd files try to include generated files
(which may not exist at GN time). To work around this, you can
mark the grit targets as `source_is_generated = true`; the
downside of that is that that target will be skipped just as if
compute_grit_inputs_for_analyze=False, however, this is still an
improvement over not checking *any* of the grit targets. A better
fix would be to have grit_info ignore any paths in the generated
directory if they don't exist, and I'll try to do that in a 
follow-up patch.

R=brettw@chromium.org
BUG=639328

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I9f6702b06f8a41a159e4599bf192db0abf9e77eb
Reviewed-on: https://chromium-review.googlesource.com/545150
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487135}
parent 3f8a63c8
...@@ -261,6 +261,9 @@ grit("generate_aw_strings") { ...@@ -261,6 +261,9 @@ grit("generate_aw_strings") {
grit("generate_webui_resources") { grit("generate_webui_resources") {
source = "../ui/webui/resources/webui_resources.grd" source = "../ui/webui/resources/webui_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
# webui/resources has way too many resources. The whitelist is trim this down # webui/resources has way too many resources. The whitelist is trim this down
# to a reasonable size # to a reasonable size
whitelist = rebase_path("ui/grit_resources_whitelist.txt") whitelist = rebase_path("ui/grit_resources_whitelist.txt")
...@@ -282,6 +285,9 @@ grit("generate_webui_resources") { ...@@ -282,6 +285,9 @@ grit("generate_webui_resources") {
grit("generate_components_resources") { grit("generate_components_resources") {
source = "../components/resources/components_resources.grd" source = "../components/resources/components_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
# See :generate_webui_resources for an explanation of the whitelist # See :generate_webui_resources for an explanation of the whitelist
whitelist = rebase_path("ui/grit_resources_whitelist.txt") whitelist = rebase_path("ui/grit_resources_whitelist.txt")
inputs = [ inputs = [
...@@ -295,6 +301,10 @@ grit("generate_components_resources") { ...@@ -295,6 +301,10 @@ grit("generate_components_resources") {
"grit/components_resources.h", "grit/components_resources.h",
"components_resources.pak", "components_resources.pak",
] ]
deps = [
"//components/resources:components_resources",
]
} }
grit("generate_components_strings") { grit("generate_components_strings") {
......
...@@ -4244,6 +4244,9 @@ proto_library("resource_prefetch_predictor_proto") { ...@@ -4244,6 +4244,9 @@ proto_library("resource_prefetch_predictor_proto") {
grit("resources") { grit("resources") {
source = "browser_resources.grd" source = "browser_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
defines = chrome_grit_defines defines = chrome_grit_defines
if (enable_hangout_services_extension) { if (enable_hangout_services_extension) {
defines += [ "enable_hangout_services_extension" ] defines += [ "enable_hangout_services_extension" ]
......
...@@ -109,6 +109,10 @@ if (!is_android) { ...@@ -109,6 +109,10 @@ if (!is_android) {
grit("settings_resources") { grit("settings_resources") {
if (use_vulcanize) { if (use_vulcanize) {
source = "settings/settings_resources_vulcanized.grd" source = "settings/settings_resources_vulcanized.grd"
# The .grd contains references to generated files.
source_is_generated = true
deps = [ deps = [
"//chrome/browser/resources/settings:build", "//chrome/browser/resources/settings:build",
] ]
......
...@@ -61,6 +61,10 @@ polymer_css_build("build") { ...@@ -61,6 +61,10 @@ polymer_css_build("build") {
grit("flattened_resources") { grit("flattened_resources") {
source = "settings_resources.grd" source = "settings_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
defines = chrome_grit_defines defines = chrome_grit_defines
outputs = [ outputs = [
"grit/settings_resources.h", "grit/settings_resources.h",
......
...@@ -113,6 +113,10 @@ if (is_component_build) { ...@@ -113,6 +113,10 @@ if (is_component_build) {
grit("resources") { grit("resources") {
source = "content_resources.grd" source = "content_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
outputs = [ outputs = [
"grit/content_resources.h", "grit/content_resources.h",
"content_resources.pak", "content_resources.pak",
......
...@@ -890,6 +890,10 @@ js_compile_checked("js_resources") { ...@@ -890,6 +890,10 @@ js_compile_checked("js_resources") {
grit("resources") { grit("resources") {
source = "ios_web_resources.grd" source = "ios_web_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
outputs = [ outputs = [
"grit/ios_web_resources.h", "grit/ios_web_resources.h",
"ios_web_resources.pak", "ios_web_resources.pak",
......
...@@ -50,6 +50,10 @@ service_manifest("shell_browser_manifest_overlay") { ...@@ -50,6 +50,10 @@ service_manifest("shell_browser_manifest_overlay") {
grit("resources") { grit("resources") {
visibility = [ ":*" ] visibility = [ ":*" ]
source = "shell_resources.grd" source = "shell_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
grit_flags = [ grit_flags = [
"-E", "-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
......
...@@ -28,6 +28,10 @@ repack("packed_resources") { ...@@ -28,6 +28,10 @@ repack("packed_resources") {
grit("resources") { grit("resources") {
source = "test_resources.grd" source = "test_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
inputs = [ inputs = [
"${root_gen_dir}/ios/web/test/mojo_test.mojom.js", "${root_gen_dir}/ios/web/test/mojo_test.mojom.js",
] ]
......
...@@ -117,6 +117,7 @@ def DoMain(argv): ...@@ -117,6 +117,7 @@ def DoMain(argv):
# grit build also supports '-E KEY=VALUE', support that to share command # grit build also supports '-E KEY=VALUE', support that to share command
# line flags. # line flags.
parser.add_option("-E", action="append", dest="build_env", default=[]) parser.add_option("-E", action="append", dest="build_env", default=[])
parser.add_option("-p", action="store", dest="predetermined_ids_file")
parser.add_option("-w", action="append", dest="whitelist_files", default=[]) parser.add_option("-w", action="append", dest="whitelist_files", default=[])
parser.add_option("--output-all-resource-defines", action="store_true", parser.add_option("--output-all-resource-defines", action="store_true",
dest="output_all_resource_defines", default=True, dest="output_all_resource_defines", default=True,
......
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
# Path to .grd file. # Path to .grd file.
# #
# source_is_generated (optional, defaults to false) # source_is_generated (optional, defaults to false)
# Declares that the input is generated so that grit_info is not run # Declares that the input (or one of its dependencies) is generated so
# on the file when compute_grit_inputs_for_analyze is set (because the # that grit_info is not run on the file when
# file will not exist at analyze time). For "analyze" to be correct in # compute_grit_inputs_for_analyze is set (because the file will not
# this case, the inputs to the grit file must either be listed in the # exist at analyze time). For "analyze" to be correct in this case, the
# inputs variable or are listed as inputs to dependencies of this target. # inputs to the grit file must either be listed in the inputs variable
# or are listed as inputs to dependencies of this target.
# #
# inputs (optional) # inputs (optional)
# List of additional files, required for grit to process source file. # List of additional files, required for grit to process source file.
......
...@@ -806,11 +806,13 @@ class MetaBuildWrapper(object): ...@@ -806,11 +806,13 @@ class MetaBuildWrapper(object):
self.MaybeMakeDirectory(build_dir) self.MaybeMakeDirectory(build_dir)
self.WriteFile(mb_type_path, new_mb_type) self.WriteFile(mb_type_path, new_mb_type)
def RunGNGen(self, vals): def RunGNGen(self, vals, compute_grit_inputs_for_analyze=False):
build_dir = self.args.path[0] build_dir = self.args.path[0]
cmd = self.GNCmd('gen', build_dir, '--check') cmd = self.GNCmd('gen', build_dir, '--check')
gn_args = self.GNArgs(vals) gn_args = self.GNArgs(vals)
if compute_grit_inputs_for_analyze:
gn_args += ' compute_grit_inputs_for_analyze=true'
# Since GN hasn't run yet, the build directory may not even exist. # Since GN hasn't run yet, the build directory may not even exist.
self.MaybeMakeDirectory(self.ToAbsPath(build_dir)) self.MaybeMakeDirectory(self.ToAbsPath(build_dir))
...@@ -1233,7 +1235,7 @@ class MetaBuildWrapper(object): ...@@ -1233,7 +1235,7 @@ class MetaBuildWrapper(object):
def RunGNAnalyze(self, vals): def RunGNAnalyze(self, vals):
# Analyze runs before 'gn gen' now, so we need to run gn gen # Analyze runs before 'gn gen' now, so we need to run gn gen
# in order to ensure that we have a build directory. # in order to ensure that we have a build directory.
ret = self.RunGNGen(vals) ret = self.RunGNGen(vals, compute_grit_inputs_for_analyze=True)
if ret: if ret:
return ret return ret
......
...@@ -35,6 +35,10 @@ grit("ui_unscaled_resources_grd") { ...@@ -35,6 +35,10 @@ grit("ui_unscaled_resources_grd") {
grit("webui_resources_grd") { grit("webui_resources_grd") {
source = "../webui/resources/webui_resources.grd" source = "../webui/resources/webui_resources.grd"
# The .grd contains references to generated files.
source_is_generated = true
outputs = [ outputs = [
"grit/webui_resources.h", "grit/webui_resources.h",
"grit/webui_resources_map.cc", "grit/webui_resources_map.cc",
......
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