summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-05 01:07:23 (GMT)
committerEvan Martin <martine@danga.com>2012-01-05 17:06:57 (GMT)
commitdc3ffcdd4c840a697cdbc71f2c0121908977af9a (patch)
treee1fe8bec8a57a7d7cd540e911ae6f5951983b949 /src
parentb281249fafe68b4e6415af17132d38c059f3d9d4 (diff)
downloadNinja-dc3ffcdd4c840a697cdbc71f2c0121908977af9a.zip
Ninja-dc3ffcdd4c840a697cdbc71f2c0121908977af9a.tar.gz
Ninja-dc3ffcdd4c840a697cdbc71f2c0121908977af9a.tar.bz2
factor out the main builder call
Diffstat (limited to 'src')
-rw-r--r--src/ninja.cc66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index 7a4ad7f..a55bfc4 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -517,6 +517,41 @@ int RunTool(const string& tool, Globals* globals, int argc, char** argv) {
return 1;
}
+int RunBuild(Globals* globals, int argc, char** argv) {
+ string err;
+ vector<Node*> targets;
+ if (!CollectTargetsFromArgs(globals->state, argc, argv, &targets, &err)) {
+ Error("%s", err.c_str());
+ return 1;
+ }
+
+ Builder builder(globals->state, globals->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;
+ } else {
+ // Added a target that is already up-to-date; not really
+ // an error.
+ }
+ }
+ }
+
+ if (builder.AlreadyUpToDate()) {
+ printf("ninja: no work to do.\n");
+ return 0;
+ }
+
+ if (!builder.Build(&err)) {
+ printf("ninja: build stopped: %s.\n", err.c_str());
+ return 1;
+ }
+
+ return 0;
+}
+
+
} // anonymous namespace
int main(int argc, char** argv) {
@@ -645,34 +680,5 @@ reload:
}
}
- vector<Node*> targets;
- if (!CollectTargetsFromArgs(globals.state, argc, argv, &targets, &err)) {
- Error("%s", err.c_str());
- return 1;
- }
-
- Builder builder(globals.state, globals.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;
- } else {
- // Added a target that is already up-to-date; not really
- // an error.
- }
- }
- }
-
- if (builder.AlreadyUpToDate()) {
- printf("ninja: no work to do.\n");
- return 0;
- }
-
- if (!builder.Build(&err)) {
- printf("ninja: build stopped: %s.\n", err.c_str());
- return 1;
- }
-
- return 0;
+ return RunBuild(&globals, argc, argv);
}