Hi BuildStream developers,
I would like to discuss a possible small feature addition to "bst artifacts
checkout".
Currently, "bst shell" supports the "--use-buildtrees" option, which makes
it possible to open a shell with the existing build tree.
I was wondering whether it would make sense to support a similar option in
"bst artifacts checkout", so that the build tree contents could also be
checked out directly.
I took a quick look at the implementation, and it seems that most of the
required infrastructure already exists, so the change itself appears
relatively straightforward.
Before working on a proper patch/MR, I wanted to ask:
- Has this been discussed before?
- Is something similar already planned?
- Are there architectural or UX reasons why this functionality should not
be added to "bst artifacts checkout"?
To make the idea more concrete, I am also attaching a small example patch
showing roughly what I have in mind.
If the idea sounds acceptable, I would be happy to work on a proper
contribution.
Thanks!
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index e9e6ddfb9..2b8139ab1 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1053,6 +1053,16 @@ def source_track(app, elements, deps, except_, cross_junctions):
@click.option(
"--ignore-project-source-remotes", is_flag=True, help="Ignore remote source cache servers recommended by projects"
)
[email protected](
+ "--use-buildtree",
+ "-t",
+ "cli_buildtree",
+ is_flag=True,
+ help=(
+ "Stage a buildtree. Will fail if a buildtree is not available. "
+ "pull-buildtrees configuration is needed if the buildtree is not available locally."
+ ),
+)
@click.argument("element", required=False, type=click.Path(readable=False))
@click.pass_obj
def source_checkout(
@@ -1067,6 +1077,7 @@ def source_checkout(
build_scripts,
source_remotes,
ignore_project_source_remotes,
+ cli_buildtree: bool,
):
"""Checkout sources of an element to the specified location
@@ -1103,6 +1114,7 @@ def source_checkout(
include_build_scripts=build_scripts,
source_remotes=source_remotes,
ignore_project_source_remotes=ignore_project_source_remotes,
+ usebuildtree=cli_buildtree,
)
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index a475bdb41..661f7c972 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -695,6 +695,7 @@ class Stream:
tar: bool = False,
artifact_remotes: Iterable[RemoteSpec] = (),
ignore_project_artifact_remotes: bool = False,
+ usebuildtree: bool = False,
):
elements = self._load(
@@ -728,7 +729,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)