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

Unified Diff: scripts/slave/recipe_modules/path/config.py

Issue 24737002: Add Paths as first-class types in configs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/path/config.py
diff --git a/scripts/slave/recipe_modules/path/config.py b/scripts/slave/recipe_modules/path/config.py
new file mode 100644
index 0000000000000000000000000000000000000000..084148cc3da43e5558f5a5c64e4a7c96e8f3b4a3
--- /dev/null
+++ b/scripts/slave/recipe_modules/path/config.py
@@ -0,0 +1,44 @@
+
+from slave.recipe_config import config_item_context, ConfigGroup, Dict, Static
+
+from slave.recipe_config_types import Path
agable 2013/09/26 21:46:02 No empty line above this.
iannucci 2013/09/27 02:08:20 Done.
+
+def BaseConfig(CURRENT_WORKING_DIR, **_kwargs):
+ assert CURRENT_WORKING_DIR[0].endswith(('\\', '/'))
+ return ConfigGroup(
+ # base path name -> [tokenized absolute path]
+ base_paths = Dict(value_type=tuple),
+
+ # dynamic path name -> Path object (referencing one of the base_paths)
+ dynamic_paths = Dict(value_type=(Path, type(None))),
+
+ CURRENT_WORKING_DIR = Static(tuple(CURRENT_WORKING_DIR)),
+ )
+
+VAR_TEST_MAP = {
+ 'CURRENT_WORKING_DIR': (
+ ['/', 'b', 'build', 'slave', 'fake_slave', 'build'],
+ ['D:\\', 'build', 'slave', 'fake_slave', 'build'],
agable 2013/09/26 21:46:02 It's generally E:\\b\build...
iannucci 2013/09/27 02:08:20 Done.
agable 2013/09/27 17:48:16 You're still missing the \b\ part of the path.
+ ),
+}
+
+def test_name(args):
+ if args['CURRENT_WORKING_DIR'][0] == '/':
+ return 'posix'
+ else:
+ return 'windows'
+
+config_ctx = config_item_context(BaseConfig, VAR_TEST_MAP, test_name)
+
+@config_ctx(is_root=True)
+def BASE(c):
+ c.base_paths['cwd'] = c.CURRENT_WORKING_DIR
+
+@config_ctx()
+def buildbot(c):
+ c.base_paths['root'] = c.CURRENT_WORKING_DIR[:-4]
agable 2013/09/26 21:46:02 Magic number! Comment it.
iannucci 2013/09/27 02:08:20 This IS the comment... the root path is 4 levels u
+ c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR
+ for token in ('build_internal', 'build', 'depot_tools'):
+ c.base_paths[token] = c.base_paths['root'] + (token,)
+ c.dynamic_paths['checkout'] = None
+

Powered by Google App Engine
This is Rietveld 408576698