OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''The 'grit build' tool along with integration for this tool with the | 6 '''The 'grit build' tool along with integration for this tool with the |
7 SCons build system. | 7 SCons build system. |
8 ''' | 8 ''' |
9 | 9 |
10 import filecmp | 10 import filecmp |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 # The set of names that are whitelisted to actually be included in the | 217 # The set of names that are whitelisted to actually be included in the |
218 # output. | 218 # output. |
219 self.whitelist_names = None | 219 self.whitelist_names = None |
220 | 220 |
221 @staticmethod | 221 @staticmethod |
222 def AddWhitelistTags(start_node, whitelist_names): | 222 def AddWhitelistTags(start_node, whitelist_names): |
223 # Walk the tree of nodes added attributes for the nodes that shouldn't | 223 # Walk the tree of nodes added attributes for the nodes that shouldn't |
224 # be written into the target files (skip markers). | 224 # be written into the target files (skip markers). |
225 from grit.node import include | 225 from grit.node import include |
226 from grit.node import message | 226 from grit.node import message |
| 227 from grit.node import structure |
227 for node in start_node: | 228 for node in start_node: |
228 # Same trick data_pack.py uses to see what nodes actually result in | 229 # Same trick data_pack.py uses to see what nodes actually result in |
229 # real items. | 230 # real items. |
230 if (isinstance(node, include.IncludeNode) or | 231 if (isinstance(node, include.IncludeNode) or |
231 isinstance(node, message.MessageNode)): | 232 isinstance(node, message.MessageNode) or |
| 233 isinstance(node, structure.StructureNode)): |
232 text_ids = node.GetTextualIds() | 234 text_ids = node.GetTextualIds() |
233 # Mark the item to be skipped if it wasn't in the whitelist. | 235 # Mark the item to be skipped if it wasn't in the whitelist. |
234 if text_ids and text_ids[0] not in whitelist_names: | 236 if text_ids and text_ids[0] not in whitelist_names: |
235 node.SetWhitelistMarkedAsSkip(True) | 237 node.SetWhitelistMarkedAsSkip(True) |
236 | 238 |
237 @staticmethod | 239 @staticmethod |
238 def ProcessNode(node, output_node, outfile): | 240 def ProcessNode(node, output_node, outfile): |
239 '''Processes a node in-order, calling its formatter before and after | 241 '''Processes a node in-order, calling its formatter before and after |
240 recursing to its children. | 242 recursing to its children. |
241 | 243 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 self.MakeDirectoriesTo(depfile) | 418 self.MakeDirectoriesTo(depfile) |
417 outfile = self.fo_create(depfile, 'wb') | 419 outfile = self.fo_create(depfile, 'wb') |
418 outfile.writelines(depfile_contents) | 420 outfile.writelines(depfile_contents) |
419 | 421 |
420 @staticmethod | 422 @staticmethod |
421 def MakeDirectoriesTo(file): | 423 def MakeDirectoriesTo(file): |
422 '''Creates directories necessary to contain |file|.''' | 424 '''Creates directories necessary to contain |file|.''' |
423 dir = os.path.split(file)[0] | 425 dir = os.path.split(file)[0] |
424 if not os.path.exists(dir): | 426 if not os.path.exists(dir): |
425 os.makedirs(dir) | 427 os.makedirs(dir) |
OLD | NEW |