diff --git a/src/build.cc b/src/build.cc index d17e66d54d..8d9023bde2 100644 --- a/src/build.cc +++ b/src/build.cc @@ -885,7 +885,7 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) { running_edges_.erase(it); status_->BuildEdgeFinished(edge, start_time_millis, end_time_millis, - result->success(), result->output); + result->status, result->output); // The rest of this function only applies to successful commands. if (!result->success()) { diff --git a/src/status.h b/src/status.h index 29db7c203a..a873993446 100644 --- a/src/status.h +++ b/src/status.h @@ -16,6 +16,7 @@ #define NINJA_STATUS_H_ #include +#include "exit_status.h" struct BuildConfig; struct Edge; @@ -29,7 +30,7 @@ struct Status { virtual void BuildEdgeStarted(const Edge* edge, int64_t start_time_millis) = 0; virtual void BuildEdgeFinished(Edge* edge, int64_t start_time_millis, - int64_t end_time_millis, bool success, + int64_t end_time_millis, ExitStatus exit_code, const std::string& output) = 0; virtual void BuildStarted() = 0; virtual void BuildFinished() = 0; diff --git a/src/status_printer.cc b/src/status_printer.cc index 8db6809561..81ce58c344 100644 --- a/src/status_printer.cc +++ b/src/status_printer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "status_printer.h" +#include "exit_status.h" #ifdef _WIN32 #include "win32port.h" @@ -25,6 +26,7 @@ #include #include +#include #ifdef _WIN32 #include @@ -174,7 +176,7 @@ void StatusPrinter::RecalculateProgressPrediction() { } void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis, - int64_t end_time_millis, bool success, + int64_t end_time_millis, ExitStatus exit_code, const string& output) { time_millis_ = end_time_millis; ++finished_edges_; @@ -202,16 +204,17 @@ void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis, --running_edges_; // Print the command that is spewing before printing its output. - if (!success) { + if (exit_code != 0) { string outputs; for (vector::const_iterator o = edge->outputs_.begin(); o != edge->outputs_.end(); ++o) outputs += (*o)->path() + " "; + string failed = "FAILED [code " + std::to_string(exit_code) + "]: "; if (printer_.supports_color()) { - printer_.PrintOnNewLine("\x1B[31m" "FAILED: " "\x1B[0m" + outputs + "\n"); + printer_.PrintOnNewLine("\x1B[31m" + failed + "\x1B[0m" + outputs + "\n"); } else { - printer_.PrintOnNewLine("FAILED: " + outputs + "\n"); + printer_.PrintOnNewLine(failed + outputs + "\n"); } printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n"); } diff --git a/src/status_printer.h b/src/status_printer.h index 08a8d1a93d..213e9ce825 100644 --- a/src/status_printer.h +++ b/src/status_printer.h @@ -16,6 +16,7 @@ #include #include +#include "exit_status.h" #include "explanations.h" #include "line_printer.h" #include "status.h" @@ -31,7 +32,7 @@ struct StatusPrinter : Status { void BuildEdgeStarted(const Edge* edge, int64_t start_time_millis) override; void BuildEdgeFinished(Edge* edge, int64_t start_time_millis, - int64_t end_time_millis, bool success, + int64_t end_time_millis, ExitStatus exit_code, const std::string& output) override; void BuildStarted() override; void BuildFinished() override;