Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """This module holds utilities which make writing recipes easier.""" | 5 """This module holds utilities which make writing recipes easier.""" |
| 6 | 6 |
| 7 import os as _os | 7 import os as _os |
| 8 | 8 |
| 9 # e.g. /b/build/slave/<slave-name>/build | 9 # e.g. /b/build/slave/<slave-name>/build |
| 10 SLAVE_BUILD_ROOT = _os.path.abspath(_os.getcwd()) | 10 SLAVE_BUILD_ROOT = _os.path.abspath(_os.getcwd()) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 Note that the 'steps' key will be absent from factory-properties. If you | 178 Note that the 'steps' key will be absent from factory-properties. If you |
| 179 need to pass the list of steps to some of the steps, you will need to do | 179 need to pass the list of steps to some of the steps, you will need to do |
| 180 that manually in your recipe (preferably with json.dumps()). | 180 that manually in your recipe (preferably with json.dumps()). |
| 181 | 181 |
| 182 This placeholder can be automatically added when you use the Steps.step() | 182 This placeholder can be automatically added when you use the Steps.step() |
| 183 method in this module. | 183 method in this module. |
| 184 """ | 184 """ |
| 185 pass | 185 pass |
| 186 PropertyPlaceholder = PropertyPlaceholder() | 186 PropertyPlaceholder = PropertyPlaceholder() |
| 187 | 187 |
| 188 class DelayedEvalParameter(object): | |
|
mkosiba (inactive)
2013/05/07 13:30:19
don't need this
| |
| 189 """DelayedEvalParameter allows for commands to be supplied with arguments | |
| 190 that are evaluated/executed just before the command is run. | |
| 191 | |
| 192 This is useful mostly when the command depends on files checked into the | |
| 193 source folder.""" | |
| 194 | |
| 195 def cmd(self): | |
| 196 pass | |
| 188 | 197 |
| 189 def _url_method(name): | 198 def _url_method(name): |
| 190 """Returns a shortcut static method which functions like os.path.join and uses | 199 """Returns a shortcut static method which functions like os.path.join and uses |
| 191 a fixed first url component which is chosen from the urls defined in | 200 a fixed first url component which is chosen from the urls defined in |
| 192 SOURCE_URLS based on |name|. | 201 SOURCE_URLS based on |name|. |
| 193 """ | 202 """ |
| 194 # note that we do the __name__ munging for each function separately because | 203 # note that we do the __name__ munging for each function separately because |
| 195 # staticmethod hides these attributes. | 204 # staticmethod hides these attributes. |
| 196 bases = SOURCE_URLS[name] | 205 bases = SOURCE_URLS[name] |
| 197 if len(bases) == 1: | 206 if len(bases) == 1: |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 226 """Returns obj if we're using mirrors. Otherwise returns the 'empty' | 235 """Returns obj if we're using mirrors. Otherwise returns the 'empty' |
| 227 version of obj.""" | 236 version of obj.""" |
| 228 return obj if self.use_mirror else obj.__class__() | 237 return obj if self.use_mirror else obj.__class__() |
| 229 | 238 |
| 230 def gclient_common_spec(self, solution_name): | 239 def gclient_common_spec(self, solution_name): |
| 231 """Returns a single gclient solution object (python dict) for common | 240 """Returns a single gclient solution object (python dict) for common |
| 232 solutions.""" | 241 solutions.""" |
| 233 return GCLIENT_COMMON_SPECS[solution_name](self) | 242 return GCLIENT_COMMON_SPECS[solution_name](self) |
| 234 | 243 |
| 235 @staticmethod | 244 @staticmethod |
| 236 def step(name, cmd, add_properties=False, **kwargs): | 245 def step(name, cmd, cwd=None, add_properties=False, **kwargs): |
| 237 """Returns a step dictionary which is compatible with annotator.py. Uses | 246 """Returns a step dictionary which is compatible with annotator.py. Uses |
| 238 PropertyPlaceholder as a stand-in for build-properties and | 247 PropertyPlaceholder as a stand-in for build-properties and |
| 239 factory-properties so that annotated_run can fill them in after the recipe | 248 factory-properties so that annotated_run can fill them in after the recipe |
| 240 completes.""" | 249 completes.""" |
| 241 assert 'shell' not in kwargs | 250 assert 'shell' not in kwargs |
| 242 assert isinstance(cmd, list) | 251 assert isinstance(cmd, list) |
| 243 if add_properties: | 252 if add_properties: |
| 244 cmd += [PropertyPlaceholder] | 253 cmd += [PropertyPlaceholder] |
| 245 ret = kwargs | 254 ret = kwargs |
| 246 ret.update({'name': name, 'cmd': cmd}) | 255 ret.update({'name': name, 'cmd': cmd}) |
| 256 if cwd: | |
| 257 ret.update({'cwd': cwd}) | |
|
agable
2013/05/06 17:53:11
This is already handled by **kwargs
mkosiba (inactive)
2013/05/07 13:30:19
Done.
| |
| 247 return ret | 258 return ret |
| 248 | 259 |
| 249 def apply_issue_step(self, root_pieces=None): | 260 def apply_issue_step(self, root_pieces=None): |
| 250 return self.step('apply_issue', [ | 261 return self.step('apply_issue', [ |
| 251 depot_tools_path('apply_issue'), | 262 depot_tools_path('apply_issue'), |
| 252 '-r', checkout_path(*(root_pieces or [])), | 263 '-r', checkout_path(*(root_pieces or [])), |
| 253 '-i', self.build_properties['issue'], | 264 '-i', self.build_properties['issue'], |
| 254 '-p', self.build_properties['patchset'], | 265 '-p', self.build_properties['patchset'], |
| 255 '-s', self.build_properties['rietveld'], | 266 '-s', self.build_properties['rietveld'], |
| 256 '-e', 'commit-bot@chromium.org']) | 267 '-e', 'commit-bot@chromium.org']) |
| 257 | 268 |
| 258 def git_step(self, *args): | 269 def git_step(self, *args): |
| 259 name = 'git '+args[0] | 270 name = 'git '+args[0] |
| 260 # Distinguish 'git config' commands by the variable they are setting. | 271 # Distinguish 'git config' commands by the variable they are setting. |
| 261 if args[0] == 'config' and not args[1].startswith('-'): | 272 if args[0] == 'config' and not args[1].startswith('-'): |
| 262 name += " "+args[1] | 273 name += " "+args[1] |
| 263 return self.step(name, [ | 274 return self.step(name, [ |
| 264 'git', '--work-tree', checkout_path(), | 275 'git', '--work-tree', checkout_path(), |
| 265 '--git-dir', checkout_path('.git')]+list(args)) | 276 '--git-dir', checkout_path('.git')]+list(args)) |
| OLD | NEW |