Chandan Singh pushed to branch chandan/bst-checkout-build at BuildStream / buildstream
Commits:
6 changed files:
- buildstream/_frontend/cli.py
- buildstream/element.py
- buildstream/element_enums.py
- tests/frontend/buildcheckout.py
- + tests/frontend/project/elements/checkout-deps.bst
- + tests/frontend/project/files/etc-files/etc/buildstream/config
Changes:
... | ... | @@ -630,7 +630,7 @@ def shell(app, element, sysroot, mount, isolate, build_, command): |
630 | 630 |
@click.option('--force', '-f', default=False, is_flag=True,
|
631 | 631 |
help="Allow files to be overwritten")
|
632 | 632 |
@click.option('--deps', '-d', default='run',
|
633 |
- type=click.Choice(['run', 'none']),
|
|
633 |
+ type=click.Choice(['run', 'build', 'none']),
|
|
634 | 634 |
help='The dependencies to checkout (default: run)')
|
635 | 635 |
@click.option('--integrate/--no-integrate', default=True, is_flag=True,
|
636 | 636 |
help="Whether to run integration commands")
|
... | ... | @@ -431,7 +431,7 @@ class Element(Plugin): |
431 | 431 |
visited=visited, recursed=True)
|
432 | 432 |
|
433 | 433 |
# Yeild self only at the end, after anything needed has been traversed
|
434 |
- if should_yield and (recurse or recursed) and (scope == Scope.ALL or scope == Scope.RUN):
|
|
434 |
+ if should_yield and (recurse or recursed) and scope != Scope.BUILD:
|
|
435 | 435 |
yield self
|
436 | 436 |
|
437 | 437 |
def search(self, scope, name):
|
... | ... | @@ -1327,17 +1327,24 @@ class Element(Plugin): |
1327 | 1327 |
if scope == Scope.BUILD:
|
1328 | 1328 |
self.stage(sandbox)
|
1329 | 1329 |
elif scope == Scope.RUN:
|
1330 |
+ |
|
1331 |
+ if deps == 'build':
|
|
1332 |
+ dependency_scope = Scope.BUILD
|
|
1333 |
+ elif deps == 'run':
|
|
1334 |
+ dependency_scope = Scope.RUN
|
|
1335 |
+ else:
|
|
1336 |
+ dependency_scope = Scope.NONE
|
|
1337 |
+ |
|
1330 | 1338 |
# Stage deps in the sandbox root
|
1331 |
- if deps == 'run':
|
|
1332 |
- with self.timed_activity("Staging dependencies", silent_nested=True):
|
|
1333 |
- self.stage_dependency_artifacts(sandbox, scope)
|
|
1334 |
- |
|
1335 |
- # Run any integration commands provided by the dependencies
|
|
1336 |
- # once they are all staged and ready
|
|
1337 |
- if integrate:
|
|
1338 |
- with self.timed_activity("Integrating sandbox"):
|
|
1339 |
- for dep in self.dependencies(scope):
|
|
1340 |
- dep.integrate(sandbox)
|
|
1339 |
+ with self.timed_activity("Staging dependencies", silent_nested=True):
|
|
1340 |
+ self.stage_dependency_artifacts(sandbox, dependency_scope)
|
|
1341 |
+ |
|
1342 |
+ # Run any integration commands provided by the dependencies
|
|
1343 |
+ # once they are all staged and ready
|
|
1344 |
+ if integrate:
|
|
1345 |
+ with self.timed_activity("Integrating sandbox"):
|
|
1346 |
+ for dep in self.dependencies(dependency_scope):
|
|
1347 |
+ dep.integrate(sandbox)
|
|
1341 | 1348 |
|
1342 | 1349 |
yield sandbox
|
1343 | 1350 |
|
... | ... | @@ -59,3 +59,7 @@ class Scope(Enum): |
59 | 59 |
"""All elements required for running the element. Including the element
|
60 | 60 |
itself.
|
61 | 61 |
"""
|
62 |
+ |
|
63 |
+ NONE = 4
|
|
64 |
+ """Just the element itself, no dependencies.
|
|
65 |
+ """
|
... | ... | @@ -61,13 +61,14 @@ def test_build_checkout(datafiles, cli, strict, hardlinks): |
61 | 61 |
|
62 | 62 |
|
63 | 63 |
@pytest.mark.datafiles(DATA_DIR)
|
64 |
-@pytest.mark.parametrize("deps", [("run"), ("none")])
|
|
64 |
+@pytest.mark.parametrize("deps", [("run"), ("none"), ("build")])
|
|
65 | 65 |
def test_build_checkout_deps(datafiles, cli, deps):
|
66 | 66 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
67 | 67 |
checkout = os.path.join(cli.directory, 'checkout')
|
68 |
+ element_name = "checkout-deps.bst"
|
|
68 | 69 |
|
69 | 70 |
# First build it
|
70 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
71 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
71 | 72 |
result.assert_success()
|
72 | 73 |
|
73 | 74 |
# Assert that after a successful build, the builddir is empty
|
... | ... | @@ -76,20 +77,25 @@ def test_build_checkout_deps(datafiles, cli, deps): |
76 | 77 |
assert not os.listdir(builddir)
|
77 | 78 |
|
78 | 79 |
# Now check it out
|
79 |
- result = cli.run(project=project, args=['checkout', 'target.bst', '--deps', deps, checkout])
|
|
80 |
+ result = cli.run(project=project, args=['checkout', element_name, '--deps', deps, checkout])
|
|
80 | 81 |
result.assert_success()
|
81 | 82 |
|
82 |
- # Check that the executable hello file is found in the checkout
|
|
83 |
- filename = os.path.join(checkout, 'usr', 'bin', 'hello')
|
|
83 |
+ # Verify output of this element
|
|
84 |
+ filename = os.path.join(checkout, 'etc', 'buildstream', 'config')
|
|
85 |
+ if deps == "build":
|
|
86 |
+ assert not os.path.exists(filename)
|
|
87 |
+ else:
|
|
88 |
+ assert os.path.exists(filename)
|
|
84 | 89 |
|
85 |
- if deps == "run":
|
|
90 |
+ # Verify output of this element's build dependencies
|
|
91 |
+ filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
|
|
92 |
+ if deps == "build":
|
|
86 | 93 |
assert os.path.exists(filename)
|
87 | 94 |
else:
|
88 | 95 |
assert not os.path.exists(filename)
|
89 | 96 |
|
90 |
- # Check that the executable hello file is found in the checkout
|
|
91 |
- filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
|
|
92 |
- |
|
97 |
+ # Verify output of this element's runtime dependencies
|
|
98 |
+ filename = os.path.join(checkout, 'usr', 'bin', 'hello')
|
|
93 | 99 |
if deps == "run":
|
94 | 100 |
assert os.path.exists(filename)
|
95 | 101 |
else:
|
1 |
+kind: import
|
|
2 |
+description: It is important for this element to have both build and runtime dependencies
|
|
3 |
+sources:
|
|
4 |
+- kind: local
|
|
5 |
+ path: files/etc-files
|
|
6 |
+depends:
|
|
7 |
+- filename: import-dev.bst
|
|
8 |
+ type: build
|
|
9 |
+- filename: import-bin.bst
|
|
10 |
+ type: runtime
|
1 |
+config
|