From a7ae53ad5174cc2a8ff1b4ee0727de142c305468 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Tue, 30 Nov 2010 16:32:16 -0800 Subject: [PATCH] print descriptions if available --- build.cc | 16 +++++++++++----- ninja.h | 1 + ninja_jumble.cc | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build.cc b/build.cc index 83282e5..6fb9dc7 100644 --- a/build.cc +++ b/build.cc @@ -102,7 +102,11 @@ bool RealCommandRunner::CanRunMore() { bool RealCommandRunner::StartCommand(Edge* edge) { string command = edge->EvaluateCommand(); - printf(" %s\n", command.c_str()); + string desc = edge->GetDescription(); + if (!desc.empty()) + printf(" %s\n", desc.c_str()); + else + printf(" %s\n", command.c_str()); Subprocess* subproc = new Subprocess; subproc_to_edge_.insert(make_pair(subproc, edge)); if (!subproc->Start(command)) @@ -125,15 +129,17 @@ Edge* RealCommandRunner::NextFinishedCommand(bool* success) { *success = subproc->Finish(); + map::iterator i = subproc_to_edge_.find(subproc); + Edge* edge = i->second; + subproc_to_edge_.erase(i); + + if (!*success) + printf("FAILED: %s\n", edge->EvaluateCommand().c_str()); if (!subproc->stdout_.buf_.empty()) printf("%s\n", subproc->stdout_.buf_.c_str()); if (!subproc->stderr_.buf_.empty()) printf("%s\n", subproc->stderr_.buf_.c_str()); - map::iterator i = subproc_to_edge_.find(subproc); - Edge* edge = i->second; - subproc_to_edge_.erase(i); - delete subproc; return edge; } diff --git a/ninja.h b/ninja.h index 9c881b7..8eabc3c 100644 --- a/ninja.h +++ b/ninja.h @@ -100,6 +100,7 @@ struct Edge { void MarkDirty(Node* node); bool RecomputeDirty(State* state, DiskInterface* disk_interface, string* err); string EvaluateCommand(); // XXX move to env, take env ptr + string GetDescription(); bool LoadDepFile(State* state, DiskInterface* disk_interface, string* err); void Dump(); diff --git a/ninja_jumble.cc b/ninja_jumble.cc index 40d52b5..4a30eba 100644 --- a/ninja_jumble.cc +++ b/ninja_jumble.cc @@ -206,6 +206,10 @@ string Edge::EvaluateCommand() { return rule_->command_.Evaluate(&env); } +string Edge::GetDescription() { + EdgeEnv env(this); + return rule_->description_.Evaluate(&env); +} FileStat* StatCache::GetFile(const string& path) { Paths::iterator i = paths_.find(path); -- 2.7.4