Phillip Smyth pushed to branch issue_640-Build-All at BuildStream / buildstream
Commits:
-
80385969
by Phillip Smyth at 2018-12-03T15:06:30Z
-
ead69dad
by Phillip Smyth at 2018-12-03T15:06:30Z
-
fd67e33a
by Phillip Smyth at 2018-12-03T15:06:30Z
18 changed files:
- buildstream/_frontend/cli.py
- tests/completions/completions.py
- tests/frontend/buildcheckout.py
- + tests/frontend/project_world/elements/compose-all.bst
- + tests/frontend/project_world/elements/compose-exclude-dev.bst
- + tests/frontend/project_world/elements/compose-include-bin.bst
- + tests/frontend/project_world/elements/import-bin.bst
- + tests/frontend/project_world/elements/import-dev.bst
- + tests/frontend/project_world/elements/rebuild-target.bst
- + tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
- + tests/frontend/project_world/elements/target.bst
- + tests/frontend/project_world/files/bar
- + tests/frontend/project_world/files/bin-files/usr/bin/hello
- + tests/frontend/project_world/files/build-files/buildstream/build/test
- + tests/frontend/project_world/files/dev-files/usr/include/pony.h
- + tests/frontend/project_world/files/foo
- + tests/frontend/project_world/files/source-bundle/llamas.txt
- + tests/frontend/project_world/project.conf
Changes:
... | ... | @@ -170,6 +170,18 @@ original_main = click.BaseCommand.main |
170 | 170 |
click.BaseCommand.main = override_main
|
171 | 171 |
|
172 | 172 |
|
173 |
+def get_files(project_dir):
|
|
174 |
+ output = []
|
|
175 |
+ for root, _, files in os.walk(project_dir):
|
|
176 |
+ for file in files:
|
|
177 |
+ if file.endswith(".bst"):
|
|
178 |
+ relDir = os.path.relpath(root, project_dir)
|
|
179 |
+ relFile = os.path.join(relDir, file).strip("./")
|
|
180 |
+ relFile = relFile.replace('elements/', '')
|
|
181 |
+ output.append(relFile)
|
|
182 |
+ return tuple(output)
|
|
183 |
+ |
|
184 |
+ |
|
173 | 185 |
##################################################################
|
174 | 186 |
# Main Options #
|
175 | 187 |
##################################################################
|
... | ... | @@ -311,10 +323,12 @@ def init(app, project_name, format_version, element_path, force): |
311 | 323 |
help="Allow tracking to cross junction boundaries")
|
312 | 324 |
@click.option('--track-save', default=False, is_flag=True,
|
313 | 325 |
help="Deprecated: This is ignored")
|
326 |
+@click.option('--world', 'build_world', default=False, is_flag=True,
|
|
327 |
+ help="Build every element in the project")
|
|
314 | 328 |
@click.argument('elements', nargs=-1,
|
315 | 329 |
type=click.Path(readable=False))
|
316 | 330 |
@click.pass_obj
|
317 |
-def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions):
|
|
331 |
+def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions, build_world):
|
|
318 | 332 |
"""Build elements in a pipeline"""
|
319 | 333 |
|
320 | 334 |
if (track_except or track_cross_junctions) and not (track_ or track_all):
|
... | ... | @@ -328,6 +342,13 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac |
328 | 342 |
if track_all:
|
329 | 343 |
track_ = elements
|
330 | 344 |
|
345 |
+ if elements and build_world:
|
|
346 |
+ click.echo("ERROR: --world cannot be used along side named elements: '{}'".format(elements), err=True)
|
|
347 |
+ sys.exit(-1)
|
|
348 |
+ |
|
349 |
+ if build_world:
|
|
350 |
+ elements = get_files(app._main_options.get("directory"))
|
|
351 |
+ |
|
331 | 352 |
with app.initialized(session_name="Build"):
|
332 | 353 |
app.stream.build(elements,
|
333 | 354 |
track_targets=track_,
|
... | ... | @@ -130,7 +130,7 @@ def test_commands(cli, cmd, word_idx, expected): |
130 | 130 |
('bst --no-colors build -', 3, ['--all ', '--track ', '--track-all ',
|
131 | 131 |
'--track-except ',
|
132 | 132 |
'--track-cross-junctions ', '-J ',
|
133 |
- '--track-save ']),
|
|
133 |
+ '--track-save ', '--world ']),
|
|
134 | 134 |
|
135 | 135 |
# Test the behavior of completing after an option that has a
|
136 | 136 |
# parameter that cannot be completed, vs an option that has
|
... | ... | @@ -60,6 +60,47 @@ def test_build_checkout(datafiles, cli, strict, hardlinks): |
60 | 60 |
assert os.path.exists(filename)
|
61 | 61 |
|
62 | 62 |
|
63 |
+@pytest.mark.datafiles(os.path.join(os.path.dirname(
|
|
64 |
+ os.path.realpath(__file__)),
|
|
65 |
+ "project_world",
|
|
66 |
+))
|
|
67 |
+@pytest.mark.parametrize("strict,hardlinks", [
|
|
68 |
+ ("strict", "copies"),
|
|
69 |
+ ("strict", "hardlinks"),
|
|
70 |
+ ("non-strict", "copies"),
|
|
71 |
+ ("non-strict", "hardlinks"),
|
|
72 |
+])
|
|
73 |
+def test_build_world_checkout(datafiles, cli, strict, hardlinks):
|
|
74 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
75 |
+ checkout = os.path.join(cli.directory, 'checkout')
|
|
76 |
+ |
|
77 |
+ # First build it
|
|
78 |
+ result = cli.run(project=project, args=strict_args(['build', '--world'], strict))
|
|
79 |
+ result.assert_success()
|
|
80 |
+ |
|
81 |
+ # Assert that after a successful build, the builddir is empty
|
|
82 |
+ builddir = os.path.join(cli.directory, 'build')
|
|
83 |
+ assert os.path.isdir(builddir)
|
|
84 |
+ assert not os.listdir(builddir)
|
|
85 |
+ |
|
86 |
+ # Prepare checkout args
|
|
87 |
+ checkout_args = strict_args(['checkout'], strict)
|
|
88 |
+ if hardlinks == "hardlinks":
|
|
89 |
+ checkout_args += ['--hardlinks']
|
|
90 |
+ checkout_args += ['target.bst', checkout]
|
|
91 |
+ |
|
92 |
+ # Now check it out
|
|
93 |
+ result = cli.run(project=project, args=checkout_args)
|
|
94 |
+ result.assert_success()
|
|
95 |
+ |
|
96 |
+ # Check that the executable hello file is found in the checkout
|
|
97 |
+ filename = os.path.join(checkout, 'usr', 'bin', 'hello')
|
|
98 |
+ assert os.path.exists(filename)
|
|
99 |
+ |
|
100 |
+ filename = os.path.join(checkout, 'usr', 'include', 'pony.h')
|
|
101 |
+ assert os.path.exists(filename)
|
|
102 |
+ |
|
103 |
+ |
|
63 | 104 |
@pytest.mark.datafiles(DATA_DIR)
|
64 | 105 |
@pytest.mark.parametrize("strict,hardlinks", [
|
65 | 106 |
("non-strict", "hardlinks"),
|
1 |
+kind: compose
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: import-bin.bst
|
|
5 |
+ type: build
|
|
6 |
+- filename: import-dev.bst
|
|
7 |
+ type: build
|
|
8 |
+ |
|
9 |
+config:
|
|
10 |
+ # Dont try running the sandbox, we dont have a
|
|
11 |
+ # runtime to run anything in this context.
|
|
12 |
+ integrate: False
|
1 |
+kind: compose
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: import-bin.bst
|
|
5 |
+ type: build
|
|
6 |
+- filename: import-dev.bst
|
|
7 |
+ type: build
|
|
8 |
+ |
|
9 |
+config:
|
|
10 |
+ # Dont try running the sandbox, we dont have a
|
|
11 |
+ # runtime to run anything in this context.
|
|
12 |
+ integrate: False
|
|
13 |
+ |
|
14 |
+ # Exclude the dev domain
|
|
15 |
+ exclude:
|
|
16 |
+ - devel
|
1 |
+kind: compose
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: import-bin.bst
|
|
5 |
+ type: build
|
|
6 |
+- filename: import-dev.bst
|
|
7 |
+ type: build
|
|
8 |
+ |
|
9 |
+config:
|
|
10 |
+ # Dont try running the sandbox, we dont have a
|
|
11 |
+ # runtime to run anything in this context.
|
|
12 |
+ integrate: False
|
|
13 |
+ |
|
14 |
+ # Only include the runtim
|
|
15 |
+ include:
|
|
16 |
+ - runtime
|
1 |
+kind: import
|
|
2 |
+sources:
|
|
3 |
+- kind: local
|
|
4 |
+ path: files/bin-files
|
1 |
+kind: import
|
|
2 |
+sources:
|
|
3 |
+- kind: local
|
|
4 |
+ path: files/dev-files
|
1 |
+kind: compose
|
|
2 |
+ |
|
3 |
+build-depends:
|
|
4 |
+- target.bst
|
1 |
+kind: import
|
|
2 |
+description: the kind of this element must implement generate_script() method
|
|
3 |
+ |
|
4 |
+sources:
|
|
5 |
+- kind: local
|
|
6 |
+ path: files/source-bundle
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ Main stack target for the bst build test
|
|
5 |
+ |
|
6 |
+depends:
|
|
7 |
+- import-bin.bst
|
|
8 |
+- compose-all.bst
|
1 |
+#!/bin/bash
|
|
2 |
+ |
|
3 |
+echo "Hello !"
|
1 |
+test
|
1 |
+#ifndef __PONY_H__
|
|
2 |
+#define __PONY_H__
|
|
3 |
+ |
|
4 |
+#define PONY_BEGIN "Once upon a time, there was a pony."
|
|
5 |
+#define PONY_END "And they lived happily ever after, the end."
|
|
6 |
+ |
|
7 |
+#define MAKE_PONY(story) \
|
|
8 |
+ PONY_BEGIN \
|
|
9 |
+ story \
|
|
10 |
+ PONY_END
|
|
11 |
+ |
|
12 |
+#endif /* __PONY_H__ */
|
1 |
+llamas
|
1 |
+# Project config for frontend build test
|
|
2 |
+name: test
|
|
3 |
+ |
|
4 |
+element-path: elements
|