OLD | NEW |
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 from recipe_engine.config import config_item_context, ConfigGroup, Dict, Static | 5 from recipe_engine.config import config_item_context, ConfigGroup, Dict, Static |
6 from recipe_engine.config_types import Path | 6 from recipe_engine.config_types import Path |
7 | 7 |
8 def BaseConfig(CURRENT_WORKING_DIR, TEMP_DIR, **_kwargs): | 8 def BaseConfig(PLATFORM, CURRENT_WORKING_DIR, TEMP_DIR, **_kwargs): |
9 assert CURRENT_WORKING_DIR[0].endswith(('\\', '/')) | 9 assert CURRENT_WORKING_DIR[0].endswith(('\\', '/')) |
10 assert TEMP_DIR[0].endswith(('\\', '/')) | 10 assert TEMP_DIR[0].endswith(('\\', '/')) |
11 return ConfigGroup( | 11 return ConfigGroup( |
12 # base path name -> [tokenized absolute path] | 12 # base path name -> [tokenized absolute path] |
13 base_paths = Dict(value_type=tuple), | 13 base_paths = Dict(value_type=tuple), |
14 | 14 |
15 # dynamic path name -> Path object (referencing one of the base_paths) | 15 # dynamic path name -> Path object (referencing one of the base_paths) |
16 dynamic_paths = Dict(value_type=(Path, type(None))), | 16 dynamic_paths = Dict(value_type=(Path, type(None))), |
17 | 17 |
| 18 PLATFORM = Static(PLATFORM), |
18 CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)), | 19 CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)), |
19 TEMP_DIR = Static(tuple(TEMP_DIR)), | 20 TEMP_DIR = Static(tuple(TEMP_DIR)), |
20 ) | 21 ) |
21 | 22 |
| 23 def test_name(args): # pragma: no cover |
| 24 if args['CURRENT_WORKING_DIR'][0] == '/': |
| 25 return 'posix' |
| 26 else: |
| 27 return 'windows' |
| 28 |
22 config_ctx = config_item_context(BaseConfig) | 29 config_ctx = config_item_context(BaseConfig) |
23 | 30 |
24 @config_ctx(is_root=True) | 31 @config_ctx(is_root=True) |
25 def BASE(c): | 32 def BASE(c): |
26 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR | 33 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR |
27 c.base_paths['tmp'] = c.TEMP_DIR | 34 c.base_paths['tmp_base'] = c.TEMP_DIR |
28 c.base_paths['root'] = c.CURRENT_WORKING_DIR[:1] | |
29 | 35 |
| 36 @config_ctx() |
| 37 def buildbot(c): |
| 38 c.base_paths['root'] = c.CURRENT_WORKING_DIR[:-4] |
| 39 c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR |
| 40 c.base_paths['cache'] = c.base_paths['root'] + ( |
| 41 'build', 'slave', 'cache') |
| 42 c.base_paths['git_cache'] = c.base_paths['root'] + ( |
| 43 'build', 'slave', 'cache_dir') |
| 44 c.base_paths['goma_cache'] = c.base_paths['root'] + ( |
| 45 'build', 'slave', 'goma_cache') |
| 46 for token in ('build_internal', 'build', 'depot_tools'): |
| 47 c.base_paths[token] = c.base_paths['root'] + (token,) |
30 c.dynamic_paths['checkout'] = None | 48 c.dynamic_paths['checkout'] = None |
| 49 |
| 50 @config_ctx(includes=['buildbot']) |
| 51 def swarming(c): |
| 52 c.base_paths['slave_build'] = ( |
| 53 c.CURRENT_WORKING_DIR[:1] + |
| 54 ('b', 'fake_build', 'slave', 'fake_slave', 'build')) |
| 55 |
| 56 @config_ctx() |
| 57 def kitchen(c): |
| 58 c.base_paths['root'] = c.CURRENT_WORKING_DIR |
| 59 c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR |
| 60 # TODO(phajdan.jr): have one cache dir, let clients append suffixes. |
| 61 # TODO(phajdan.jr): set persistent cache path for remaining platforms. |
| 62 # NOTE: do not use /b/swarm_slave here - it gets deleted on bot redeploy, |
| 63 # and may happen even after a reboot. |
| 64 if c.PLATFORM == 'linux': |
| 65 c.base_paths['cache'] = ( |
| 66 '/', 'b', 'cache', 'chromium') |
| 67 c.base_paths['git_cache'] = ( |
| 68 '/', 'b', 'cache', 'chromium', 'git_cache') |
| 69 c.base_paths['goma_cache'] = ( |
| 70 '/', 'b', 'cache', 'chromium', 'goma_cache') |
| 71 else: |
| 72 c.base_paths['cache'] = c.base_paths['root'] + ('cache',) |
| 73 c.base_paths['git_cache'] = c.base_paths['root'] + ('cache_dir',) |
| 74 c.base_paths['goma_cache'] = c.base_paths['root'] + ('goma_cache',) |
| 75 c.dynamic_paths['checkout'] = None |
OLD | NEW |