print descriptions if available
authorEvan Martin <martine@danga.com>
Wed, 1 Dec 2010 00:32:16 +0000 (16:32 -0800)
committerEvan Martin <martine@danga.com>
Wed, 1 Dec 2010 00:32:16 +0000 (16:32 -0800)
build.cc
ninja.h
ninja_jumble.cc

index 83282e5..6fb9dc7 100644 (file)
--- 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<Subprocess*, Edge*>::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<Subprocess*, Edge*>::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 (file)
--- 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();
index 40d52b5..4a30eba 100644 (file)
@@ -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);