diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/grit/build/grit_resources.rules | 2 | ||||
-rw-r--r-- | tools/grit/grit/format/rc_header.py | 4 | ||||
-rw-r--r-- | tools/grit/grit/tool/build.py | 25 |
3 files changed, 24 insertions, 7 deletions
diff --git a/tools/grit/build/grit_resources.rules b/tools/grit/build/grit_resources.rules index e81f87e..8dd7c3f 100644 --- a/tools/grit/build/grit_resources.rules +++ b/tools/grit/build/grit_resources.rules @@ -8,7 +8,7 @@ Name="GRIT Generated Resources" DisplayName="GRIT Generated Resources" CommandLine="$(SolutionDir)..\tools\grit\build\grit_resource_file.bat [inputs] "$(SolutionDir)" "$(OutDir)\grit_derived_sources" [AllOptions]" - Outputs="$(OutDir)\grit_derived_sources\grit\$(InputName).h" + Outputs="$(OutDir)\grit_derived_sources\$(InputName).rc" AdditionalDependencies="$(SolutionDir)..\tools\grit\build\grit_resource_file.bat;$(SolutionDir)..\tools\grit\grit.py" FileExtensions="*.grd" ExecutionDescription="Generating resources..." diff --git a/tools/grit/grit/format/rc_header.py b/tools/grit/grit/format/rc_header.py index 4da974a..849bf14 100644 --- a/tools/grit/grit/format/rc_header.py +++ b/tools/grit/grit/format/rc_header.py @@ -7,7 +7,6 @@ ''' import re -import time from grit.format import interface from grit import exception @@ -26,10 +25,9 @@ class TopLevel(interface.ItemFormatter): header_string = '''// Copyright (c) Google Inc. %d // All rights reserved. // This file is automatically generated by GRIT. Do not edit. -// Built on %s #pragma once -''' % (util.GetCurrentYear(), time.asctime()) +''' % (util.GetCurrentYear()) # Check for emit nodes under the rc_header. If any emit node # is present, we assume it means the GRD file wants to override # the default header, with no includes. diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py index a2683fd..5fe2348 100644 --- a/tools/grit/grit/tool/build.py +++ b/tools/grit/grit/tool/build.py @@ -7,10 +7,12 @@ SCons build system. ''' -import os +import filecmp import getopt -import types +import os +import shutil import sys +import types from grit import grd_reader from grit import util @@ -169,7 +171,9 @@ are exported to translation interchange files (e.g. XMB files), etc. outdir = os.path.split(output.GetOutputFilename())[0] if not os.path.exists(outdir): os.makedirs(outdir) - outfile = self.fo_create(output.GetOutputFilename(), 'wb') + # Write the results to a temporary file and only overwrite the original + # if the file changed. This avoids unnecessary rebuilds. + outfile = self.fo_create(output.GetOutputFilename() + '.tmp', 'wb') if output.GetType() != 'data_package': outfile = util.WrapOutputStream(outfile, encoding) @@ -186,6 +190,21 @@ are exported to translation interchange files (e.g. XMB files), etc. self.ProcessNode(self.res, output, outfile) outfile.close() + # Now copy from the temp file back to the real output, but only if the + # real output doesn't exist or the contents of the file changed. This + # prevents identical headers from being written and .cc files from + # recompiling. + if not os.path.exists(output.GetOutputFilename()): + 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: + shutil.copy2(output.GetOutputFilename() + '.tmp', + output.GetOutputFilename()) + os.remove(output.GetOutputFilename() + '.tmp') + self.VerboseOut(' done.\n') # Print warnings if there are any duplicate shortcuts. |