| OLD | NEW |
| 1 # Copyright (c) 2013-2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """Entry point for fully-annotated builds. | 5 """Entry point for fully-annotated builds. |
| 6 | 6 |
| 7 This script is part of the effort to move all builds to annotator-based | 7 This script is part of the effort to move all builds to annotator-based |
| 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() | 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() |
| 9 found in scripts/master/factory/annotator_factory.py executes a single | 9 found in scripts/master/factory/annotator_factory.py executes a single |
| 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls | 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls |
| 11 this script with the build- and factory-properties passed on the command | 11 this script with the build- and factory-properties passed on the command |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 """ | 64 """ |
| 65 | 65 |
| 66 import collections | 66 import collections |
| 67 import os | 67 import os |
| 68 import sys | 68 import sys |
| 69 import traceback | 69 import traceback |
| 70 | 70 |
| 71 from . import loader | 71 from . import loader |
| 72 from . import recipe_api | 72 from . import recipe_api |
| 73 from . import recipe_test_api | 73 from . import recipe_test_api |
| 74 from . import step_runner as step_runner_module |
| 74 from . import types | 75 from . import types |
| 75 from . import util | 76 from . import util |
| 76 | 77 |
| 77 | 78 |
| 78 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) | 79 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) |
| 79 | 80 |
| 80 BUILDBOT_MAGIC_ENV = set([ | 81 BUILDBOT_MAGIC_ENV = set([ |
| 81 'BUILDBOT_BLAMELIST', | 82 'BUILDBOT_BLAMELIST', |
| 82 'BUILDBOT_BRANCH', | 83 'BUILDBOT_BRANCH', |
| 83 'BUILDBOT_BUILDBOTURL', | 84 'BUILDBOT_BUILDBOTURL', |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 properties.pop('root', None) | 199 properties.pop('root', None) |
| 199 | 200 |
| 200 # TODO(iannucci): A much better way to do this would be to dynamically | 201 # TODO(iannucci): A much better way to do this would be to dynamically |
| 201 # detect if the mirrors are actually available during the execution of the | 202 # detect if the mirrors are actually available during the execution of the |
| 202 # recipe. | 203 # recipe. |
| 203 if ('use_mirror' not in properties and ( | 204 if ('use_mirror' not in properties and ( |
| 204 'TESTING_MASTERNAME' in os.environ or | 205 'TESTING_MASTERNAME' in os.environ or |
| 205 'TESTING_SLAVENAME' in os.environ)): | 206 'TESTING_SLAVENAME' in os.environ)): |
| 206 properties['use_mirror'] = False | 207 properties['use_mirror'] = False |
| 207 | 208 |
| 208 engine = RecipeEngine(step_runner, properties, universe) | 209 with stream_engine.new_step_stream('setup_build') as s: |
| 210 engine = RecipeEngine(step_runner, properties, universe) |
| 209 | 211 |
| 210 # Create all API modules and top level RunSteps function. It doesn't launch | 212 # Create all API modules and top level RunSteps function. It doesn't launch |
| 211 # any recipe code yet; RunSteps needs to be called. | 213 # any recipe code yet; RunSteps needs to be called. |
| 212 api = None | 214 api = None |
| 213 with stream_engine.new_step_stream('setup_build') as s: | 215 |
| 214 assert 'recipe' in properties | 216 assert 'recipe' in properties |
| 215 recipe = properties['recipe'] | 217 recipe = properties['recipe'] |
| 216 | 218 |
| 217 properties_to_print = properties.copy() | 219 properties_to_print = properties.copy() |
| 218 if 'use_mirror' in properties: | 220 if 'use_mirror' in properties: |
| 219 del properties_to_print['use_mirror'] | 221 del properties_to_print['use_mirror'] |
| 220 | 222 |
| 221 run_recipe_help_lines = [ | 223 run_recipe_help_lines = [ |
| 222 'To repro this locally, run the following line from a build checkout:', | 224 'To repro this locally, run the following line from a build checkout:', |
| 223 '', | 225 '', |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 """See run_steps() for parameter meanings.""" | 294 """See run_steps() for parameter meanings.""" |
| 293 self._step_runner = step_runner | 295 self._step_runner = step_runner |
| 294 self._properties = properties | 296 self._properties = properties |
| 295 self._universe_view = universe_view | 297 self._universe_view = universe_view |
| 296 | 298 |
| 297 # A stack of ActiveStep objects, holding the most recently executed step at | 299 # A stack of ActiveStep objects, holding the most recently executed step at |
| 298 # each nest level (objects deeper in the stack have lower nest levels). | 300 # each nest level (objects deeper in the stack have lower nest levels). |
| 299 # When we pop from this stack, we close the corresponding step stream. | 301 # When we pop from this stack, we close the corresponding step stream. |
| 300 self._step_stack = [] | 302 self._step_stack = [] |
| 301 | 303 |
| 304 # TODO(iannucci): come up with a more structured way to advertise/set mode |
| 305 # flags/options for the engine. |
| 306 if '$recipe_engine' in properties: |
| 307 options = properties['$recipe_engine'] |
| 308 try: |
| 309 mode_flags = options.get('mode_flags') |
| 310 if mode_flags: |
| 311 if mode_flags.get('use_subprocess42'): |
| 312 print "Setting MODE_SUBPROCESS42: True" |
| 313 step_runner_module.MODE_SUBPROCESS42 = True |
| 314 except Exception as e: |
| 315 print "Failed to set recipe_engine options, got: %r: %s" % (options, e) |
| 316 |
| 302 @property | 317 @property |
| 303 def properties(self): | 318 def properties(self): |
| 304 return self._properties | 319 return self._properties |
| 305 | 320 |
| 306 @property | 321 @property |
| 307 def universe(self): | 322 def universe(self): |
| 308 return self._universe_view.universe | 323 return self._universe_view.universe |
| 309 | 324 |
| 310 @property | 325 @property |
| 311 def previous_step_result(self): | 326 def previous_step_result(self): |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 results.append( | 480 results.append( |
| 466 loader._invoke_with_properties( | 481 loader._invoke_with_properties( |
| 467 run_recipe, properties, recipe_script.PROPERTIES, | 482 run_recipe, properties, recipe_script.PROPERTIES, |
| 468 properties.keys())) | 483 properties.keys())) |
| 469 except TypeError as e: | 484 except TypeError as e: |
| 470 raise TypeError( | 485 raise TypeError( |
| 471 "Got %r while trying to call recipe %s with properties %r" % ( | 486 "Got %r while trying to call recipe %s with properties %r" % ( |
| 472 e, recipe, properties)) | 487 e, recipe, properties)) |
| 473 | 488 |
| 474 return results | 489 return results |
| OLD | NEW |