Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: grit/tool/build.py

Issue 757213003: Give build a --write-only-new option. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grit/tool/build_unittest.py » ('j') | grit/tool/build_unittest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/tool/build.py
===================================================================
--- grit/tool/build.py (revision 182)
+++ grit/tool/build.py (working copy)
@@ -109,6 +109,12 @@
output_all_resource_defines attribute of the root <grit>
element of the input .grd file.
+ --write-only-new Write output files to a temporary file first, and copy
newt (away) 2014/12/04 22:09:42 Does this also need to be added to grit_info.py as
Nico 2014/12/04 22:33:07 I think policy_templates only passes the same defi
+ it to the real output only if the new file is different
+ from the old file. This allows some build systems to
+ realize that dependent build steps might be unnecessary,
+ at the cost of comparing the output data at grit time.
+
Conditional inclusion of resources only affects the output of files which
control which resources get linked into a binary, e.g. it affects .rc files
meant for compilation but it does not affect resource header files (that define
@@ -129,10 +135,12 @@
depdir = None
rc_header_format = None
output_all_resource_defines = None
+ write_only_new = False
(own_opts, args) = getopt.getopt(args, 'a:o:D:E:f:w:t:h:',
('depdir=','depfile=','assert-file-list=',
'output-all-resource-defines',
- 'no-output-all-resource-defines',))
+ 'no-output-all-resource-defines',
+ 'write-only-new'))
for (key, val) in own_opts:
if key == '-a':
assert_output_files.append(val)
@@ -166,6 +174,8 @@
depdir = val
elif key == '--depfile':
depfile = val
+ elif key == '--write-only-new':
+ write_only_new = True
if len(args):
print 'This tool takes no tool-specific arguments.'
@@ -185,6 +195,8 @@
whitelist_contents = util.ReadFile(whitelist_filename, util.RAW_TEXT)
self.whitelist_names.update(whitelist_contents.strip().split('\n'))
+ self.write_only_new = write_only_new
+
self.res = grd_reader.Parse(opts.input,
debug=opts.extra_verbose,
first_ids_file=first_ids_file,
@@ -236,6 +248,9 @@
# output.
self.whitelist_names = None
+ # Whether to compare outputs to their old contents before writing.
+ self.write_only_new = False
+
@staticmethod
def AddWhitelistTags(start_node, whitelist_names):
# Walk the tree of nodes added attributes for the nodes that shouldn't
@@ -341,13 +356,17 @@
else:
# CHROMIUM SPECIFIC CHANGE.
# This clashes with gyp + vstudio, which expect the output timestamp
newt (away) 2014/12/04 22:09:42 If this is still an issue when using visual studio
Nico 2014/12/04 22:33:07 We don't support visual studio anymore, but maybe
- # 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())
+ # to change on a rebuild, even if nothing has changed, so only do
+ # it when opted in.
+ if not self.write_only_new:
+ write_file = True
+ else:
+ files_match = filecmp.cmp(output.GetOutputFilename(),
+ output.GetOutputFilename() + '.tmp')
+ write_file = not files_match
+ if write_file:
+ shutil.copy2(output.GetOutputFilename() + '.tmp',
newt (away) 2014/12/04 22:09:42 Seems like it would be quicker to delete output.h,
Nico 2014/12/04 22:33:07 That's the usual way of doing things so that if yo
+ output.GetOutputFilename())
os.remove(output.GetOutputFilename() + '.tmp')
self.VerboseOut(' done.\n')
« no previous file with comments | « no previous file | grit/tool/build_unittest.py » ('j') | grit/tool/build_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698