summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-03-01 22:25:51 (GMT)
committerEvan Martin <martine@danga.com>2011-03-01 22:25:51 (GMT)
commit723b93b03f414ebe1412b65dc3f5080a51cdbedc (patch)
tree14919998f742be02726aec76539587cd9457c7bf
parent01880fb3a2a13f9071e9729c3a13752846828ed2 (diff)
downloadNinja-723b93b03f414ebe1412b65dc3f5080a51cdbedc.zip
Ninja-723b93b03f414ebe1412b65dc3f5080a51cdbedc.tar.gz
Ninja-723b93b03f414ebe1412b65dc3f5080a51cdbedc.tar.bz2
print short name of command before dumping command stdout/stderr
Previously we showed the full command line, but with this change we only show the full command line in verbose mode or when the command fails.
-rw-r--r--src/build.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/build.cc b/src/build.cc
index 95f20bc..874542a 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -234,20 +234,20 @@ void Plan::Dump() {
}
struct RealCommandRunner : public CommandRunner {
- RealCommandRunner(int parallelism) : parallelism_(parallelism) {}
+ RealCommandRunner(const BuildConfig& config) : config_(config) {}
virtual ~RealCommandRunner() {}
virtual bool CanRunMore();
virtual bool StartCommand(Edge* edge);
virtual bool WaitForCommands();
virtual Edge* NextFinishedCommand(bool* success);
- int parallelism_;
+ const BuildConfig& config_;
SubprocessSet subprocs_;
map<Subprocess*, Edge*> subproc_to_edge_;
};
bool RealCommandRunner::CanRunMore() {
- return ((int)subprocs_.running_.size()) < parallelism_;
+ return ((int)subprocs_.running_.size()) < config_.parallelism;
}
bool RealCommandRunner::StartCommand(Edge* edge) {
@@ -285,8 +285,17 @@ Edge* RealCommandRunner::NextFinishedCommand(bool* success) {
if (!*success ||
!subproc->stdout_.buf_.empty() ||
!subproc->stderr_.buf_.empty()) {
- printf("\n%s%s\n", *success ? "" : "FAILED: ",
- edge->EvaluateCommand().c_str());
+ // Print the command that is spewing before printing its output.
+ // Print the full command when it failed, otherwise the short name if
+ // available.
+ string to_print = edge->GetDescription();
+ if (to_print.empty() ||
+ config_.verbosity == BuildConfig::VERBOSE ||
+ !*success) {
+ to_print = edge->EvaluateCommand();
+ }
+
+ printf("\n%s%s\n", *success ? "" : "FAILED: ", to_print.c_str());
if (!subproc->stdout_.buf_.empty())
printf("%s\n", subproc->stdout_.buf_.c_str());
if (!subproc->stderr_.buf_.empty())
@@ -327,7 +336,7 @@ Builder::Builder(State* state, const BuildConfig& config)
if (config.dry_run)
command_runner_ = new DryRunCommandRunner;
else
- command_runner_ = new RealCommandRunner(config.parallelism);
+ command_runner_ = new RealCommandRunner(config);
status_ = new BuildStatus;
status_->verbosity_ = config.verbosity;
log_ = state->build_log_;