diff options
author | Evan Martin <martine@danga.com> | 2010-12-13 16:36:57 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2010-12-13 16:37:05 (GMT) |
commit | 07171dd9d7aaa28580827b40203364862c2c0968 (patch) | |
tree | 6e2b42fd9dc55a3d521e347c574c34a4136370bc /src/build.cc | |
parent | 76327856c43414940c210325858b35b5fea09360 (diff) | |
download | Ninja-07171dd9d7aaa28580827b40203364862c2c0968.zip Ninja-07171dd9d7aaa28580827b40203364862c2c0968.tar.gz Ninja-07171dd9d7aaa28580827b40203364862c2c0968.tar.bz2 |
dry run flag
Diffstat (limited to 'src/build.cc')
-rw-r--r-- | src/build.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/build.cc b/src/build.cc index 262fee5..0666f8e 100644 --- a/src/build.cc +++ b/src/build.cc @@ -212,6 +212,29 @@ Edge* RealCommandRunner::NextFinishedCommand(bool* success) { return edge; } +struct DryRunCommandRunner : public CommandRunner { + virtual ~DryRunCommandRunner() {} + virtual bool CanRunMore() { + return true; + } + virtual bool StartCommand(Edge* edge) { + finished_.push(edge); + return true; + } + virtual void WaitForCommands() { + } + virtual Edge* NextFinishedCommand(bool* success) { + if (finished_.empty()) + return NULL; + *success = true; + Edge* edge = finished_.front(); + finished_.pop(); + return edge; + } + + queue<Edge*> finished_; +}; + Builder::Builder(State* state) : state_(state) { disk_interface_ = new RealDiskInterface; @@ -223,6 +246,11 @@ void Builder::SetVerbose(bool verbose) { log_->verbose_ = verbose; } +void Builder::SetDryRun(bool on) { + if (on) + command_runner_ = new DryRunCommandRunner; +} + Node* Builder::AddTarget(const string& name, string* err) { Node* node = state_->LookupNode(name); if (!node) { |