You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2023/08/09 06:40:07 UTC
[buildstream] branch juerg/checkout-buildtree created (now 83bfd0478)
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a change to branch juerg/checkout-buildtree
in repository https://gitbox.apache.org/repos/asf/buildstream.git
at 83bfd0478 WIP: Experimental support for `bst artifact checkout --use-buildtree`
This branch includes the following new commits:
new 83bfd0478 WIP: Experimental support for `bst artifact checkout --use-buildtree`
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[buildstream] 01/01: WIP: Experimental support for `bst artifact checkout --use-buildtree`
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/checkout-buildtree
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 83bfd0478bbf30311877f8feaf7715529def9c94
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Wed Aug 9 08:39:14 2023 +0200
WIP: Experimental support for `bst artifact checkout --use-buildtree`
---
src/buildstream/_frontend/cli.py | 15 +++++++++++++++
src/buildstream/_stream.py | 22 +++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 468342c5f..bed3efb4e 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1292,6 +1292,16 @@ def artifact_show(app, deps, artifacts):
),
help="The dependencies to checkout",
)
+@click.option(
+ "--use-buildtree",
+ "-t",
+ "cli_buildtree",
+ is_flag=True,
+ help=(
+ "Checkout a buildtree. Will fail if a buildtree is not available. "
+ "pull-buildtrees configuration is needed if the buildtree is not available locally."
+ ),
+)
@click.option("--integrate/--no-integrate", default=None, is_flag=True, help="Whether to run integration commands")
@click.option("--hardlinks", is_flag=True, help="Checkout hardlinks instead of copying if possible")
@click.option(
@@ -1330,6 +1340,7 @@ def artifact_checkout(
app,
force,
deps,
+ cli_buildtree,
integrate,
hardlinks,
tar,
@@ -1346,6 +1357,9 @@ def artifact_checkout(
"""
from .. import utils
+ if cli_buildtree:
+ deps = _PipelineSelection.NONE
+
if hardlinks and tar:
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
sys.exit(-1)
@@ -1397,6 +1411,7 @@ def artifact_checkout(
hardlinks=hardlinks,
compression=compression,
tar=bool(tar),
+ usebuildtree=cli_buildtree,
artifact_remotes=artifact_remotes,
ignore_project_artifact_remotes=ignore_project_artifact_remotes,
)
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 9372347e3..e3c288d72 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -661,6 +661,7 @@ class Stream:
# location: Location to checkout the artifact to
# force: Whether files can be overwritten if necessary
# selection: The selection mode for the specified targets (_PipelineSelection)
+ # usebuildtree (bool): Whether to use a buildtree as the source, given cli option
# integrate: Whether to run integration commands
# hardlinks: Whether checking out files hardlinked to
# their artifacts is acceptable
@@ -679,6 +680,7 @@ class Stream:
location: Optional[str] = None,
force: bool = False,
selection: str = _PipelineSelection.RUN,
+ usebuildtree: bool = False,
integrate: bool = True,
hardlinks: bool = False,
compression: str = "",
@@ -711,6 +713,24 @@ class Stream:
self.query_cache(elements)
self._pull_missing_artifacts(elements)
+ # Check if we require a pull queue attempt, with given artifact state and context
+ if usebuildtree:
+ if not element._cached_buildroot():
+ if not element._cached():
+ message = "Artifact not cached locally or in available remotes"
+ reason = "missing-buildtree-artifact-not-cached"
+ elif element._buildroot_exists():
+ message = "Buildtree is not cached locally or in available remotes"
+ reason = "missing-buildtree-artifact-buildtree-not-cached"
+ else:
+ message = "Artifact was created without buildtree"
+ reason = "missing-buildtree-artifact-created-without-buildtree"
+ raise StreamError(message, reason=reason)
+
+ # Raise warning if the element is cached in a failed state
+ if element._cached_failure():
+ self._context.messenger.warn("using a buildtree from a failed build.")
+
try:
scope = {
_PipelineSelection.RUN: _Scope.RUN,
@@ -718,7 +738,7 @@ class Stream:
_PipelineSelection.NONE: _Scope.NONE,
_PipelineSelection.ALL: _Scope.ALL,
}
- with element._prepare_sandbox(scope=scope[selection], integrate=integrate) as sandbox:
+ with element._prepare_sandbox(scope=scope[selection], integrate=integrate, usebuildtree=usebuildtree) as sandbox:
# Copy or move the sandbox to the target directory
virdir = sandbox.get_virtual_directory()
self._export_artifact(tar, location, compression, element, hardlinks, virdir)