summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-09-11 17:48:49 +0100
committerJames Ennis <james.ennis@codethink.co.uk>2019-09-12 10:07:34 +0100
commit74ddcea4c85a307acf80d63883421c80dd37cd62 (patch)
treee7867a623c4cea78c8632b62873f9ada1535305e
parent3eedd7a7a5db75650085275c63596a54f412feab (diff)
downloadbuildstream-jennis/load_deps_consistently.tar.gz
_stream.py: Load the appropriate PipelineSelection in checkoutjennis/load_deps_consistently
This patch ensures checkout behaves like the rest of our commands which support --deps options. That is, we carry the "deps" string through to the Stream and load the corresponding PipelineSelection.
-rw-r--r--src/buildstream/_frontend/cli.py5
-rw-r--r--src/buildstream/_stream.py18
2 files changed, 10 insertions, 13 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 1fdbbdc58..98d5e314a 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1066,8 +1066,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
When this command is executed from a workspace directory, the default
is to checkout the artifact of the workspace element.
"""
- from ..element import Scope
-
if hardlinks and tar:
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
sys.exit(-1)
@@ -1107,11 +1105,10 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
if not target:
raise AppError('Missing argument "ELEMENT".')
- scope = {'run': Scope.RUN, 'build': Scope.BUILD, 'none': Scope.NONE}
app.stream.checkout(target,
location=location,
force=force,
- scope=scope[deps],
+ selection=deps,
integrate=True if integrate is None else integrate,
hardlinks=hardlinks,
pull=pull_,
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 293ba051d..d30fe6e4e 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -521,7 +521,7 @@ class Stream():
# target (str): Target to checkout
# location (str): Location to checkout the artifact to
# force (bool): Whether files can be overwritten if necessary
- # scope (str): The scope of dependencies to checkout
+ # selection (PipelineSelection): The selection mode for the specified targets
# integrate (bool): Whether to run integration commands
# hardlinks (bool): Whether checking out files hardlinked to
# their artifacts is acceptable
@@ -536,21 +536,20 @@ class Stream():
def checkout(self, target, *,
location=None,
force=False,
- scope=Scope.RUN,
+ selection=PipelineSelection.RUN,
integrate=True,
hardlinks=False,
compression='',
pull=False,
tar=False):
- # if pulling we need to ensure dependency artifacts are also pulled
- selection = PipelineSelection.RUN if pull else PipelineSelection.NONE
elements, _ = self._load((target,), (), selection=selection, use_artifact_config=True, load_refs=True)
- target = elements[-1]
- # Verify that --deps run has not been specified for an ArtifactElement
- if isinstance(target, ArtifactElement) and scope == Scope.RUN:
- raise StreamError("Unable to determine the runtime dependencies of an ArtifactElement")
+ # self.targets contains a list of the loaded target objects
+ # if we specify --deps build, Stream._load() will return a list
+ # of build dependency objects, however, we need to prepare a sandbox
+ # with the target (which has had its appropriate dependencies loaded)
+ target = self.targets[0]
self._check_location_writable(location, force=force, tar=tar)
@@ -563,7 +562,8 @@ class Stream():
self._run()
try:
- with target._prepare_sandbox(scope=scope, directory=None,
+ scope = {'run': Scope.RUN, 'build': Scope.BUILD, 'none': Scope.NONE}
+ with target._prepare_sandbox(scope=scope[selection], directory=None,
integrate=integrate) as sandbox:
# Copy or move the sandbox to the target directory
virdir = sandbox.get_virtual_directory()