Phillip Smyth pushed to branch issue-638-validate-all-files at BuildStream / buildstream
Commits:
-
efe39d25
by Phillip Smyth at 2018-12-13T10:07:01Z
-
da3ed1ac
by Phillip Smyth at 2018-12-13T10:07:01Z
-
31b03713
by Phillip Smyth at 2018-12-13T10:07:01Z
-
275c3cfb
by Phillip Smyth at 2018-12-13T10:07:01Z
12 changed files:
- NEWS
- buildstream/_frontend/cli.py
- buildstream/_project.py
- + tests/frontend/project_default/elements/target.bst
- + tests/frontend/project_default/elements/target2.bst
- + tests/frontend/project_default/project.conf
- + tests/frontend/project_fail/elements/compose-all.bst
- + tests/frontend/project_fail/elements/import-dev.bst
- + tests/frontend/project_fail/elements/target.bst
- + tests/frontend/project_fail/files/dev-files/usr/include/pony.h
- + tests/frontend/project_fail/project.conf
- tests/frontend/show.py
Changes:
... | ... | @@ -12,6 +12,10 @@ buildstream 1.3.1 |
12 | 12 |
specific. Recommendation if you are building in Linux is to use the
|
13 | 13 |
ones being used in freedesktop-sdk project, for example
|
14 | 14 |
|
15 |
+ o Running `bst show` without elements specified will now attempt to show
|
|
16 |
+ the default element defined in the projcet configuration.
|
|
17 |
+ If no default element is defined, all elements in the project will be shown
|
|
18 |
+ |
|
15 | 19 |
o All elements must now be suffixed with `.bst`
|
16 | 20 |
Attempting to use an element that does not have the `.bst` extension,
|
17 | 21 |
will result in a warning.
|
... | ... | @@ -526,6 +526,11 @@ def push(app, elements, deps, remote): |
526 | 526 |
def show(app, elements, deps, except_, order, format_):
|
527 | 527 |
"""Show elements in the pipeline
|
528 | 528 |
|
529 |
+ Declaring no elements with result in showing a default element if one is declared in the project configuration.
|
|
530 |
+ |
|
531 |
+ If no default is declared, all elements in the project will be shown
|
|
532 |
+ |
|
533 |
+ |
|
529 | 534 |
By default this will show all of the dependencies of the
|
530 | 535 |
specified target element.
|
531 | 536 |
|
... | ... | @@ -570,11 +575,14 @@ def show(app, elements, deps, except_, order, format_): |
570 | 575 |
bst show target.bst --format \\
|
571 | 576 |
$'---------- %{name} ----------\\n%{vars}'
|
572 | 577 |
"""
|
578 |
+ |
|
573 | 579 |
with app.initialized():
|
574 | 580 |
if not elements:
|
575 | 581 |
guessed_target = app.context.guess_element()
|
576 | 582 |
if guessed_target:
|
577 | 583 |
elements = (guessed_target,)
|
584 |
+ else:
|
|
585 |
+ elements = app.project.get_default_elements()
|
|
578 | 586 |
|
579 | 587 |
dependencies = app.stream.load_selection(elements,
|
580 | 588 |
selection=deps,
|
... | ... | @@ -228,7 +228,7 @@ class Project(): |
228 | 228 |
'element-path', 'variables',
|
229 | 229 |
'environment', 'environment-nocache',
|
230 | 230 |
'split-rules', 'elements', 'plugins',
|
231 |
- 'aliases', 'name',
|
|
231 |
+ 'aliases', 'name', 'defaults',
|
|
232 | 232 |
'artifacts', 'options',
|
233 | 233 |
'fail-on-overlap', 'shell', 'fatal-warnings',
|
234 | 234 |
'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
|
... | ... | @@ -391,6 +391,34 @@ class Project(): |
391 | 391 |
# Reset the element loader state
|
392 | 392 |
Element._reset_load_state()
|
393 | 393 |
|
394 |
+ # get_default_elements()
|
|
395 |
+ #
|
|
396 |
+ # This function is used to gather either:
|
|
397 |
+ # The project default element (if defined in project.conf)
|
|
398 |
+ # or
|
|
399 |
+ # All elements in the project
|
|
400 |
+ #
|
|
401 |
+ def get_default_elements(self):
|
|
402 |
+ output = []
|
|
403 |
+ |
|
404 |
+ # The project is not required to have an element-path
|
|
405 |
+ element_directory = self._project_conf.get('element-path')
|
|
406 |
+ |
|
407 |
+ # The project may have a default element defined
|
|
408 |
+ default_element = self._project_conf.get("defaults", {}).get("target-element", None)
|
|
409 |
+ |
|
410 |
+ if default_element:
|
|
411 |
+ return (default_element,)
|
|
412 |
+ |
|
413 |
+ directory = os.path.join(self.directory, element_directory)
|
|
414 |
+ for root, _, files in os.walk(directory):
|
|
415 |
+ for file in files:
|
|
416 |
+ if file.endswith(".bst"):
|
|
417 |
+ rel_dir = os.path.relpath(root, directory)
|
|
418 |
+ rel_file = os.path.join(rel_dir, file).lstrip("./")
|
|
419 |
+ output.append(rel_file)
|
|
420 |
+ return tuple(output)
|
|
421 |
+ |
|
394 | 422 |
# _load():
|
395 | 423 |
#
|
396 | 424 |
# Loads the project configuration file in the project
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ Main stack target for the bst build test
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ Main stack target for the bst build test
|
1 |
+# Project config for frontend build test
|
|
2 |
+name: test
|
|
3 |
+ |
|
4 |
+element-path: elements
|
|
5 |
+ |
|
6 |
+fatal-warnings:
|
|
7 |
+- bad-element-suffix
|
|
8 |
+ |
|
9 |
+defaults:
|
|
10 |
+ target-element: target2.bst
|
1 |
+kind: compose
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- fileNAME: import-dev.bst
|
|
5 |
+ type: build
|
|
6 |
+ |
|
7 |
+config:
|
|
8 |
+ # Dont try running the sandbox, we dont have a
|
|
9 |
+ # runtime to run anything in this context.
|
|
10 |
+ integrate: False
|
1 |
+kind: import
|
|
2 |
+sources:
|
|
3 |
+- kind: local
|
|
4 |
+ path: files/dev-files
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ Main stack target for the bst build test
|
|
5 |
+ |
|
6 |
+depends:
|
|
7 |
+- compose-all.bst
|
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 |
+# Project config for frontend build test
|
|
2 |
+name: test
|
|
3 |
+ |
|
4 |
+element-path: elements
|
... | ... | @@ -46,6 +46,27 @@ def test_show_invalid_element_path(cli, datafiles): |
46 | 46 |
'show',
|
47 | 47 |
"foo.bst"])
|
48 | 48 |
|
49 |
+ |
|
50 |
+@pytest.mark.datafiles(DATA_DIR + "_default")
|
|
51 |
+def test_show_default(cli, datafiles):
|
|
52 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
53 |
+ result = cli.run(project=project, silent=True, args=[
|
|
54 |
+ 'show'])
|
|
55 |
+ |
|
56 |
+ result.assert_success()
|
|
57 |
+ |
|
58 |
+ # Get the result output of "[state sha element]" and turn into a list
|
|
59 |
+ results = result.output.strip().split(" ")
|
|
60 |
+ expected = 'target2.bst'
|
|
61 |
+ assert results[2] == expected
|
|
62 |
+ |
|
63 |
+ |
|
64 |
+@pytest.mark.datafiles(DATA_DIR + "_fail")
|
|
65 |
+def test_show_fail(cli, datafiles):
|
|
66 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
67 |
+ result = cli.run(project=project, silent=True, args=[
|
|
68 |
+ 'show'])
|
|
69 |
+ |
|
49 | 70 |
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
50 | 71 |
|
51 | 72 |
|