Chromium Code Reviews| 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 <structure> element. | 6 '''The <structure> element. |
| 7 ''' | 7 ''' |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import platform | 10 import platform |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 gathertype = _GATHERERS[self.attrs['type']] | 86 gathertype = _GATHERERS[self.attrs['type']] |
| 87 | 87 |
| 88 self.gatherer = gathertype(self.attrs['file'], | 88 self.gatherer = gathertype(self.attrs['file'], |
| 89 self.attrs['name'], | 89 self.attrs['name'], |
| 90 self.attrs['encoding']) | 90 self.attrs['encoding']) |
| 91 self.gatherer.SetGrdNode(self) | 91 self.gatherer.SetGrdNode(self) |
| 92 self.gatherer.SetUberClique(self.UberClique()) | 92 self.gatherer.SetUberClique(self.UberClique()) |
| 93 if hasattr(self.GetRoot(), 'defines'): | 93 if hasattr(self.GetRoot(), 'defines'): |
| 94 self.gatherer.SetDefines(self.GetRoot().defines) | 94 self.gatherer.SetDefines(self.GetRoot().defines) |
| 95 self.gatherer.SetAttributes(self.attrs) | 95 self.gatherer.SetAttributes(self.attrs) |
| 96 if self.ExpandVariables(): | |
| 97 self.gatherer.SetFilenameExpansionFunction(self._Substitute) | |
| 96 | 98 |
| 97 # Parse local variables and instantiate the substituter. | 99 # Parse local variables and instantiate the substituter. |
| 98 if self.attrs['variables']: | 100 if self.attrs['variables']: |
| 99 variables = self.attrs['variables'] | 101 variables = self.attrs['variables'] |
| 100 self.substituter = util.Substituter() | 102 self.substituter = util.Substituter() |
| 101 self.substituter.AddSubstitutions(self._ParseVariables(variables)) | 103 self.substituter.AddSubstitutions(self._ParseVariables(variables)) |
| 102 | 104 |
| 103 self.skeletons = {} # Maps expressions to skeleton gatherers | 105 self.skeletons = {} # Maps expressions to skeleton gatherers |
| 104 for child in self.children: | 106 for child in self.children: |
| 105 assert isinstance(child, variant.SkeletonNode) | 107 assert isinstance(child, variant.SkeletonNode) |
| 106 skel = gathertype(child.attrs['file'], | 108 skel = gathertype(child.attrs['file'], |
| 107 self.attrs['name'], | 109 self.attrs['name'], |
| 108 child.GetEncodingToUse(), | 110 child.GetEncodingToUse(), |
| 109 is_skeleton=True) | 111 is_skeleton=True) |
| 110 skel.SetGrdNode(self) # TODO(benrg): Or child? Only used for ToRealPath | 112 skel.SetGrdNode(self) # TODO(benrg): Or child? Only used for ToRealPath |
| 111 skel.SetUberClique(self.UberClique()) | 113 skel.SetUberClique(self.UberClique()) |
| 114 if self.ExpandVariables(): | |
| 115 skel.SetFilenameExpansionFunction(self._Substitute) | |
|
flackr
2013/06/06 14:07:19
Hmm, we should be calling SetDefines here as well
dconnelly
2013/06/07 09:10:38
Done.
| |
| 112 self.skeletons[child.attrs['expr']] = skel | 116 self.skeletons[child.attrs['expr']] = skel |
| 113 | 117 |
| 114 def MandatoryAttributes(self): | 118 def MandatoryAttributes(self): |
| 115 return ['type', 'name', 'file'] | 119 return ['type', 'name', 'file'] |
| 116 | 120 |
| 117 def DefaultAttributes(self): | 121 def DefaultAttributes(self): |
| 118 return { 'encoding' : 'cp1252', | 122 return { 'encoding' : 'cp1252', |
| 119 'exclude_from_rc' : 'false', | 123 'exclude_from_rc' : 'false', |
| 120 'line_end' : 'unix', | 124 'line_end' : 'unix', |
| 121 'output_encoding' : 'utf-8', | 125 'output_encoding' : 'utf-8', |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 def SubstituteMessages(self, substituter): | 347 def SubstituteMessages(self, substituter): |
| 344 '''Propagates substitution to gatherer. | 348 '''Propagates substitution to gatherer. |
| 345 | 349 |
| 346 Args: | 350 Args: |
| 347 substituter: a grit.util.Substituter object. | 351 substituter: a grit.util.Substituter object. |
| 348 ''' | 352 ''' |
| 349 assert hasattr(self, 'gatherer') | 353 assert hasattr(self, 'gatherer') |
| 350 if self.ExpandVariables(): | 354 if self.ExpandVariables(): |
| 351 self.gatherer.SubstituteMessages(substituter) | 355 self.gatherer.SubstituteMessages(substituter) |
| 352 | 356 |
| OLD | NEW |