depot_tools: add infra_paths recipe module for infra-specific paths (attempt #2)

This is different from previous attempt https://codereview.chromium.org/1915463002 .

The change is completely backwards-compatible, and doesn't introduce recipe
expectation changes.

Modules can be switched to depend on infra_paths independently,
without any expectation changes either.

By moving path module's config.py to paths_config.py here, we also guarantee
that the returned results are going to be exactly the same.

Depends on https://codereview.chromium.org/1923363003 .

BUG=chromium:605919

Review-Url: https://codereview.chromium.org/1926033002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@300324 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c378606
DEPS = [
'recipe_engine/path',
'recipe_engine/properties',
]
......@@ -2,15 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_test_api
from recipe_engine.config_types import Path, NamedBasePath
from recipe_engine import recipe_api
class InfraPathsTestApi(recipe_test_api.RecipeTestApi): #pragma: no cover
@recipe_test_api.mod_test_data
@staticmethod
def exists(*paths):
assert all(isinstance(p, Path) for p in paths)
return paths
def __getitem__(self, name):
return Path(NamedBasePath(name))
class InfraPathsApi(recipe_api.RecipeApi):
def initialize(self):
# TODO(phajdan.jr): remove dupes from the engine and delete infra_ prefix.
self.m.path.set_config(
'infra_' + self.m.properties.get('path_config', 'buildbot'))
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
[
{
"cmd": [],
"name": "show cache path",
"~followup_annotations": [
"@@@STEP_TEXT@[CACHE]@@@"
]
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'infra_paths',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/step',
]
def RunSteps(api):
api.step('show cache path', [])
api.step.active_result.presentation.step_text = str(api.path['cache'])
def GenTests(api):
yield api.test('basic')
for platform in ('linux', 'mac', 'win'):
for path_config in ('buildbot', 'kitchen'):
yield (
api.test('paths_%s_%s' % (path_config, platform)) +
api.platform.name(platform) +
api.properties(path_config=path_config)
)
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import DEPS
CONFIG_CTX = DEPS['path'].CONFIG_CTX
@CONFIG_CTX()
def infra_common(c):
c.dynamic_paths['checkout'] = None
@CONFIG_CTX(includes=['infra_common'])
def infra_buildbot(c):
c.base_paths['root'] = c.CURRENT_WORKING_DIR[:-4]
c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR
c.base_paths['cache'] = c.base_paths['root'] + (
'build', 'slave', 'cache')
c.base_paths['git_cache'] = c.base_paths['root'] + (
'build', 'slave', 'cache_dir')
c.base_paths['goma_cache'] = c.base_paths['root'] + (
'build', 'slave', 'goma_cache')
for token in ('build_internal', 'build', 'depot_tools'):
c.base_paths[token] = c.base_paths['root'] + (token,)
@CONFIG_CTX(includes=['infra_common'])
def infra_kitchen(c):
c.base_paths['root'] = c.CURRENT_WORKING_DIR
c.base_paths['slave_build'] = c.CURRENT_WORKING_DIR
# TODO(phajdan.jr): have one cache dir, let clients append suffixes.
# TODO(phajdan.jr): set persistent cache path for remaining platforms.
# NOTE: do not use /b/swarm_slave here - it gets deleted on bot redeploy,
# and may happen even after a reboot.
if c.PLATFORM == 'linux':
c.base_paths['cache'] = (
'/', 'b', 'cache', 'chromium')
c.base_paths['git_cache'] = (
'/', 'b', 'cache', 'chromium', 'git_cache')
c.base_paths['goma_cache'] = (
'/', 'b', 'cache', 'chromium', 'goma_cache')
else:
c.base_paths['cache'] = c.base_paths['root'] + ('cache',)
c.base_paths['git_cache'] = c.base_paths['root'] + ('cache_dir',)
c.base_paths['goma_cache'] = c.base_paths['root'] + ('goma_cache',)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment