diff options
author | Evan Martin <martine@danga.com> | 2012-04-26 03:15:19 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-04-26 03:15:19 (GMT) |
commit | 256d00da2243f2c6d069ac04e86d5c8cf0f82075 (patch) | |
tree | e621755de6f607e899abaf4c11facc6dcd5d1014 | |
parent | c2098f931b6d93b6eae406598e2b46c175bd969f (diff) | |
parent | 3ba052b16265acb6ada689d7e9e517c25a507510 (diff) | |
download | Ninja-256d00da2243f2c6d069ac04e86d5c8cf0f82075.zip Ninja-256d00da2243f2c6d069ac04e86d5c8cf0f82075.tar.gz Ninja-256d00da2243f2c6d069ac04e86d5c8cf0f82075.tar.bz2 |
Merge pull request #228 from pcc/lazily-create-commandrunner
Lazily create the CommandRunner in Builder::Build
-rw-r--r-- | src/build.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/build.cc b/src/build.cc index a2e4f64..3ff90c3 100644 --- a/src/build.cc +++ b/src/build.cc @@ -513,10 +513,6 @@ struct DryRunCommandRunner : public CommandRunner { Builder::Builder(State* state, const BuildConfig& config) : state_(state), config_(config) { disk_interface_ = new RealDiskInterface; - if (config.dry_run) - command_runner_.reset(new DryRunCommandRunner); - else - command_runner_.reset(new RealCommandRunner(config)); status_ = new BuildStatus(config); log_ = state->build_log_; } @@ -589,6 +585,14 @@ bool Builder::Build(string* err) { int pending_commands = 0; int failures_allowed = config_.failures_allowed; + // Set up the command runner if we haven't done so already. + if (!command_runner_.get()) { + if (config_.dry_run) + command_runner_.reset(new DryRunCommandRunner); + else + command_runner_.reset(new RealCommandRunner(config_)); + } + // This main loop runs the entire build process. // It is structured like this: // First, we attempt to start as many commands as allowed by the |