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

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

Issue 1592973003: Allow base path overrides when running a recipe. (Closed) Base URL: git@github.com:luci/recipes-py.git@isolate
Patch Set: Created 4 years, 11 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') | no next file » | 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 from recipe_engine.types import FrozenDict
7 8
8 def BaseConfig(CURRENT_WORKING_DIR, TEMP_DIR, **_kwargs): 9 def BaseConfig(CURRENT_WORKING_DIR, TEMP_DIR, BASE_PATH_OVERRIDES, **_kwargs):
9 assert CURRENT_WORKING_DIR[0].endswith(('\\', '/')) 10 assert CURRENT_WORKING_DIR[0].endswith(('\\', '/'))
10 assert TEMP_DIR[0].endswith(('\\', '/')) 11 assert TEMP_DIR[0].endswith(('\\', '/'))
11 return ConfigGroup( 12 return ConfigGroup(
12 # base path name -> [tokenized absolute path] 13 # base path name -> [tokenized absolute path]
13 base_paths = Dict(value_type=tuple), 14 base_paths = Dict(value_type=tuple),
14 15
15 # dynamic path name -> Path object (referencing one of the base_paths) 16 # dynamic path name -> Path object (referencing one of the base_paths)
16 dynamic_paths = Dict(value_type=(Path, type(None))), 17 dynamic_paths = Dict(value_type=(Path, type(None))),
17 18
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)),
21 BASE_PATH_OVERRIDES = Static(FrozenDict(BASE_PATH_OVERRIDES)),
20 ) 22 )
21 23
22 def test_name(args): # pragma: no cover 24 def test_name(args): # pragma: no cover
23 if args['CURRENT_WORKING_DIR'][0] == '/': 25 if args['CURRENT_WORKING_DIR'][0] == '/':
24 return 'posix' 26 return 'posix'
25 else: 27 else:
26 return 'windows' 28 return 'windows'
27 29
28 config_ctx = config_item_context(BaseConfig) 30 config_ctx = config_item_context(BaseConfig)
29 31
30 @config_ctx(is_root=True) 32 @config_ctx(is_root=True)
31 def BASE(c): 33 def BASE(c):
32 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR 34 c.base_paths['cwd'] = c.CURRENT_WORKING_DIR
33 c.base_paths['tmp_base'] = c.TEMP_DIR 35 c.base_paths['tmp_base'] = c.TEMP_DIR
36 for k, v in c.BASE_PATH_OVERRIDES.iteritems():
37 c.base_paths[k] = v # pragma: no cover
34 38
35 @config_ctx() 39 @config_ctx()
36 def buildbot(c): 40 def buildbot(c):
37 c.base_paths['root'] = c.CURRENT_WORKING_DIR[:-4] 41 c.base_paths.setdefault('root', c.CURRENT_WORKING_DIR[:-4])
38 c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR 42 c.base_paths.setdefault('slave_build', c.CURRENT_WORKING_DIR)
39 for token in ('build_internal', 'build', 'depot_tools'): 43 for token in ('build_internal', 'build', 'depot_tools'):
40 c.base_paths[token] = c.base_paths['root'] + (token,) 44 c.base_paths.setdefault(token, c.base_paths['root'] + (token,))
41 c.dynamic_paths['checkout'] = None 45 c.dynamic_paths['checkout'] = None
42 46
43 @config_ctx() 47 @config_ctx()
44 def example(c): 48 def example(c):
45 c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR 49 c.base_paths.setdefault('slave_build', c.CURRENT_WORKING_DIR)
46 c.dynamic_paths['borts'] = None 50 c.dynamic_paths['borts'] = None
47 51
48 @config_ctx(includes=['buildbot']) 52 @config_ctx(includes=['buildbot'])
49 def swarming(c): 53 def swarming(c):
50 c.base_paths['slave_build'] = ( 54 c.base_paths.setdefault('slave_build', (
martiniss 2016/01/19 23:29:37 This won't work as is.... base_paths already has a
51 c.CURRENT_WORKING_DIR[:1] + 55 c.CURRENT_WORKING_DIR[:1] +
52 ('b', 'fake_build', 'slave', 'fake_slave', 'build')) 56 ('b', 'fake_build', 'slave', 'fake_slave', 'build')))
OLDNEW
« no previous file with comments | « recipe_modules/path/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698