Skip to content

Commit 950e2b4

Browse files
committed
Format progress-status helpers (follow-up to #1336, #2507)
1 parent 0b2549c commit 950e2b4

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/build.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,7 @@ bool Builder::FinalizeEdgeAndReportStatus(Edge* edge, Plan::EdgeResult result,
877877
int64_t start_time_millis,
878878
int64_t end_time_millis,
879879
ExitStatus exit_code,
880-
const string& output,
881-
string* err) {
880+
const string& output, string* err) {
882881
bool plan_ok = plan_.EdgeFinished(edge, result, err);
883882
status_->BuildEdgeFinished(edge, start_time_millis, end_time_millis,
884883
exit_code, output);
@@ -918,9 +917,9 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) {
918917

919918
// The rest of this function only applies to successful commands.
920919
if (!result->success()) {
921-
return FinalizeEdgeAndReportStatus(
922-
edge, Plan::kEdgeFailed, start_time_millis, end_time_millis,
923-
result->status, result->output, err);
920+
return FinalizeEdgeAndReportStatus(edge, Plan::kEdgeFailed,
921+
start_time_millis, end_time_millis,
922+
result->status, result->output, err);
924923
}
925924

926925
// Restat the edge outputs
@@ -959,9 +958,9 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) {
959958
}
960959
}
961960

962-
if (!FinalizeEdgeAndReportStatus(
963-
edge, Plan::kEdgeSucceeded, start_time_millis, end_time_millis,
964-
result->status, result->output, err)) {
961+
if (!FinalizeEdgeAndReportStatus(edge, Plan::kEdgeSucceeded,
962+
start_time_millis, end_time_millis,
963+
result->status, result->output, err)) {
965964
return false;
966965
}
967966

src/build.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ struct Builder {
256256
int64_t start_time_millis,
257257
int64_t end_time_millis,
258258
ExitStatus exit_code,
259-
const std::string& output,
260-
std::string* err);
259+
const std::string& output, std::string* err);
261260

262261
/// Map of running edge to time the edge started running.
263262
typedef std::map<const Edge*, int> RunningEdgeMap;

src/status_printer.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ void StatusPrinter::RecalculateProgressPrediction() {
207207
}
208208

209209
void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis,
210-
int64_t end_time_millis, ExitStatus exit_code,
210+
int64_t end_time_millis,
211+
ExitStatus exit_code,
211212
const string& output) {
212213
time_millis_ = end_time_millis;
213214
++finished_edges_;
@@ -233,8 +234,8 @@ void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis,
233234
const bool is_tty = printer_.is_tty();
234235
const bool is_smart_terminal = printer_.is_smart_terminal();
235236
const bool is_final_edge = finished_edges_ == total_edges_;
236-
const bool has_status_format = progress_status_format_ &&
237-
progress_status_format_[0] != '\0';
237+
const bool has_status_format =
238+
progress_status_format_ && progress_status_format_[0] != '\0';
238239

239240
// Regular edges are always reported on completion. Console edges are
240241
// reported on completion in non-TTY mode and in smart terminals. For dumb
@@ -256,9 +257,9 @@ void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis,
256257

257258
string failed = "FAILED: [code=" + std::to_string(exit_code) + "] ";
258259
if (printer_.supports_color()) {
259-
printer_.PrintOnNewLine("\x1B[31m" + failed + "\x1B[0m" + outputs + "\n");
260+
printer_.PrintOnNewLine("\x1B[31m" + failed + "\x1B[0m" + outputs + "\n");
260261
} else {
261-
printer_.PrintOnNewLine(failed + outputs + "\n");
262+
printer_.PrintOnNewLine(failed + outputs + "\n");
262263
}
263264
printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n");
264265
}
@@ -487,8 +488,8 @@ void StatusPrinter::PrintStatus(const Edge* edge, int64_t time_millis) {
487488
}
488489
}
489490

490-
if (config_.verbosity == BuildConfig::QUIET
491-
|| config_.verbosity == BuildConfig::NO_STATUS_UPDATE)
491+
if (config_.verbosity == BuildConfig::QUIET ||
492+
config_.verbosity == BuildConfig::NO_STATUS_UPDATE)
492493
return;
493494

494495
RecalculateProgressPrediction();
@@ -499,8 +500,8 @@ void StatusPrinter::PrintStatus(const Edge* edge, int64_t time_millis) {
499500
if (to_print.empty() || force_full_command)
500501
to_print = edge->GetBinding("command");
501502

502-
to_print = FormatProgressStatus(progress_status_format_, time_millis)
503-
+ to_print;
503+
to_print =
504+
FormatProgressStatus(progress_status_format_, time_millis) + to_print;
504505

505506
printer_.Print(to_print,
506507
force_full_command ? LinePrinter::FULL : LinePrinter::ELIDE);

0 commit comments

Comments
 (0)