diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 18:28:26 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 18:28:26 +0000 |
commit | d335cf2aeb85bfd2ecae02db819a79a75a827b79 (patch) | |
tree | e7ba20be1ab8e19d3696da43d5cf1a0919936fe1 /tools | |
parent | 0753fed7b6ecb24af3640426573434bf43902478 (diff) | |
download | chromium_src-d335cf2aeb85bfd2ecae02db819a79a75a827b79.zip chromium_src-d335cf2aeb85bfd2ecae02db819a79a75a827b79.tar.gz chromium_src-d335cf2aeb85bfd2ecae02db819a79a75a827b79.tar.bz2 |
Allow data_packages outputs to include flattened items without
rc_all outputs.
This fixes a bug where the code to flatten an html file was in
the rc_all output step. So if a data_package output came before
the rc_all output in the grd file, we would get a build error.
Just refactor the code to flatten for both output types (but only
flatten once).
BUG=48253
TEST=build completes succesfully
Review URL: http://codereview.chromium.org/2889001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r-- | tools/grit/grit/format/rc.py | 8 | ||||
-rw-r--r-- | tools/grit/grit/node/include.py | 19 |
2 files changed, 20 insertions, 7 deletions
diff --git a/tools/grit/grit/format/rc.py b/tools/grit/grit/format/rc.py index bb64db1..13834b7 100644 --- a/tools/grit/grit/format/rc.py +++ b/tools/grit/grit/format/rc.py @@ -11,7 +11,6 @@ import types import re from grit import util -from grit.format import html_inline from grit.format import interface # Matches all different types of linebreaks. @@ -425,11 +424,8 @@ class RcInclude(interface.ItemFormatter): # if needed (e.g. if it is an HTML file include). filename = os.path.abspath(item.FileForLanguage(lang, output_dir)) if self.flatten_html: - # Generate the flattened HTML file. - flat_filename = os.path.join(output_dir, os.path.basename(filename)) - html_inline.InlineFile(filename, flat_filename, item) - - # Include the flattened HTML file. + item.Flatten(output_dir) + # The flattened file is in the output dir. filename = os.path.basename(filename) elif self.filenameWithoutPath: filename = os.path.basename(filename) diff --git a/tools/grit/grit/node/include.py b/tools/grit/grit/node/include.py index 0b6eee6..aff6660 100644 --- a/tools/grit/grit/node/include.py +++ b/tools/grit/grit/node/include.py @@ -8,6 +8,7 @@ import os +import grit.format.html_inline import grit.format.rc_header import grit.format.rc @@ -16,6 +17,12 @@ from grit import util class IncludeNode(base.Node): '''An <include> element.''' + def __init__(self): + base.Node.__init__(self) + + # Keep track of whether we've flattened the file or not. We don't + # want to flatten the same file multiple times. + self._is_flattened = False def _IsValidChild(self, child): return False @@ -64,7 +71,8 @@ class IncludeNode(base.Node): id = id_map[self.GetTextualIds()[0]] filename = self.FilenameToOpen() if self.attrs['flattenhtml'] == 'true': - # If the file was flattened, the flattened file is in the output dir. + self.Flatten(output_dir) + # The flattened file is in the output dir. filename = os.path.join(output_dir, os.path.split(filename)[1]) file = open(filename, 'rb') @@ -73,6 +81,15 @@ class IncludeNode(base.Node): return id, data + def Flatten(self, output_dir): + if self._is_flattened: + return + + filename = self.FilenameToOpen() + flat_filename = os.path.join(output_dir, os.path.split(filename)[1]) + grit.format.html_inline.InlineFile(filename, flat_filename, self) + self._is_flattened = True + # static method def Construct(parent, name, type, file, translateable=True, filenameonly=False, relativepath=False): |