diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2019-01-31 12:01:55 +0000 |
---|---|---|
committer | Chandan Singh <csingh43@bloomberg.net> | 2019-02-12 15:50:52 +0530 |
commit | 9b6c18e45cf96fad15bc15d767c627124a1722ee (patch) | |
tree | 0a292ff505dca5c5b660e44eb80a3768bec86554 /buildstream | |
parent | 86a9048a587f67fbb562f1188f9d04db0c220f75 (diff) | |
download | buildstream-9b6c18e45cf96fad15bc15d767c627124a1722ee.tar.gz |
_frontend: Allow printing dependencies using `bst show`
At present, there isn't an easy way to print anything from `bst show`
that would give the users an idea of what the dependency graph looks
like. One could use things like `--deps build`, but that will just print
a list, without any information about the dependency edges.
Add `%{deps}`, `%{build-deps}` and `%{runtime-deps}` format strings to
`bst show` that would simply print the list of all dependencies, build
dependencies and runtime dependencies respectively.
Summary of changes:
* buildstream/_frontend/cli.py: Add help for new format symbols.
* buildstream/_frontend/widget.py: Add support for new format symbols
for dependencies.
* tests/frontend/show.py: Add tests for new format symbols.
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_frontend/cli.py | 3 | ||||
-rw-r--r-- | buildstream/_frontend/widget.py | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index 49d5717b4..b3c4634a9 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -440,6 +440,9 @@ def show(app, elements, deps, except_, order, format_): %{public} Public domain data %{workspaced} If the element is workspaced %{workspace-dirs} A list of workspace directories + %{deps} A list of all dependencies + %{build-deps} A list of build dependencies + %{runtime-deps} A list of runtime dependencies The value of the %{symbol} without the leading '%' character is understood as a pythonic formatting string, so python formatting features apply, diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py index de122f8a3..b8e3d920a 100644 --- a/buildstream/_frontend/widget.py +++ b/buildstream/_frontend/widget.py @@ -27,7 +27,7 @@ from ruamel import yaml import click from . import Profile -from .. import Element, Consistency +from .. import Element, Consistency, Scope from .. import _yaml from .. import __version__ as bst_version from .._exceptions import ImplError @@ -435,6 +435,27 @@ class LogLine(Widget): line = p.fmt_subst( line, 'workspace-dirs', '') + # Dependencies + if "%{deps" in format_: + deps = [e.name for e in element.dependencies(Scope.ALL, recurse=False)] + line = p.fmt_subst( + line, 'deps', + yaml.safe_dump(deps, default_style=None).rstrip('\n')) + + # Build Dependencies + if "%{build-deps" in format_: + build_deps = [e.name for e in element.dependencies(Scope.BUILD, recurse=False)] + line = p.fmt_subst( + line, 'build-deps', + yaml.safe_dump(build_deps, default_style=False).rstrip('\n')) + + # Runtime Dependencies + if "%{runtime-deps" in format_: + runtime_deps = [e.name for e in element.dependencies(Scope.RUN, recurse=False)] + line = p.fmt_subst( + line, 'runtime-deps', + yaml.safe_dump(runtime_deps, default_style=False).rstrip('\n')) + report += line + '\n' return report.rstrip('\n') |