Skip to content

Commit

Permalink
Emit color job progress and job failure messages by default
Browse files Browse the repository at this point in the history
Set the default `NINJA_STATUS` and the "FAILED" text on job failure to
use ANSI color code escapes if running under a smart terminal.

Requires ninja-build#1454 to be merged first.
  • Loading branch information
mqudsi committed Jul 31, 2018
1 parent 5f42d00 commit 99fff21
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ BuildStatus::BuildStatus(const BuildConfig& config)
printer_.set_smart_terminal(false);

progress_status_format_ = getenv("NINJA_STATUS");
if (!progress_status_format_)
progress_status_format_ = "[%f/%t] ";
if (!progress_status_format_) {
if (printer_.is_smart_terminal())
progress_status_format_ = "\\033[32m[%f/%t] \\033[0m";
else
progress_status_format_ = "[%f/%t] ";
}
}

void BuildStatus::PlanHasTotalEdges(int total) {
Expand Down Expand Up @@ -151,7 +155,10 @@ void BuildStatus::BuildEdgeFinished(Edge* edge,
o != edge->outputs_.end(); ++o)
outputs += (*o)->path() + " ";

printer_.PrintOnNewLine("FAILED: " + outputs + "\n");
if (printer_.is_smart_terminal())
printer_.PrintOnNewLine("\x1B[31m" "FAILED: " "\x1B[0m" + outputs + "\n");
else
printer_.PrintOnNewLine("FAILED: " + outputs + "\n");
printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n");
}

Expand Down

0 comments on commit 99fff21

Please sign in to comment.