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

Unified Diff: tools/grit/grit/node/misc.py

Issue 3155033: Add support for if nodes in outputs nodes of grd files (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: nits Created 10 years, 4 months 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 | « tools/grit/grit/node/empty.py ('k') | tools/grit/grit/node/misc_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/node/misc.py
diff --git a/tools/grit/grit/node/misc.py b/tools/grit/grit/node/misc.py
index 56fec47066aad20fee92fdffd0d8c2153d04d08b..b906ec250cd09ebe413c543c9b932987599bf1b9 100644
--- a/tools/grit/grit/node/misc.py
+++ b/tools/grit/grit/node/misc.py
@@ -36,6 +36,9 @@ class IfNode(base.Node):
elif isinstance(self.parent, empty.StructuresNode):
from grit.node import structure
return isinstance(child, structure.StructureNode)
+ elif isinstance(self.parent, empty.OutputsNode):
+ from grit.node import io
+ return isinstance(child, io.OutputNode)
else:
return False
@@ -204,12 +207,31 @@ class GritNode(base.Node):
'''
return self.attrs['base_dir']
+ def _CollectOutputFiles(self, nodes, output_files):
+ '''Recursively filters the list of nodes that may contain other lists
+ in <if> nodes, and collects all the nodes that are not enclosed by
+ unsatisfied <if> conditionals and not <if> nodes themselves.
+
+ Args:
+ nodes: The list of nodes to filter.
+ output_files: The list of satisfying nodes.
+ '''
+ for node in nodes:
+ if node.name == 'if':
+ if node.IsConditionSatisfied():
+ self._CollectOutputFiles(node.children, output_files)
+ else:
+ output_files.append(node)
+
def GetOutputFiles(self):
- '''Returns the list of <file> nodes that are children of this node's
- <outputs> child.'''
+ '''Returns the list of <output> nodes that are descendants of this node's
+ <outputs> child and are not enclosed by unsatisfied <if> conditionals.
+ '''
for child in self.children:
if child.name == 'outputs':
- return child.children
+ output_files = []
+ self._CollectOutputFiles(child.children, output_files)
+ return output_files
raise exception.MissingElement()
def ItemFormatter(self, t):
« no previous file with comments | « tools/grit/grit/node/empty.py ('k') | tools/grit/grit/node/misc_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698