Skip to content

Commit

Permalink
Add command-line option to be intolerant of build noise.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdempsky committed Jun 12, 2014
1 parent 23a88ea commit 7cb5ec5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ bool Builder::Build(string* err) {
status_->PlanHasTotalEdges(plan_.command_edge_count());
int pending_commands = 0;
int failures_allowed = config_.failures_allowed;
bool noisy_output = false;

// Set up the command runner if we haven't done so already.
if (!command_runner_.get()) {
Expand Down Expand Up @@ -656,6 +657,10 @@ bool Builder::Build(string* err) {
failures_allowed--;
}

if (!result.output.empty()) {
noisy_output = true;
}

// We made some progress; start the main loop over.
continue;
}
Expand All @@ -676,6 +681,11 @@ bool Builder::Build(string* err) {
}

status_->BuildFinished();
if (noisy_output && !config_.tolerate_noise) {
*err = "subcommands produced noise";
return false;
}

return true;
}

Expand Down
6 changes: 5 additions & 1 deletion src/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ struct CommandRunner {
/// Options (e.g. verbosity, parallelism) passed to a build.
struct BuildConfig {
BuildConfig() : verbosity(NORMAL), dry_run(false), parallelism(1),
failures_allowed(1), max_load_average(-0.0f) {}
failures_allowed(1), max_load_average(-0.0f),
tolerate_noise(true) {}

enum Verbosity {
NORMAL,
Expand All @@ -137,6 +138,9 @@ struct BuildConfig {
/// The maximum load average we must not exceed. A negative value
/// means that we do not have any limit.
double max_load_average;
/// Controls whether a build that outputs messages is tolerated or
/// not.
bool tolerate_noise;
};

/// Builder wraps the build process: starting commands, updating status.
Expand Down
5 changes: 4 additions & 1 deletion src/ninja.cc
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ int ReadFlags(int* argc, char*** argv,

int opt;
while (!options->tool &&
(opt = getopt_long(*argc, *argv, "d:f:j:k:l:nt:vC:h", kLongOptions,
(opt = getopt_long(*argc, *argv, "d:f:j:k:l:nt:vC:Nh", kLongOptions,
NULL)) != -1) {
switch (opt) {
case 'd':
Expand Down Expand Up @@ -1001,6 +1001,9 @@ int ReadFlags(int* argc, char*** argv,
case 'C':
options->working_dir = optarg;
break;
case 'N':
config->tolerate_noise = false;
break;
case OPT_VERSION:
printf("%s\n", kNinjaVersion);
return 0;
Expand Down

0 comments on commit 7cb5ec5

Please sign in to comment.