summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-02-27 00:35:03 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2012-02-27 00:39:58 (GMT)
commit3ba052b16265acb6ada689d7e9e517c25a507510 (patch)
tree6ea5af0388f72686d6ac0fed0efa504a05962ba1 /src
parenteab83e9774330a754e44ba023781e1c0a07d923f (diff)
downloadNinja-3ba052b16265acb6ada689d7e9e517c25a507510.zip
Ninja-3ba052b16265acb6ada689d7e9e517c25a507510.tar.gz
Ninja-3ba052b16265acb6ada689d7e9e517c25a507510.tar.bz2
Lazily create the CommandRunner in Builder::Build
This allows the user to interrupt the build (i.e. using Ctrl-C) while the build plan is being computed.
Diffstat (limited to 'src')
-rw-r--r--src/build.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/build.cc b/src/build.cc
index d3e88ee..2b9c657 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -479,10 +479,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_;
}
@@ -540,6 +536,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