[grit-i18n] r196 committed - Write sources from flattenhtml to depfiles....

0 views
Skip to first unread message

grit...@googlecode.com

unread,
Aug 26, 2015, 1:46:59 PM8/26/15
to grit-de...@googlegroups.com
Revision: 196
Author: bre...@chromium.org
Date: Wed Aug 26 17:46:46 2015 UTC
Log: Write sources from flattenhtml to depfiles.

Previously, only explicit inputs were written to depfiles. This patch adds
any includes in files marked "flattenhtml=true" which are also dependencies
of the .grd file.

BUG=http://crbug.com/519860
Review=https://codereview.chromium.org/1320683002/

https://code.google.com/p/grit-i18n/source/detail?r=196

Modified:
/trunk/grit/node/misc.py
/trunk/grit/node/misc_unittest.py

=======================================
--- /trunk/grit/node/misc.py Mon Jun 29 15:41:07 2015 UTC
+++ /trunk/grit/node/misc.py Wed Aug 26 17:46:46 2015 UTC
@@ -333,9 +333,15 @@
structure.StructureNode,
variant.SkeletonNode)):
input_path = node.GetInputPath()
if input_path is not None:
- input_files.add(input_path)
+ input_files.add(self.ToRealPath(input_path))
+
+ # If it's a flattened node, grab inlined resources too.
+ if node.name == 'structure' and node.attrs['flattenhtml']
== 'true':
+ node.RunPreSubstitutionGatherer()
+ input_files.update(node.GetHtmlResourceFilenames())
+
self.SetOutputLanguage(old_output_language)
- return sorted(map(self.ToRealPath, input_files))
+ return sorted(input_files)

def GetFirstIdsFile(self):
"""Returns a usable path to the first_ids file, if set, otherwise
=======================================
--- /trunk/grit/node/misc_unittest.py Mon Jun 29 15:41:07 2015 UTC
+++ /trunk/grit/node/misc_unittest.py Wed Aug 26 17:46:46 2015 UTC
@@ -56,6 +56,7 @@
# Verifies that GetInputFiles() returns the correct list of files
# corresponding to ChromeScaledImage nodes when assets are missing.
def testGetInputFilesChromeScaledImage(self):
+ chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html')
xml = '''<?xml version="1.0" encoding="utf-8"?>
<grit latest_public_release="0" current_release="1">
<outputs>
@@ -66,12 +67,15 @@
<structures fallback_to_low_resolution="true">
<structure type="chrome_scaled_image" name="IDR_A"
file="a.png" />
<structure type="chrome_scaled_image" name="IDR_B"
file="b.png" />
+ <structure type="chrome_html" name="HTML_FILE1" file="%s"
flattenhtml="true" />
</structures>
</release>
- </grit>'''
+ </grit>''' % chrome_html_path

grd = grd_reader.Parse(StringIO.StringIO(xml),
util.PathFromRoot('grit/testdata'))
- expected =
['default_100_percent/a.png', 'default_100_percent/b.png', 'special_100_percent/a.png']
+ expected = ['chrome_html.html', 'default_100_percent/a.png',
+ 'default_100_percent/b.png', 'included_sample.html',
+ 'special_100_percent/a.png']
actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata'))
for path in grd.GetInputFiles()]
# Convert path separator for Windows paths.
actual = [path.replace('\\', '/') for path in actual]
Reply all
Reply to author
Forward
0 new messages