summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2019-08-02 15:04:39 +0200
committerGitHub <noreply@github.com>2019-08-02 15:04:39 +0200
commit70c8d75055b4fcb0ee6d9a41b908c554534725f6 (patch)
treedbde439bdc7fbd066454e9b8c8cd80c3b27240aa
parent20af31d586c1f1bddeaad0583adc17933d5465ce (diff)
parent85038a5947183e0ead7bd81d7b481228e1e0d13a (diff)
downloadninja-70c8d75055b4fcb0ee6d9a41b908c554534725f6.tar.gz
Merge pull request #1508 from mqudsi/colored_fail
Emit "FAILED: " in red if terminal supports ANSI color output
-rw-r--r--src/build.cc6
-rw-r--r--src/line_printer.cc4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/build.cc b/src/build.cc
index a055738..8ef88b5 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -139,7 +139,11 @@ void BuildStatus::BuildEdgeFinished(Edge* edge,
o != edge->outputs_.end(); ++o)
outputs += (*o)->path() + " ";
- printer_.PrintOnNewLine("FAILED: " + outputs + "\n");
+ if (printer_.supports_color()) {
+ printer_.PrintOnNewLine("\x1B[31m" "FAILED: " "\x1B[0m" + outputs + "\n");
+ } else {
+ printer_.PrintOnNewLine("FAILED: " + outputs + "\n");
+ }
printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n");
}
diff --git a/src/line_printer.cc b/src/line_printer.cc
index 55469d9..c93173e 100644
--- a/src/line_printer.cc
+++ b/src/line_printer.cc
@@ -58,7 +58,9 @@ LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) {
if (supports_color_) {
DWORD mode;
if (GetConsoleMode(console_, &mode)) {
- SetConsoleMode(console_, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
+ if (!SetConsoleMode(console_, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
+ supports_color_ = false;
+ }
}
}
#endif