summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-08-28 15:36:14 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-05 12:14:53 +0000
commit9a2c8890c7823b26629f6d62a302955d7ae81bd1 (patch)
treefa8a54853a9893d64e0a3ba877bbf7532cce61e5
parentf35bf5125a776738adb173cfbd01336666a6e076 (diff)
downloadbuildstream-9a2c8890c7823b26629f6d62a302955d7ae81bd1.tar.gz
cli.py: Allow checkout to handle artifact refs
-rw-r--r--src/buildstream/_frontend/cli.py16
-rw-r--r--src/buildstream/_stream.py4
-rw-r--r--tests/frontend/buildcheckout.py2
3 files changed, 13 insertions, 9 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 5333be2ea..3fad1664d 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -181,7 +181,7 @@ def override_completions(orig_args, cmd, cmd_param, args, incomplete):
cmd_param.opts == ['--track'] or
cmd_param.opts == ['--track-except']):
return complete_target(args, incomplete)
- if cmd_param.name == 'artifacts':
+ if cmd_param.name == 'artifacts' or cmd_param.name == 'target':
return complete_artifact(orig_args, args, incomplete)
raise CompleteUnhandled()
@@ -1058,10 +1058,10 @@ def artifact_show(app, deps, artifacts):
@click.option('--directory', default=None,
type=click.Path(file_okay=False),
help="The directory to checkout the artifact to")
-@click.argument('element', required=False,
+@click.argument('target', required=False,
type=click.Path(readable=False))
@click.pass_obj
-def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, pull_, directory, element):
+def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, pull_, directory, target):
"""Checkout contents of an artifact
When this command is executed from a workspace directory, the default
@@ -1083,7 +1083,7 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
sys.exit(-1)
else:
if directory is None:
- location = os.path.abspath(os.path.join(os.getcwd(), element))
+ location = os.path.abspath(os.path.join(os.getcwd(), target))
else:
location = directory
if location[-4:] == '.bst':
@@ -1103,13 +1103,13 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
compression = inferred_compression
with app.initialized():
- if not element:
- element = app.project.get_default_target()
- if not element:
+ if not target:
+ target = app.project.get_default_target()
+ if not target:
raise AppError('Missing argument "ELEMENT".')
scope = {'run': Scope.RUN, 'build': Scope.BUILD, 'none': Scope.NONE}
- app.stream.checkout(element,
+ app.stream.checkout(target,
location=location,
force=force,
scope=scope[deps],
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index a28ca80f6..b3e0a6183 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -540,6 +540,10 @@ class Stream():
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._check_location_writable(location, force=force, tar=tar)
uncached_elts = [elt for elt in elements if not elt._cached()]
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 72974a620..67314d452 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -311,7 +311,7 @@ def test_build_checkout_using_ref(datafiles, cli):
result.assert_success()
key = cli.get_element_key(project, 'checkout-deps.bst')
- checkout_args = ['artifact', 'checkout', '--directory', checkout, 'test/checkout-deps/' + key]
+ checkout_args = ['artifact', 'checkout', '--directory', checkout, '--deps', 'none', 'test/checkout-deps/' + key]
result = cli.run(project=project, args=checkout_args)
result.assert_success()