summaryrefslogtreecommitdiff
path: root/buildstream/_stream.py
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/_stream.py
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/_stream.py')
-rw-r--r--buildstream/_stream.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index afb0256b4..af736c96a 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -115,7 +115,7 @@ class Stream():
elements, _ = self._load(targets, (),
selection=selection,
except_targets=except_targets,
- fetch_subprojects=False
+ fetch_subprojects=False,
use_artifact_config=use_artifact_config)
profile_end(Topics.LOAD_SELECTION, "_".join(t.replace(os.sep, '-') for t in targets))
@@ -134,7 +134,7 @@ class Stream():
# mounts (list of HostMount): Additional directories to mount into the sandbox
# isolate (bool): Whether to isolate the environment like we do in builds
# command (list): An argv to launch in the sandbox, or None
- # usebuildtree (bool): Wheather to use a buildtree as the source.
+ # usebuildtree (str): Whether to use a buildtree as the source, given cli option
#
# Returns:
# (int): The exit code of the launched shell
@@ -144,7 +144,7 @@ class Stream():
mounts=None,
isolate=False,
command=None,
- usebuildtree=False):
+ usebuildtree=None):
# Assert we have everything we need built, unless the directory is specified
# in which case we just blindly trust the directory, using the element
@@ -159,8 +159,31 @@ class Stream():
raise StreamError("Elements need to be built or downloaded before staging a shell environment",
detail="\n".join(missing_deps))
+ buildtree = False
+ # Check if we require a pull queue attempt, with given artifact state and context
+ if usebuildtree:
+ if not element._cached_buildtree():
+ require_buildtree = self._buildtree_pull_required([element])
+ # Attempt a pull queue for the given element if remote and context allow it
+ if require_buildtree:
+ self._message(MessageType.INFO, "Attempting to fetch missing artifact buildtree")
+ self._add_queue(PullQueue(self._scheduler))
+ self._enqueue_plan(require_buildtree)
+ self._run()
+ # Now check if the buildtree was successfully fetched
+ if element._cached_buildtree():
+ buildtree = True
+ if not buildtree:
+ if usebuildtree == "always":
+ raise StreamError("Buildtree is not cached locally or in available remotes")
+ else:
+ self._message(MessageType.INFO, """Buildtree is not cached locally or in available remotes,
+ shell will be loaded without it""")
+ else:
+ buildtree = True
+
return element._shell(scope, directory, mounts=mounts, isolate=isolate, prompt=prompt, command=command,
- usebuildtree=usebuildtree)
+ usebuildtree=buildtree)
# build()
#