diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-09-11 17:48:49 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-09-13 16:04:12 +0100 |
commit | 25b3f7009aacad8fcfe0364f731573acf2149ece (patch) | |
tree | 2c964bff85c30b1b73b50522c8a692b203844d8c | |
parent | a6574793018107df79404298308721e9b9ef826c (diff) | |
download | buildstream-25b3f7009aacad8fcfe0364f731573acf2149ece.tar.gz |
_stream.py: Load the appropriate PipelineSelection in checkout
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.py | 5 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 18 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index f9c3e9546..931f531aa 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -1080,8 +1080,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) @@ -1121,11 +1119,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, 'all': Scope.ALL} 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 a637ef12d..83db24d94 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, 'all': Scope.ALL} + 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() |