summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-09-12 10:34:46 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-12 10:34:46 +0000
commit38c620928fc0547f613a2e4c4f7f894c5c8172e2 (patch)
treeecd76ae49e2abb2a6e5726ecb882304e051ef4d6
parent108a38edd86d9de3ef0ce78cb005041662ed279e (diff)
parent3a263bb8b36d77912a411c25b0bfb020be518f82 (diff)
downloadbuildstream-38c620928fc0547f613a2e4c4f7f894c5c8172e2.tar.gz
Merge branch 'build-all-option' into 'master'
Add 'dependencies' option to 'build' user config See merge request BuildStream/buildstream!1469
-rw-r--r--src/buildstream/_context.py11
-rw-r--r--src/buildstream/_frontend/cli.py5
-rw-r--r--src/buildstream/data/userconfig.yaml8
-rw-r--r--tests/remoteexecution/partial.py14
4 files changed, 34 insertions, 4 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index ecdf6f97b..aab09b6d4 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -129,6 +129,9 @@ class Context():
# Maximum jobs per build
self.build_max_jobs = None
+ # Control which dependencies to build
+ self.build_dependencies = None
+
# Size of the artifact cache in bytes
self.config_cache_quota = None
@@ -347,9 +350,15 @@ class Context():
# Load build config
build = defaults.get_mapping('build')
- build.validate_keys(['max-jobs'])
+ build.validate_keys(['max-jobs', 'dependencies'])
self.build_max_jobs = build.get_int('max-jobs')
+ self.build_dependencies = build.get_str('dependencies')
+ if self.build_dependencies not in ['plan', 'all']:
+ provenance = build.get_scalar('dependencies').get_provenance()
+ raise LoadError("{}: Invalid value for 'dependencies'. Choose 'plan' or 'all'."
+ .format(provenance), LoadErrorReason.INVALID_DATA)
+
# Load per-projects overrides
self._project_overrides = defaults.get_mapping('projects', default={})
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 1fdbbdc58..3344c5c79 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -374,7 +374,7 @@ def init(app, project_name, format_version, element_path, force, target_director
# Build Command #
##################################################################
@cli.command(short_help="Build elements in a pipeline")
-@click.option('--deps', '-d', default='plan', show_default=True,
+@click.option('--deps', '-d', default=None,
type=click.Choice(['plan', 'all']),
help='The dependencies to build')
@click.option('--track', 'track_', multiple=True,
@@ -423,6 +423,9 @@ def build(app, elements, deps, track_, track_save, track_all, track_except, trac
with app.initialized(session_name="Build"):
ignore_junction_targets = False
+ if deps is None:
+ deps = app.context.build_dependencies
+
if not elements:
elements = app.project.get_default_targets()
# Junction elements cannot be built, exclude them from default targets
diff --git a/src/buildstream/data/userconfig.yaml b/src/buildstream/data/userconfig.yaml
index a73c1ce44..dc31c10ce 100644
--- a/src/buildstream/data/userconfig.yaml
+++ b/src/buildstream/data/userconfig.yaml
@@ -90,6 +90,14 @@ build:
#
max-jobs: 0
+ #
+ # Control which dependencies to build:
+ #
+ # plan - Only dependencies required for the build plan
+ # all - All dependencies
+ #
+ dependencies: plan
+
#
# Logging
diff --git a/tests/remoteexecution/partial.py b/tests/remoteexecution/partial.py
index bf5106f8d..a640f27d5 100644
--- a/tests/remoteexecution/partial.py
+++ b/tests/remoteexecution/partial.py
@@ -24,7 +24,8 @@ DATA_DIR = os.path.join(
# to the local cache.
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize('pull_artifact_files', [True, False])
-def test_build_dependency_partial_local_cas(cli, datafiles, pull_artifact_files):
+@pytest.mark.parametrize('build_all', [True, False])
+def test_build_dependency_partial_local_cas(cli, datafiles, pull_artifact_files, build_all):
project = str(datafiles)
element_name = 'no-runtime-deps.bst'
builddep_element_name = 'autotools/amhello.bst'
@@ -35,6 +36,12 @@ def test_build_dependency_partial_local_cas(cli, datafiles, pull_artifact_files)
assert set(services) == set(['action-cache', 'execution', 'storage'])
# configure pull blobs
+ if build_all:
+ cli.configure({
+ 'build': {
+ 'dependencies': 'all'
+ }
+ })
cli.config['remote-execution']['pull-artifact-files'] = pull_artifact_files
result = cli.run(project=project, args=['build', element_name])
@@ -52,7 +59,10 @@ def test_build_dependency_partial_local_cas(cli, datafiles, pull_artifact_files)
# Verify build dependencies is pulled for ALL and BUILD
result = cli.run(project=project, args=['artifact', 'checkout', builddep_element_name,
'--directory', builddep_checkout])
- result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
+ if build_all and pull_artifact_files:
+ result.assert_success()
+ else:
+ result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
@pytest.mark.datafiles(DATA_DIR)