summaryrefslogtreecommitdiff
path: root/buildstream/_frontend
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-01-10 11:09:40 +0000
committerTom Pollard <tom.pollard@codethink.co.uk>2019-01-28 12:14:40 +0000
commit805baf7d96ade33c8bbe3f38122283e705000d81 (patch)
treeab668d69303e68a83b82051925b4ad8ad89578a6 /buildstream/_frontend
parenta3e2cdd207fc610f9310bce122045f05734ccae2 (diff)
downloadbuildstream-805baf7d96ade33c8bbe3f38122283e705000d81.tar.gz
Download buildtrees on demand for bst shell --use-buildtreetpollard/829
Provide bst shell --use-buildtree the ability to attempt to acquire missing buildtrees, given respective option, user pull-buildtree context and remote availability. _frontend/cli.py: Refactor logic for determining --use-buildtree option with given opportunity to attempt pulling a non-local buildtree. Element loaded with artifact_config to allow remote querying. _stream.py: With given user option and element state, construct PullQueue to fetch remote buildtree. Continue or Error without buildtree if cannot be attained. tests/integration/build-tree.py: Update to support new usecases
Diffstat (limited to 'buildstream/_frontend')
-rw-r--r--buildstream/_frontend/cli.py40
1 files changed, 26 insertions, 14 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index ab190aae4..34217aee5 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -526,7 +526,7 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command)
else:
scope = Scope.RUN
- use_buildtree = False
+ use_buildtree = None
with app.initialized():
if not element:
@@ -534,7 +534,8 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command)
if not element:
raise AppError('Missing argument "ELEMENT".')
- dependencies = app.stream.load_selection((element,), selection=PipelineSelection.NONE)
+ dependencies = app.stream.load_selection((element,), selection=PipelineSelection.NONE,
+ use_artifact_config=True)
element = dependencies[0]
prompt = app.shell_prompt(element)
mounts = [
@@ -543,20 +544,31 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command)
]
cached = element._cached_buildtree()
- if cli_buildtree == "always":
- if cached:
- use_buildtree = True
- else:
- raise AppError("No buildtree is cached but the use buildtree option was specified")
- elif cli_buildtree == "never":
- pass
- elif cli_buildtree == "try":
- use_buildtree = cached
+ if cli_buildtree in ("always", "try"):
+ use_buildtree = cli_buildtree
+ if not cached and use_buildtree == "always":
+ click.echo("WARNING: buildtree is not cached locally, will attempt to pull from available remotes",
+ err=True)
else:
- if app.interactive and cached:
- use_buildtree = bool(click.confirm('Do you want to use the cached buildtree?'))
+ # If the value has defaulted to ask and in non interactive mode, don't consider the buildtree, this
+ # being the default behaviour of the command
+ if app.interactive and cli_buildtree == "ask":
+ if cached and bool(click.confirm('Do you want to use the cached buildtree?')):
+ use_buildtree = "always"
+ elif not cached:
+ try:
+ choice = click.prompt("Do you want to pull & use a cached buildtree?",
+ type=click.Choice(['try', 'always', 'never']),
+ err=True, show_choices=True)
+ except click.Abort:
+ click.echo('Aborting', err=True)
+ sys.exit(-1)
+
+ if choice != "never":
+ use_buildtree = choice
+
if use_buildtree and not element._cached_success():
- click.echo("Warning: using a buildtree from a failed build.")
+ click.echo("WARNING: using a buildtree from a failed build.", err=True)
try:
exitcode = app.stream.shell(element, scope, prompt,