summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-09-21 23:20:56 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2018-11-12 10:33:59 +0000
commit78e7e1c3e14e7ab291f7172cfbee12d630468fc2 (patch)
tree4bb1aee23cde23dc7c75a7782a8bbda572288a98
parentf03ed2d6158b4753b3e7293fd9c782c209b6277e (diff)
downloadbuildstream-78e7e1c3e14e7ab291f7172cfbee12d630468fc2.tar.gz
Add `--deps build` option to `bst checkout`
As discussed in https://mail.gnome.org/archives/buildstream-list/2018-September/msg00064.html, add `--deps build` option to `bst checkout`. This will allow users to checkout the all build dependencies of a given element using a single command. - _frontend/cli.py: Add `--deps build` option for `bst checkout`. - element.py: Support `deps='build'` in Element._prepare_sandbox(). - tests/frontend/buildcheckout.py: Ensure `--deps build` works as expected.
-rw-r--r--buildstream/_frontend/cli.py2
-rw-r--r--buildstream/element.py5
-rw-r--r--tests/frontend/buildcheckout.py14
3 files changed, 17 insertions, 4 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 85632959f..97feb2d87 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -630,7 +630,7 @@ def shell(app, element, sysroot, mount, isolate, build_, command):
@click.option('--force', '-f', default=False, is_flag=True,
help="Allow files to be overwritten")
@click.option('--deps', '-d', default='run',
- type=click.Choice(['run', 'none']),
+ type=click.Choice(['run', 'build', 'none']),
help='The dependencies to checkout (default: run)')
@click.option('--integrate/--no-integrate', default=True, is_flag=True,
help="Whether to run integration commands")
diff --git a/buildstream/element.py b/buildstream/element.py
index 91ce177c6..3637d8d60 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1329,7 +1329,10 @@ class Element(Plugin):
if scope == Scope.BUILD:
self.stage(sandbox)
elif scope == Scope.RUN:
- if deps == 'run':
+
+ if deps == 'build':
+ dependency_scope = Scope.BUILD
+ elif deps == 'run':
dependency_scope = Scope.RUN
else:
dependency_scope = Scope.NONE
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 480eeadf9..99cb4b905 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -61,7 +61,7 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("deps", [("run"), ("none")])
+@pytest.mark.parametrize("deps", [("run"), ("none"), ("build")])
def test_build_checkout_deps(datafiles, cli, deps):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkout = os.path.join(cli.directory, 'checkout')
@@ -82,7 +82,17 @@ def test_build_checkout_deps(datafiles, cli, deps):
# Verify output of this element
filename = os.path.join(checkout, 'etc', 'buildstream', 'config')
- assert os.path.exists(filename)
+ if deps == "build":
+ assert not os.path.exists(filename)
+ else:
+ assert os.path.exists(filename)
+
+ # Verify output of this element's build dependencies
+ filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
+ if deps == "build":
+ assert os.path.exists(filename)
+ else:
+ assert not os.path.exists(filename)
# Verify output of this element's runtime dependencies
filename = os.path.join(checkout, 'usr', 'bin', 'hello')