summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbradnelson@chromium.org <bradnelson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 20:08:47 +0000
committerbradnelson@chromium.org <bradnelson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 20:08:47 +0000
commit2ab24f976efe9f0c167afbf444177b860a2bb82f (patch)
treecd9a190154b0903193f04950f4942146ba2089f5
parent530f43f302f1eef9d3530767015891f1db1f1272 (diff)
downloadchromium_src-2ab24f976efe9f0c167afbf444177b860a2bb82f.zip
chromium_src-2ab24f976efe9f0c167afbf444177b860a2bb82f.tar.gz
chromium_src-2ab24f976efe9f0c167afbf444177b860a2bb82f.tar.bz2
Altering grit so that it clobbers all outputs even on windows.
Previously headers were handled differently only as an optimization. This thwarts vstudio + gyp. Adding a grit_info python stub so that gyp can get an accurate list of inputs and outputs from a grd file. Currently only using it for the inputs, because there's no good way in gyp to have rules invoke a !@( expansion once per rule instance. This change will over-specify dependencies for these modules, but it will at least not under-specify them anymore. BUG=24836 TEST=None Review URL: http://codereview.chromium.org/197007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25499 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome.gyp74
-rw-r--r--tools/grit/grit/tool/build.py15
-rwxr-xr-xtools/grit/grit_info.py90
3 files changed, 150 insertions, 29 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index a5e1440..f12a88c 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -34,6 +34,20 @@
'ru', 'sk', 'sl', 'sr', 'sv', 'ta', 'te', 'th', 'tr',
'uk', 'vi', 'zh-CN', 'zh-TW',
],
+ 'chrome_strings_grds': [
+ # Localizable resources.
+ 'app/resources/locale_settings.grd',
+ 'app/chromium_strings.grd',
+ 'app/generated_resources.grd',
+ 'app/google_chrome_strings.grd',
+ ],
+ 'chrome_resources_grds': [
+ # Data resources.
+ 'browser/browser_resources.grd',
+ 'common/common_resources.grd',
+ 'renderer/renderer_resources.grd',
+ ],
+ 'grit_info_cmd': ['python', '../tools/grit/grit_info.py',],
'repack_locales_cmd': ['python', 'tools/build/repack_locales.py',],
# TODO: remove this helper when we have loops in GYP
'apply_locales_cmd': ['python', 'tools/build/apply_locales.py',],
@@ -167,6 +181,11 @@
'target_name': 'chrome_resources',
'type': 'none',
'msvs_guid': 'B95AB527-F7DB-41E9-AD91-EB51EE0F56BE',
+ 'variables': {
+ 'chrome_resources_inputs': [
+ '<!@(<(grit_info_cmd) --inputs <(chrome_resources_grds))',
+ ],
+ },
'rules': [
{
'rule_name': 'grit',
@@ -186,13 +205,22 @@
],
},
'inputs': [
- '../tools/grit/grit.py',
+ '<@(chrome_resources_inputs)',
],
'outputs': [
'<(grit_out_dir)/grit/<(RULE_INPUT_ROOT).h',
'<(grit_out_dir)/<(RULE_INPUT_ROOT).pak',
- ],
- 'action': ['python', '<@(_inputs)', '-i', '<(RULE_INPUT_PATH)',
+ # TODO(bradnelson): move to something like this instead
+ #'<!@(<(grit_info_cmd) --outputs \'<(grit_out_dir)\' <(chrome_resources_grds))',
+ # This currently cannot work because gyp only evaluates the
+ # outputs once (rather than per case where the rule applies).
+ # This means you end up with all the outputs from all the grd
+ # files, which angers scons and confuses vstudio.
+ # One alternative would be to turn this into several actions,
+ # but that would be rather verbose.
+ ],
+ 'action': ['python', '../tools/grit/grit.py', '-i',
+ '<(RULE_INPUT_PATH)',
'build', '-o', '<(grit_out_dir)',
'-D', '<(chrome_build)',
'-E', '<(branded_env)',
@@ -201,10 +229,8 @@
},
],
'sources': [
- # Data resources.
- 'browser/browser_resources.grd',
- 'common/common_resources.grd',
- 'renderer/renderer_resources.grd',
+ '<@(chrome_resources_grds)',
+ '<@(chrome_resources_inputs)',
],
'direct_dependent_settings': {
'include_dirs': [
@@ -239,6 +265,11 @@
'type': 'none',
}],
],
+ 'variables': {
+ 'chrome_strings_inputs': [
+ '<!@(<(grit_info_cmd) --inputs <(chrome_strings_grds))',
+ ],
+ },
'rules': [
{
'rule_name': 'grit',
@@ -256,16 +287,20 @@
],
},
'inputs': [
- '../tools/grit/grit.py',
+ '<@(chrome_strings_inputs)',
],
'outputs': [
'<(grit_out_dir)/grit/<(RULE_INPUT_ROOT).h',
# TODO: remove this helper when we have loops in GYP
'>!@(<(apply_locales_cmd) \'<(grit_out_dir)/<(RULE_INPUT_ROOT)_ZZLOCALE.pak\' <(locales))',
- ],
- 'action': ['python', '<@(_inputs)', '-i', '<(RULE_INPUT_PATH)',
- 'build', '-o', '<(grit_out_dir)',
- '-D', '<(chrome_build)'],
+ # TODO(bradnelson): move to something like this
+ #'<!@(<(grit_info_cmd) --outputs \'<(grit_out_dir)\' <(chrome_strings_grds))',
+ # See comment in chrome_resources as to why.
+ ],
+ 'action': ['python', '../tools/grit/grit.py', '-i',
+ '<(RULE_INPUT_PATH)',
+ 'build', '-o', '<(grit_out_dir)',
+ '-D', '<(chrome_build)'],
'conditions': [
['chromeos==1', {
'action': ['-D', 'chromeos'],
@@ -275,11 +310,8 @@
},
],
'sources': [
- # Localizable resources.
- 'app/resources/locale_settings.grd',
- 'app/chromium_strings.grd',
- 'app/generated_resources.grd',
- 'app/google_chrome_strings.grd',
+ '<@(chrome_strings_grds)',
+ '<@(chrome_strings_inputs)',
],
'direct_dependent_settings': {
'include_dirs': [
@@ -312,14 +344,10 @@
],
},
'inputs': [
- '<(input_path)',
+ '<!@(<(grit_info_cmd) --inputs <(input_path))',
],
'outputs': [
- '<(grit_out_dir)/grit/theme_resources.h',
- '<(grit_out_dir)/grit/theme_resources_map.cc',
- '<(grit_out_dir)/grit/theme_resources_map.h',
- '<(grit_out_dir)/theme_resources.pak',
- '<(grit_out_dir)/theme_resources.rc',
+ '<!@(<(grit_info_cmd) --outputs \'<(grit_out_dir)\' <(input_path))',
],
'action': [
'python', '<(grit_path)',
diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py
index e750b9b..1ba1b59 100644
--- a/tools/grit/grit/tool/build.py
+++ b/tools/grit/grit/tool/build.py
@@ -208,12 +208,15 @@ are exported to translation interchange files (e.g. XMB files), etc.
os.rename(output.GetOutputFilename() + '.tmp',
output.GetOutputFilename())
else:
- files_match = filecmp.cmp(output.GetOutputFilename(),
- output.GetOutputFilename() + '.tmp')
- if (output.GetType() != 'rc_header' or not files_match
- or sys.platform != 'win32'):
- shutil.copy2(output.GetOutputFilename() + '.tmp',
- output.GetOutputFilename())
+ # CHROMIUM SPECIFIC CHANGE.
+ # This clashes with gyp + vstudio, which expect the output timestamp
+ # to change on a rebuild, even if nothing has changed.
+ #files_match = filecmp.cmp(output.GetOutputFilename(),
+ # output.GetOutputFilename() + '.tmp')
+ #if (output.GetType() != 'rc_header' or not files_match
+ # or sys.platform != 'win32'):
+ shutil.copy2(output.GetOutputFilename() + '.tmp',
+ output.GetOutputFilename())
os.remove(output.GetOutputFilename() + '.tmp')
self.VerboseOut(' done.\n')
diff --git a/tools/grit/grit_info.py b/tools/grit/grit_info.py
new file mode 100755
index 0000000..116ace0
--- /dev/null
+++ b/tools/grit/grit_info.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''Tool to determine inputs and outputs of a grit file.
+'''
+
+import os
+import posixpath
+import types
+import sys
+from grit import grd_reader
+from grit import util
+
+
+def Outputs(filename):
+ grd = grd_reader.Parse(filename)
+
+ target = []
+ lang_folders = {}
+ # Add all explicitly-specified output files
+ for output in grd.GetOutputFiles():
+ path = output.GetFilename()
+ target.append(path)
+
+ if path.endswith('.h'):
+ path, filename = os.path.split(path)
+ if output.attrs['lang']:
+ lang_folders[output.attrs['lang']] = os.path.dirname(path)
+
+ # Add all generated files, once for each output language.
+ for node in grd:
+ if node.name == 'structure':
+ # TODO(joi) Should remove the "if sconsdep is true" thing as it is a
+ # hack - see grit/node/structure.py
+ if node.HasFileForLanguage() and node.attrs['sconsdep'] == 'true':
+ for lang in lang_folders:
+ path = node.FileForLanguage(lang, lang_folders[lang],
+ create_file=False,
+ return_if_not_generated=False)
+ if path:
+ target.append(path)
+
+ return [t.replace('\\', '/') for t in target]
+
+
+def Inputs(filename):
+ grd = grd_reader.Parse(filename, debug=False)
+ files = []
+ for node in grd:
+ if (node.name == 'structure' or node.name == 'skeleton' or
+ (node.name == 'file' and node.parent and
+ node.parent.name == 'translations')):
+ files.append(node.GetFilePath())
+ elif node.name == 'include':
+ # Only include files that we actually plan on using.
+ if node.SatisfiesOutputCondition():
+ files.append(node.FilenameToOpen())
+
+ # Add in the grit source files. If one of these change, we want to re-run
+ # grit.
+ grit_root_dir = os.path.dirname(__file__)
+ for root, dirs, filenames in os.walk(grit_root_dir):
+ grit_src = [os.path.join(root, f) for f in filenames if f.endswith('.py')]
+ files.extend(grit_src)
+
+ return [f.replace('\\', '/') for f in files]
+
+
+def main(argv):
+ if len(argv) >= 3 and argv[1] == '--inputs':
+ for f in argv[2:]:
+ inputs = Inputs(f)
+ # Include grd file as second input (works around gyp expecting it).
+ inputs = [inputs[0], f] + inputs[1:]
+ print '\n'.join(inputs)
+ return 0
+ if len(argv) >= 4 and argv[1] == '--outputs':
+ for f in argv[3:]:
+ outputs = [posixpath.join(argv[2], f) for f in Outputs(f)]
+ print '\n'.join(outputs)
+ return 0
+ print 'USAGE: ./grit_info.py --inputs <grd-files>..'
+ print ' ./grit_info.py --outputs <out-prefix> <grd-files>..'
+ return 1
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))