diff options
author | Evan Martin <martine@danga.com> | 2010-12-07 03:37:26 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2010-12-07 03:37:26 (GMT) |
commit | f38606e4e92b37bef216b495e17ec268f04eb8e6 (patch) | |
tree | 5062b5d5ecc97a182372ae852ee372fdd3580dcc /src | |
parent | 6d59ab8a7ddd548c34da618c6f9441197046c121 (diff) | |
download | Ninja-f38606e4e92b37bef216b495e17ec268f04eb8e6.zip Ninja-f38606e4e92b37bef216b495e17ec268f04eb8e6.tar.gz Ninja-f38606e4e92b37bef216b495e17ec268f04eb8e6.tar.bz2 |
verbose mode
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 10 | ||||
-rw-r--r-- | src/build.h | 2 | ||||
-rw-r--r-- | src/ninja.cc | 9 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/build.cc b/src/build.cc index 128ad7d..262fee5 100644 --- a/src/build.cc +++ b/src/build.cc @@ -13,10 +13,12 @@ struct BuildStatusLog { time_t last_update_; int finished_edges_, total_edges_; + bool verbose_; }; BuildStatusLog::BuildStatusLog() - : last_update_(time(NULL)), finished_edges_(0), total_edges_(0) {} + : last_update_(time(NULL)), finished_edges_(0), total_edges_(0), + verbose_(false) {} void BuildStatusLog::PlanHasTotalEdges(int total) { total_edges_ = total; @@ -24,7 +26,7 @@ void BuildStatusLog::PlanHasTotalEdges(int total) { void BuildStatusLog::BuildEdgeStarted(Edge* edge) { string desc = edge->GetDescription(); - if (!desc.empty()) + if (!verbose_ && !desc.empty()) printf("%s\n", desc.c_str()); else printf("%s\n", edge->EvaluateCommand().c_str()); @@ -217,6 +219,10 @@ Builder::Builder(State* state) log_ = new BuildStatusLog; } +void Builder::SetVerbose(bool verbose) { + log_->verbose_ = verbose; +} + Node* Builder::AddTarget(const string& name, string* err) { Node* node = state_->LookupNode(name); if (!node) { diff --git a/src/build.h b/src/build.h index bbde651..e362226 100644 --- a/src/build.h +++ b/src/build.h @@ -60,6 +60,8 @@ struct CommandRunner { struct Builder { Builder(State* state); + void SetVerbose(bool verbose); + Node* AddTarget(const string& name, string* err); bool Build(string* err); diff --git a/src/ninja.cc b/src/ninja.cc index f39c77f..fab3f3a 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -20,6 +20,7 @@ void usage() { "options:\n" " -g output graphviz dot file for targets and exit\n" " -i FILE specify input build file [default=build.ninja]\n" +" -v show all command lines\n" ); } @@ -33,8 +34,8 @@ int main(int argc, char** argv) { const char* input_file = "build.ninja"; int opt; - bool graph = false; - while ((opt = getopt_long(argc, argv, "ghi:", options, NULL)) != -1) { + bool graph = false, verbose = false; + while ((opt = getopt_long(argc, argv, "ghi:v", options, NULL)) != -1) { switch (opt) { case 'g': graph = true; @@ -42,6 +43,9 @@ int main(int argc, char** argv) { case 'i': input_file = optarg; break; + case 'v': + verbose = true; + break; case 'h': default: usage(); @@ -82,6 +86,7 @@ int main(int argc, char** argv) { } Builder builder(&state); + builder.SetVerbose(verbose); for (int i = 0; i < argc; ++i) { if (!builder.AddTarget(argv[i], &err)) { if (!err.empty()) { |