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

Side by Side Diff: scripts/slave/recipe_config_types.py

Issue 1111413005: Some changes to allow recipes and modules to live noncentrally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Review comments Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/slave/recipe_api.py ('k') | scripts/slave/recipe_loader.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import abc 5 import abc
6 import re 6 import re
7 7
8 from collections import namedtuple 8 from collections import namedtuple
9 9
10 from infra.libs import infra_types 10 from infra.libs import infra_types
11 11
12
13 RECIPE_MODULE_PREFIX = 'RECIPE_MODULES'
14
15
12 def ResetTostringFns(): 16 def ResetTostringFns():
13 RecipeConfigType._TOSTRING_MAP.clear() # pylint: disable=W0212 17 RecipeConfigType._TOSTRING_MAP.clear() # pylint: disable=W0212
14 18
15 19
16 def json_fixup(obj): 20 def json_fixup(obj):
17 if isinstance(obj, RecipeConfigType): 21 if isinstance(obj, RecipeConfigType):
18 return str(obj) 22 return str(obj)
19 thawed = infra_types.thaw(obj) 23 thawed = infra_types.thaw(obj)
20 if thawed is not obj: # i.e. it was a frozen type 24 if thawed is not obj: # i.e. it was a frozen type
21 return thawed 25 return thawed
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 def parse(base): 81 def parse(base):
78 base_match = NamedBasePath.BASE_RE.match(base) 82 base_match = NamedBasePath.BASE_RE.match(base)
79 assert base_match, 'Base should be [ALL_CAPS], got %r' % base 83 assert base_match, 'Base should be [ALL_CAPS], got %r' % base
80 return NamedBasePath(base_match.group(1).lower()) 84 return NamedBasePath(base_match.group(1).lower())
81 85
82 def __repr__(self): 86 def __repr__(self):
83 return '[%s]' % self.name.upper() 87 return '[%s]' % self.name.upper()
84 88
85 89
86 class ModuleBasePath(BasePath, namedtuple('ModuleBasePath', 'module')): 90 class ModuleBasePath(BasePath, namedtuple('ModuleBasePath', 'module')):
87 # All recipe modules are in a magic RECIPE_MODULES package. Remove it
88 # before rendering MODULE[_] form.
89 MODULE_PREFIX_RE = r'^RECIPE_MODULES\.'
90
91 def __repr__(self): 91 def __repr__(self):
92 name = re.sub(self.MODULE_PREFIX_RE, '', self.module.__name__) 92 prefix = '%s.' % RECIPE_MODULE_PREFIX
93 assert self.module.__name__.startswith(prefix)
94 name = self.module.__name__[len(prefix):]
93 return 'RECIPE_MODULE[%s]' % name 95 return 'RECIPE_MODULE[%s]' % name
94 96
95 97
96 class Path(RecipeConfigType): 98 class Path(RecipeConfigType):
97 """Represents a path which is relative to a semantically-named base. 99 """Represents a path which is relative to a semantically-named base.
98 100
99 Because there's a lot of platform (separator style) and runtime-specific 101 Because there's a lot of platform (separator style) and runtime-specific
100 context (working directory) which goes into assembling a final OS-specific 102 context (working directory) which goes into assembling a final OS-specific
101 absolute path, we only store three context-free attributes in this Path 103 absolute path, we only store three context-free attributes in this Path
102 object. 104 object.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return child.pieces[:len(self.pieces)] == self.pieces 155 return child.pieces[:len(self.pieces)] == self.pieces
154 156
155 def default_tostring_fn(self): 157 def default_tostring_fn(self):
156 suffix = '' 158 suffix = ''
157 if self.platform_ext: 159 if self.platform_ext:
158 suffix = ', platform_ext=%r' % (self.platform_ext,) 160 suffix = ', platform_ext=%r' % (self.platform_ext,)
159 pieces = '' 161 pieces = ''
160 if self.pieces: 162 if self.pieces:
161 pieces = ', ' + (', '.join(map(repr, self.pieces))) 163 pieces = ', ' + (', '.join(map(repr, self.pieces)))
162 return 'Path(\'%s\'%s%s)' % (self.base, pieces, suffix) 164 return 'Path(\'%s\'%s%s)' % (self.base, pieces, suffix)
OLDNEW
« no previous file with comments | « scripts/slave/recipe_api.py ('k') | scripts/slave/recipe_loader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698