| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from recipe_engine.config import config_item_context, ConfigGroup, Dict, Static | |
| 6 from recipe_engine.config_types import Path | |
| 7 | |
| 8 def BaseConfig(CURRENT_WORKING_DIR, TEMP_DIR, **_kwargs): | |
| 9 assert CURRENT_WORKING_DIR[0].endswith(('\\', '/')) | |
| 10 assert TEMP_DIR[0].endswith(('\\', '/')) | |
| 11 return ConfigGroup( | |
| 12 # base path name -> [tokenized absolute path] | |
| 13 base_paths = Dict(value_type=tuple), | |
| 14 | |
| 15 # dynamic path name -> Path object (referencing one of the base_paths) | |
| 16 dynamic_paths = Dict(value_type=(Path, type(None))), | |
| 17 | |
| 18 CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)), | |
| 19 TEMP_DIR = Static(tuple(TEMP_DIR)), | |
| 20 ) | |
| 21 | |
| 22 def test_name(args): # pragma: no cover | |
| 23 if args['CURRENT_WORKING_DIR'][0] == '/': | |
| 24 return 'posix' | |
| 25 else: | |
| 26 return 'windows' | |
| 27 | |
| 28 config_ctx = config_item_context(BaseConfig) | |
| 29 | |
| 30 @config_ctx(is_root=True) | |
| 31 def BASE(c): | |
| 32 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR | |
| 33 c.base_paths['tmp_base'] = c.TEMP_DIR | |
| 34 | |
| 35 @config_ctx() | |
| 36 def buildbot(c): | |
| 37 c.base_paths['root'] = c.CURRENT_WORKING_DIR[:-4] | |
| 38 c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR | |
| 39 for token in ('build_internal', 'build', 'depot_tools'): | |
| 40 c.base_paths[token] = c.base_paths['root'] + (token,) | |
| 41 c.dynamic_paths['checkout'] = None | |
| 42 | |
| 43 @config_ctx(includes=['buildbot']) | |
| 44 def swarming(c): | |
| 45 c.base_paths['slave_build'] = ( | |
| 46 c.CURRENT_WORKING_DIR[:1] + | |
| 47 ('b', 'fake_build', 'slave', 'fake_slave', 'build')) | |
| OLD | NEW |