Tristan Van Berkom pushed to branch jjardon/doc_git_submodules at BuildStream / buildstream
Commits:
-
cc5ef68c
by Tristan Van Berkom at 2018-12-03T08:41:42Z
-
87ba19d7
by Tristan Van Berkom at 2018-12-03T09:19:54Z
-
1b24148f
by Chandan Singh at 2018-12-03T09:46:13Z
-
8ac1e757
by Chandan Singh at 2018-12-03T09:46:14Z
-
ac60f47a
by Benjamin Schubert at 2018-12-03T09:46:14Z
-
b1430fb5
by Tristan Van Berkom at 2018-12-03T11:01:54Z
-
9022a778
by Javier Jardón at 2018-12-03T11:14:55Z
7 changed files:
- MANIFEST.in
- buildstream/_frontend/cli.py
- buildstream/_stream.py
- buildstream/element.py
- buildstream/plugins/sources/git.py
- buildstream/types.py
- tests/frontend/buildcheckout.py
Changes:
... | ... | @@ -19,6 +19,7 @@ recursive-include doc/source *.html |
19 | 19 |
recursive-include doc/source *.odg
|
20 | 20 |
recursive-include doc/source *.svg
|
21 | 21 |
recursive-include doc/examples *
|
22 |
+recursive-include doc/sessions *.run
|
|
22 | 23 |
|
23 | 24 |
# Tests
|
24 | 25 |
recursive-include tests *
|
... | ... | @@ -640,7 +640,7 @@ def shell(app, element, sysroot, mount, isolate, build_, command): |
640 | 640 |
@click.option('--force', '-f', default=False, is_flag=True,
|
641 | 641 |
help="Allow files to be overwritten")
|
642 | 642 |
@click.option('--deps', '-d', default='run',
|
643 |
- type=click.Choice(['run', 'none']),
|
|
643 |
+ type=click.Choice(['run', 'build', 'none']),
|
|
644 | 644 |
help='The dependencies to checkout (default: run)')
|
645 | 645 |
@click.option('--integrate/--no-integrate', default=True, is_flag=True,
|
646 | 646 |
help="Whether to run integration commands")
|
... | ... | @@ -657,16 +657,24 @@ def shell(app, element, sysroot, mount, isolate, build_, command): |
657 | 657 |
def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
|
658 | 658 |
"""Checkout a built artifact to the specified location
|
659 | 659 |
"""
|
660 |
+ from ..element import Scope
|
|
660 | 661 |
|
661 | 662 |
if hardlinks and tar:
|
662 | 663 |
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
|
663 | 664 |
sys.exit(-1)
|
664 | 665 |
|
666 |
+ if deps == "run":
|
|
667 |
+ scope = Scope.RUN
|
|
668 |
+ elif deps == "build":
|
|
669 |
+ scope = Scope.BUILD
|
|
670 |
+ elif deps == "none":
|
|
671 |
+ scope = Scope.NONE
|
|
672 |
+ |
|
665 | 673 |
with app.initialized():
|
666 | 674 |
app.stream.checkout(element,
|
667 | 675 |
location=location,
|
668 | 676 |
force=force,
|
669 |
- deps=deps,
|
|
677 |
+ scope=scope,
|
|
670 | 678 |
integrate=integrate,
|
671 | 679 |
hardlinks=hardlinks,
|
672 | 680 |
tar=tar)
|
... | ... | @@ -370,7 +370,7 @@ class Stream(): |
370 | 370 |
# target (str): Target to checkout
|
371 | 371 |
# location (str): Location to checkout the artifact to
|
372 | 372 |
# force (bool): Whether files can be overwritten if necessary
|
373 |
- # deps (str): The dependencies to checkout
|
|
373 |
+ # scope (str): The scope of dependencies to checkout
|
|
374 | 374 |
# integrate (bool): Whether to run integration commands
|
375 | 375 |
# hardlinks (bool): Whether checking out files hardlinked to
|
376 | 376 |
# their artifacts is acceptable
|
... | ... | @@ -383,7 +383,7 @@ class Stream(): |
383 | 383 |
def checkout(self, target, *,
|
384 | 384 |
location=None,
|
385 | 385 |
force=False,
|
386 |
- deps='run',
|
|
386 |
+ scope=Scope.RUN,
|
|
387 | 387 |
integrate=True,
|
388 | 388 |
hardlinks=False,
|
389 | 389 |
tar=False):
|
... | ... | @@ -396,7 +396,7 @@ class Stream(): |
396 | 396 |
|
397 | 397 |
# Stage deps into a temporary sandbox first
|
398 | 398 |
try:
|
399 |
- with target._prepare_sandbox(Scope.RUN, None, deps=deps,
|
|
399 |
+ with target._prepare_sandbox(scope=scope, directory=None,
|
|
400 | 400 |
integrate=integrate) as sandbox:
|
401 | 401 |
|
402 | 402 |
# Copy or move the sandbox to the target directory
|
... | ... | @@ -438,7 +438,7 @@ class Element(Plugin): |
438 | 438 |
visited=visited, recursed=True)
|
439 | 439 |
|
440 | 440 |
# Yeild self only at the end, after anything needed has been traversed
|
441 |
- if should_yield and (recurse or recursed) and (scope in (Scope.ALL, Scope.RUN)):
|
|
441 |
+ if should_yield and (recurse or recursed) and scope != Scope.BUILD:
|
|
442 | 442 |
yield self
|
443 | 443 |
|
444 | 444 |
def search(self, scope, name):
|
... | ... | @@ -1339,7 +1339,7 @@ class Element(Plugin): |
1339 | 1339 |
# is used to stage things by the `bst checkout` codepath
|
1340 | 1340 |
#
|
1341 | 1341 |
@contextmanager
|
1342 |
- def _prepare_sandbox(self, scope, directory, deps='run', integrate=True):
|
|
1342 |
+ def _prepare_sandbox(self, scope, directory, shell=False, integrate=True):
|
|
1343 | 1343 |
# bst shell and bst checkout require a local sandbox.
|
1344 | 1344 |
bare_directory = True if directory else False
|
1345 | 1345 |
with self.__sandbox(directory, config=self.__sandbox_config, allow_remote=False,
|
... | ... | @@ -1350,20 +1350,19 @@ class Element(Plugin): |
1350 | 1350 |
|
1351 | 1351 |
# Stage something if we need it
|
1352 | 1352 |
if not directory:
|
1353 |
- if scope == Scope.BUILD:
|
|
1353 |
+ if shell and scope == Scope.BUILD:
|
|
1354 | 1354 |
self.stage(sandbox)
|
1355 |
- elif scope == Scope.RUN:
|
|
1355 |
+ else:
|
|
1356 | 1356 |
# Stage deps in the sandbox root
|
1357 |
- if deps == 'run':
|
|
1358 |
- with self.timed_activity("Staging dependencies", silent_nested=True):
|
|
1359 |
- self.stage_dependency_artifacts(sandbox, scope)
|
|
1357 |
+ with self.timed_activity("Staging dependencies", silent_nested=True):
|
|
1358 |
+ self.stage_dependency_artifacts(sandbox, scope)
|
|
1360 | 1359 |
|
1361 |
- # Run any integration commands provided by the dependencies
|
|
1362 |
- # once they are all staged and ready
|
|
1363 |
- if integrate:
|
|
1364 |
- with self.timed_activity("Integrating sandbox"):
|
|
1365 |
- for dep in self.dependencies(scope):
|
|
1366 |
- dep.integrate(sandbox)
|
|
1360 |
+ # Run any integration commands provided by the dependencies
|
|
1361 |
+ # once they are all staged and ready
|
|
1362 |
+ if integrate:
|
|
1363 |
+ with self.timed_activity("Integrating sandbox"):
|
|
1364 |
+ for dep in self.dependencies(scope):
|
|
1365 |
+ dep.integrate(sandbox)
|
|
1367 | 1366 |
|
1368 | 1367 |
yield sandbox
|
1369 | 1368 |
|
... | ... | @@ -1858,7 +1857,7 @@ class Element(Plugin): |
1858 | 1857 |
# If directory is not specified, one will be staged using scope
|
1859 | 1858 |
def _shell(self, scope=None, directory=None, *, mounts=None, isolate=False, prompt=None, command=None):
|
1860 | 1859 |
|
1861 |
- with self._prepare_sandbox(scope, directory) as sandbox:
|
|
1860 |
+ with self._prepare_sandbox(scope, directory, shell=True) as sandbox:
|
|
1862 | 1861 |
environment = self.get_environment()
|
1863 | 1862 |
environment = copy.copy(environment)
|
1864 | 1863 |
flags = SandboxFlags.INTERACTIVE | SandboxFlags.ROOT_READ_ONLY
|
... | ... | @@ -25,6 +25,11 @@ git - stage files from a git repository |
25 | 25 |
|
26 | 26 |
* git
|
27 | 27 |
|
28 |
+.. attention::
|
|
29 |
+ |
|
30 |
+ Note that this plugin **will checkout git submodules by default**; even if
|
|
31 |
+ they are not specified in the `.bst` file.
|
|
32 |
+ |
|
28 | 33 |
**Usage:**
|
29 | 34 |
|
30 | 35 |
.. code:: yaml
|
... | ... | @@ -48,6 +48,12 @@ class Scope(Enum): |
48 | 48 |
itself.
|
49 | 49 |
"""
|
50 | 50 |
|
51 |
+ NONE = 4
|
|
52 |
+ """Just the element itself, no dependencies.
|
|
53 |
+ |
|
54 |
+ *Since: 1.4*
|
|
55 |
+ """
|
|
56 |
+ |
|
51 | 57 |
|
52 | 58 |
class Consistency():
|
53 | 59 |
"""Defines the various consistency states of a :class:`.Source`.
|
... | ... | @@ -86,13 +86,14 @@ def test_build_invalid_suffix_dep(datafiles, cli, strict, hardlinks): |
86 | 86 |
|
87 | 87 |
|
88 | 88 |
@pytest.mark.datafiles(DATA_DIR)
|
89 |
-@pytest.mark.parametrize("deps", [("run"), ("none")])
|
|
89 |
+@pytest.mark.parametrize("deps", [("run"), ("none"), ("build")])
|
|
90 | 90 |
def test_build_checkout_deps(datafiles, cli, deps):
|
91 | 91 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
92 | 92 |
checkout = os.path.join(cli.directory, 'checkout')
|
93 |
+ element_name = "checkout-deps.bst"
|
|
93 | 94 |
|
94 | 95 |
# First build it
|
95 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
96 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
96 | 97 |
result.assert_success()
|
97 | 98 |
|
98 | 99 |
# Assert that after a successful build, the builddir is empty
|
... | ... | @@ -101,20 +102,25 @@ def test_build_checkout_deps(datafiles, cli, deps): |
101 | 102 |
assert not os.listdir(builddir)
|
102 | 103 |
|
103 | 104 |
# Now check it out
|
104 |
- result = cli.run(project=project, args=['checkout', 'target.bst', '--deps', deps, checkout])
|
|
105 |
+ result = cli.run(project=project, args=['checkout', element_name, '--deps', deps, checkout])
|
|
105 | 106 |
result.assert_success()
|
106 | 107 |
|
107 |
- # Check that the executable hello file is found in the checkout
|
|
108 |
- filename = os.path.join(checkout, 'usr', 'bin', 'hello')
|
|
108 |
+ # Verify output of this element
|
|
109 |
+ filename = os.path.join(checkout, 'etc', 'buildstream', 'config')
|
|
110 |
+ if deps == "build":
|
|
111 |
+ assert not os.path.exists(filename)
|
|
112 |
+ else:
|
|
113 |
+ assert os.path.exists(filename)
|
|
109 | 114 |
|
110 |
- if deps == "run":
|
|
115 |
+ # Verify output of this element's build dependencies
|
|
116 |
+ filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
|
|
117 |
+ if deps == "build":
|
|
111 | 118 |
assert os.path.exists(filename)
|
112 | 119 |
else:
|
113 | 120 |
assert not os.path.exists(filename)
|
114 | 121 |
|
115 |
- # Check that the executable hello file is found in the checkout
|
|
116 |
- filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
|
|
117 |
- |
|
122 |
+ # Verify output of this element's runtime dependencies
|
|
123 |
+ filename = os.path.join(checkout, 'usr', 'bin', 'hello')
|
|
118 | 124 |
if deps == "run":
|
119 | 125 |
assert os.path.exists(filename)
|
120 | 126 |
else:
|