You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:21:12 UTC

[buildstream] 02/05: Add cli main and user config option for 'pull-buildtrees' context.

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch phil/712-high-priority-job-queue
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit da612300d1b58311be64798fe8fc6e35a004407b
Author: Tom Pollard <to...@codethink.co.uk>
AuthorDate: Mon Nov 5 13:16:53 2018 +0000

    Add cli main and user config option for 'pull-buildtrees' context.
    
    _context.py: Add pull_buildtrees global user context, the default
    of which is set to False via the addition of pull-buildtrees to
    userconfig.yaml cache group.
    
    _frontend/app.py & cli.py: Add --pull-buildtrees as a bst main
    option, which when passed will override the default or user defined
    context for pull_buildtrees.
    
    tests/completions/completions.py: Update for the added flag.
---
 buildstream/_context.py          | 8 +++++++-
 buildstream/_frontend/app.py     | 3 ++-
 buildstream/_frontend/cli.py     | 2 ++
 buildstream/data/userconfig.yaml | 3 +++
 tests/completions/completions.py | 1 +
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/buildstream/_context.py b/buildstream/_context.py
index 876b747..960f371 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -104,6 +104,9 @@ class Context():
         # What to do when a build fails in non interactive mode
         self.sched_error_action = 'continue'
 
+        # Whether or not to attempt to pull build trees globally
+        self.pull_buildtrees = None
+
         # Whether elements must be rebuilt when their dependencies have changed
         self._strict_build_plan = None
 
@@ -178,13 +181,16 @@ class Context():
         # our artifactdir - the artifactdir may not have been created
         # yet.
         cache = _yaml.node_get(defaults, Mapping, 'cache')
-        _yaml.node_validate(cache, ['quota'])
+        _yaml.node_validate(cache, ['quota', 'pull-buildtrees'])
 
         self.config_cache_quota = _yaml.node_get(cache, str, 'quota', default_value='infinity')
 
         # Load artifact share configuration
         self.artifact_cache_specs = ArtifactCache.specs_from_config_node(defaults)
 
+        # Load pull build trees configuration
+        self.pull_buildtrees = _yaml.node_get(cache, bool, 'pull-buildtrees')
+
         # 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 6b292a4..b42b94b 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -182,7 +182,8 @@ class App():
             'fetchers': 'sched_fetchers',
             'builders': 'sched_builders',
             'pushers': 'sched_pushers',
-            'network_retries': 'sched_network_retries'
+            'network_retries': 'sched_network_retries',
+            'pull_buildtrees': 'pull_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 8563295..b75bf45 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -219,6 +219,8 @@ def print_version(ctx, param, value):
               help="Specify a project option")
 @click.option('--default-mirror', default=None,
               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.pass_context
 def cli(context, **kwargs):
     """Build and manipulate BuildStream projects
diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml
index efe419c..f540a97 100644
--- a/buildstream/data/userconfig.yaml
+++ b/buildstream/data/userconfig.yaml
@@ -35,6 +35,9 @@ cache:
   # to the isize of the file system containing the cache.
   quota: infinity
 
+  # Whether to pull build trees when downloading element artifacts
+  pull-buildtrees: False
+
 #
 #    Scheduler
 #
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index e6d15e6..8372874 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -42,6 +42,7 @@ MAIN_OPTIONS = [
     "-o ",
     "--option ",
     "--on-error ",
+    "--pull-buildtrees ",
     "--pushers ",
     "--strict ",
     "--verbose ",