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

Side by Side Diff: recipe_modules/path/config.py

Issue 1906323003: recipe engine: extract infra-specific paths out of the engine (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: tmp Created 4 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
« no previous file with comments | « recipe_modules/path/api.py ('k') | recipe_modules/path/example.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 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(PLATFORM, CURRENT_WORKING_DIR, TEMP_DIR, **_kwargs): 8 def BaseConfig(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),
19 CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)), 18 CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)),
20 TEMP_DIR = Static(tuple(TEMP_DIR)), 19 TEMP_DIR = Static(tuple(TEMP_DIR)),
21 ) 20 )
22 21
23 def test_name(args): # pragma: no cover
24 if args['CURRENT_WORKING_DIR'][0] == '/':
25 return 'posix'
26 else:
27 return 'windows'
28
29 config_ctx = config_item_context(BaseConfig) 22 config_ctx = config_item_context(BaseConfig)
30 23
31 @config_ctx(is_root=True) 24 @config_ctx(is_root=True)
32 def BASE(c): 25 def BASE(c):
33 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR 26 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR
34 c.base_paths['tmp_base'] = c.TEMP_DIR 27 c.base_paths['tmp'] = c.TEMP_DIR
28 c.base_paths['root'] = c.CURRENT_WORKING_DIR[:1]
35 29
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,)
48 c.dynamic_paths['checkout'] = None 30 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
OLDNEW
« no previous file with comments | « recipe_modules/path/api.py ('k') | recipe_modules/path/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698