diff options
-rw-r--r-- | src/build.cc | 15 | ||||
-rw-r--r-- | src/build.h | 1 | ||||
-rw-r--r-- | src/ninja.cc | 20 |
3 files changed, 20 insertions, 16 deletions
diff --git a/src/build.cc b/src/build.cc index deef7aa..2549553 100644 --- a/src/build.cc +++ b/src/build.cc @@ -372,17 +372,24 @@ Node* Builder::AddTarget(const string& name, string* err) { *err = "unknown target: '" + name + "'"; return NULL; } + if (!AddTarget(node, err)) + return NULL; + return node; +} + +bool Builder::AddTarget(Node* node, string* err) { node->file_->StatIfNecessary(disk_interface_); if (node->in_edge_) { if (!node->in_edge_->RecomputeDirty(state_, disk_interface_, err)) - return NULL; + return false; } if (!node->dirty_) - return NULL; // Intentionally no error. + return false; // Intentionally no error. if (!plan_.AddTarget(node, err)) - return NULL; - return node; + return false; + + return true; } bool Builder::Build(string* err) { diff --git a/src/build.h b/src/build.h index b5f53da..feb83d5 100644 --- a/src/build.h +++ b/src/build.h @@ -97,6 +97,7 @@ struct Builder { Builder(State* state, const BuildConfig& config); Node* AddTarget(const string& name, string* err); + bool AddTarget(Node* target, string* err); bool Build(string* err); bool StartEdge(Edge* edge, string* err); diff --git a/src/ninja.cc b/src/ninja.cc index 96530f6..43b19ea 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -374,11 +374,6 @@ int main(int argc, char** argv) { return 1; } } - if (optind >= argc && tool.empty()) { - Error("expected target to build"); - usage(config); - return 1; - } argv += optind; argc -= optind; @@ -440,14 +435,15 @@ int main(int argc, char** argv) { return 1; } - Builder builder(&state, config); - for (int i = 0; i < argc; ++i) { - string path = argv[i]; - string err; - if (!CanonicalizePath(&path, &err)) - Fatal("can't canonicalize '%s': %s", path.c_str(), err.c_str()); + vector<Node*> targets; + if (!CollectTargetsFromArgs(&state, argc, argv, &targets, &err)) { + Error("%s", err.c_str()); + return 1; + } - if (!builder.AddTarget(path, &err)) { + Builder builder(&state, config); + for (size_t i = 0; i < targets.size(); ++i) { + if (!builder.AddTarget(targets[i], &err)) { if (!err.empty()) { Error("%s", err.c_str()); return 1; |