summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 01:01:45 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 01:01:45 +0000
commitc1ab43dc83a615dfbf4b5153f2bfc9abee8871c2 (patch)
tree554dd35afd9fa9a538252a23293a3d86ab1b2609 /tools
parent668eb917cde85fddb2267325de95aa45f60e1c93 (diff)
downloadchromium_src-c1ab43dc83a615dfbf4b5153f2bfc9abee8871c2.zip
chromium_src-c1ab43dc83a615dfbf4b5153f2bfc9abee8871c2.tar.gz
chromium_src-c1ab43dc83a615dfbf4b5153f2bfc9abee8871c2.tar.bz2
This fixes a few GRIT issues:
- The generated header files had the wrong paths specified in the vcproj files. - Have the .h files generate to a temp file and overwrite the real .h files if they changed from the last run. This prevents recompiling when only a resource is changed. - Change the output file to the .rc file because otherwise the vcproj file would recompile every time because the .h file wasn't changing. Since the .rc file gets written all the time, this isn't a problem. On a side note, you still have to re-link to get the resources in chrome.dll. I imagine if you turn on incremental linking, this would be pretty fast. BUG=7967 Review URL: http://codereview.chromium.org/53028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/grit/build/grit_resources.rules2
-rw-r--r--tools/grit/grit/format/rc_header.py4
-rw-r--r--tools/grit/grit/tool/build.py25
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] &quot;$(SolutionDir)&quot; &quot;$(OutDir)\grit_derived_sources&quot; [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.