diff options
-rw-r--r-- | buildstream/_context.py | 9 | ||||
-rw-r--r-- | buildstream/_frontend/app.py | 3 | ||||
-rw-r--r-- | buildstream/_frontend/cli.py | 3 | ||||
-rw-r--r-- | buildstream/data/userconfig.yaml | 9 | ||||
-rw-r--r-- | tests/frontend/completions.py | 2 |
5 files changed, 24 insertions, 2 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py index 9c53e7d75..6fe7c3f52 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -121,6 +121,9 @@ class Context(): # Whether or not to attempt to pull build trees globally self.pull_buildtrees = None + # Whether or not to cache build trees on artifact creation + self.cache_buildtrees = None + # Boolean, whether we double-check with the user that they meant to # close the workspace when they're using it to access the project. self.prompt_workspace_close_project_inaccessible = None @@ -201,7 +204,7 @@ class Context(): # our artifactdir - the artifactdir may not have been created # yet. cache = _yaml.node_get(defaults, Mapping, 'cache') - _yaml.node_validate(cache, ['quota', 'pull-buildtrees']) + _yaml.node_validate(cache, ['quota', 'pull-buildtrees', 'cache-buildtrees']) self.config_cache_quota = _yaml.node_get(cache, str, 'quota') @@ -213,6 +216,10 @@ class Context(): # Load pull build trees configuration self.pull_buildtrees = _yaml.node_get(cache, bool, 'pull-buildtrees') + # Load cache build trees configuration + self.cache_buildtrees = _node_get_option_str( + cache, 'cache-buildtrees', ['always', 'failure', 'never']) + # Load logging config logging = _yaml.node_get(defaults, Mapping, 'logging') _yaml.node_validate(logging, [ diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index b6da079bd..329f9a2c6 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -183,7 +183,8 @@ class App(): 'builders': 'sched_builders', 'pushers': 'sched_pushers', 'network_retries': 'sched_network_retries', - 'pull_buildtrees': 'pull_buildtrees' + 'pull_buildtrees': 'pull_buildtrees', + 'cache_buildtrees': 'cache_buildtrees' } for cli_option, context_attr in override_map.items(): option_value = self._main_options.get(cli_option) diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index e3c5059b9..c4dd91c75 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -251,6 +251,9 @@ def print_version(ctx, param, value): help="The mirror to fetch from first, before attempting other mirrors") @click.option('--pull-buildtrees', is_flag=True, default=None, help="Include an element's build tree when pulling remote element artifacts") +@click.option('--cache-buildtrees', default=None, + type=click.Choice(['always', 'failure', 'never']), + help="Cache artifact build tree content on creation") @click.pass_context def cli(context, **kwargs): """Build and manipulate BuildStream projects diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml index 0834b93f6..0b4535cea 100644 --- a/buildstream/data/userconfig.yaml +++ b/buildstream/data/userconfig.yaml @@ -41,6 +41,15 @@ cache: # Whether to pull build trees when downloading element artifacts pull-buildtrees: False + # Whether to cache build trees on artifact creation: + # + # always - Always cache artifact build tree content + # failure - Only cache build trees of failed builds + # never - Don't cache artifact build tree content + # + cache-buildtrees: always + + # # Scheduler # diff --git a/tests/frontend/completions.py b/tests/frontend/completions.py index cb151c284..c374df2a0 100644 --- a/tests/frontend/completions.py +++ b/tests/frontend/completions.py @@ -23,6 +23,7 @@ MAIN_OPTIONS = [ "--builders ", "-c ", "-C ", + "--cache-buildtrees ", "--colors ", "--config ", "--debug ", @@ -156,6 +157,7 @@ def test_options(cli, cmd, word_idx, expected): @pytest.mark.parametrize("cmd,word_idx,expected", [ ('bst --on-error ', 2, ['continue ', 'quit ', 'terminate ']), + ('bst --cache-buildtrees ', 2, ['always ', 'failure ', 'never ']), ('bst show --deps ', 3, ['all ', 'build ', 'none ', 'plan ', 'run ']), ('bst show --deps=', 2, ['all ', 'build ', 'none ', 'plan ', 'run ']), ('bst show --deps b', 3, ['build ']), |