| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 from recipe_engine.config import config_item_context, ConfigGroup, Dict, \ | 5 from recipe_engine.config import config_item_context, ConfigGroup, Dict, Static |
| 6 Set, Static | |
| 7 from recipe_engine.config_types import Path | 6 from recipe_engine.config_types import Path |
| 8 | 7 |
| 9 def BaseConfig(PLATFORM, START_DIR, TEMP_DIR, CACHE_DIR, **_kwargs): | 8 def BaseConfig(PLATFORM, START_DIR, TEMP_DIR, CACHE_DIR, **_kwargs): |
| 10 assert START_DIR[0].endswith(('\\', '/')), START_DIR | 9 assert START_DIR[0].endswith(('\\', '/')), START_DIR |
| 11 assert TEMP_DIR[0].endswith(('\\', '/')), TEMP_DIR | 10 assert TEMP_DIR[0].endswith(('\\', '/')), TEMP_DIR |
| 12 assert CACHE_DIR[0].endswith(('\\', '/')), CACHE_DIR | 11 assert CACHE_DIR[0].endswith(('\\', '/')), CACHE_DIR |
| 13 return ConfigGroup( | 12 return ConfigGroup( |
| 14 # base path name -> [tokenized absolute path] | 13 # base path name -> [tokenized absolute path] |
| 15 base_paths = Dict(value_type=tuple), | 14 base_paths = Dict(value_type=tuple), |
| 16 | 15 |
| 17 # dynamic path name -> Path object (referencing one of the base_paths) | 16 # dynamic path name -> Path object (referencing one of the base_paths) |
| 18 dynamic_paths = Dict(value_type=(Path, type(None))), | 17 dynamic_paths = Dict(value_type=(Path, type(None))), |
| 19 | 18 |
| 20 # Path keys from "base_paths" and "dynamic_paths" that are known to be | |
| 21 # volatile. | |
| 22 volatile_paths = Set(str), | |
| 23 | |
| 24 PLATFORM = Static(PLATFORM), | 19 PLATFORM = Static(PLATFORM), |
| 25 START_DIR = Static(tuple(START_DIR)), | 20 START_DIR = Static(tuple(START_DIR)), |
| 26 TEMP_DIR = Static(tuple(TEMP_DIR)), | 21 TEMP_DIR = Static(tuple(TEMP_DIR)), |
| 27 CACHE_DIR = Static(tuple(CACHE_DIR)), | 22 CACHE_DIR = Static(tuple(CACHE_DIR)), |
| 28 ) | 23 ) |
| 29 | 24 |
| 30 config_ctx = config_item_context(BaseConfig) | 25 config_ctx = config_item_context(BaseConfig) |
| 31 | 26 |
| 32 @config_ctx(is_root=True) | 27 @config_ctx(is_root=True) |
| 33 def BASE(c): | 28 def BASE(c): |
| 34 c.base_paths['start_dir'] = c.START_DIR | 29 c.base_paths['start_dir'] = c.START_DIR |
| 35 c.base_paths['tmp_base'] = c.TEMP_DIR | 30 c.base_paths['tmp_base'] = c.TEMP_DIR |
| 36 c.base_paths['cache'] = c.CACHE_DIR | 31 c.base_paths['cache'] = c.CACHE_DIR |
| 37 c.dynamic_paths['checkout'] = None | 32 c.dynamic_paths['checkout'] = None |
| OLD | NEW |