diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-05-09 21:29:14 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-05-09 21:29:14 +0900 |
commit | 071881c35ea88f3242936488d056f83320bd535f (patch) | |
tree | 46dd921e8ffbc0646ed9aa7d7f6c7a185b14bc88 /buildstream/_frontend/widget.py | |
parent | 8d85fb47651e0f243e22a83ba07c301fd36a6023 (diff) | |
download | buildstream-071881c35ea88f3242936488d056f83320bd535f.tar.gz |
frontend: Now display pipeline with the heading at startup time
For any tasks which run the scheduler and have a heading, now
display the full pipeline dependencies in build/stage order
using the same formatting as `bst show`. The format is configurable
in the user preferences.
Also added a %{full-key} formatting value so the user can decide
to display full keys instead of abbreviated keys, this automatically
applies both to the startup summary and `bst show`.
Diffstat (limited to 'buildstream/_frontend/widget.py')
-rw-r--r-- | buildstream/_frontend/widget.py | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py index 835f1ac78..61bc91d72 100644 --- a/buildstream/_frontend/widget.py +++ b/buildstream/_frontend/widget.py @@ -27,7 +27,8 @@ from .. import utils from ..plugin import _plugin_lookup from .._message import MessageType from .. import ImplError -from .. import Element, Scope +from .. import Element, Scope, Consistency +from . import Profile # Widget() @@ -382,7 +383,9 @@ class LogLine(Widget): # Args: # log_file (file): An optional file handle for additional logging # - def print_heading(self, context, project, target, arch, variant, log_file): + def print_heading(self, pipeline, variant, log_file): + context = pipeline.context + project = pipeline.project starttime = datetime.datetime.now() bst = pkg_resources.require("buildstream")[0] text = '' @@ -393,12 +396,12 @@ class LogLine(Widget): values = OrderedDict() values["Session Start"] = starttime.strftime('%A, %d-%m-%Y at %H:%M:%S') values["Project"] = "{} ({})".format(project.name, project.directory) - values["Target"] = target - values["Machine Architecture"] = arch + values["Target"] = pipeline.target.name + values["Machine Architecture"] = context.arch values["Variant"] = variant text += self.format_values(values) - # Main invocation context + # User configurations text += '\n' text += self.content_profile.fmt("User Configuration\n", bold=True) values = OrderedDict() @@ -411,6 +414,13 @@ class LogLine(Widget): values["Maximum Fetch Tasks"] = context.sched_fetchers values["Maximum Build Tasks"] = context.sched_builders text += self.format_values(values) + text += '\n' + + # Pipeline state + text += self.content_profile.fmt("Pipeline\n", bold=True) + deps = pipeline.dependencies(Scope.ALL) + text += self.show_pipeline(deps, context.log_element_format) + text += '\n' # Separator line before following output text += self.format_profile.fmt("~" * 79 + '\n') @@ -431,3 +441,60 @@ class LogLine(Widget): text += '\n' return text + + def show_pipeline(self, dependencies, format): + report = '' + p = Profile() + + for element in dependencies: + line = p.fmt_subst(format, 'name', element.name, fg='blue', bold=True) + cache_key = element._get_display_key() + full_key = element._get_cache_key() + + consistency = element._consistency() + if consistency == Consistency.INCONSISTENT: + line = p.fmt_subst(line, 'key', "") + line = p.fmt_subst(line, 'state', "no reference", fg='red') + else: + line = p.fmt_subst(line, 'key', cache_key, fg='yellow') + line = p.fmt_subst(line, 'full-key', full_key, fg='yellow') + if element._cached(): + line = p.fmt_subst(line, 'state', "cached", fg='magenta') + elif consistency == Consistency.RESOLVED: + line = p.fmt_subst(line, 'state', "fetch needed", fg='red') + elif element._buildable(): + line = p.fmt_subst(line, 'state', "buildable", fg='green') + else: + line = p.fmt_subst(line, 'state', "waiting", fg='blue') + + # Element configuration + if "%{config" in format: + config = _yaml.node_sanitize(element._Element__config) + line = p.fmt_subst( + line, 'config', + yaml.round_trip_dump(config, default_flow_style=False, allow_unicode=True)) + + # Variables + if "%{vars" in format: + variables = _yaml.node_sanitize(element._Element__variables.variables) + line = p.fmt_subst( + line, 'vars', + yaml.round_trip_dump(variables, default_flow_style=False, allow_unicode=True)) + + # Environment + if "%{env" in format: + environment = _yaml.node_sanitize(element._Element__environment) + line = p.fmt_subst( + line, 'env', + yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True)) + + # Public + if "%{public" in format: + environment = _yaml.node_sanitize(element._Element__public) + line = p.fmt_subst( + line, 'public', + yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True)) + + report += line + '\n' + + return report.rstrip('\n') |