Permalink
Browse files

Merge pull request #436 from tfarina/dry-run-unnamed-namespace

Move DryRunCommandRunner into a unnamed namespace.
  • Loading branch information...
2 parents 733b2bd + 5cd579d commit 8bd8d170e9816bb602d3efbb1d90844762b5ad12 @evmar evmar committed Oct 2, 2012
Showing with 39 additions and 24 deletions.
  1. +39 −24 src/build.cc
View
@@ -38,6 +38,45 @@
#include "subprocess.h"
#include "util.h"
+namespace {
+
+/// A CommandRunner that doesn't actually run the commands.
+class DryRunCommandRunner : public CommandRunner {
+ public:
+ virtual ~DryRunCommandRunner() {}
+
+ // Overridden from CommandRunner:
+ virtual bool CanRunMore();
+ virtual bool StartCommand(Edge* edge);
+ virtual Edge* WaitForCommand(ExitStatus* status, string* /* output */);
+
+ private:
+ queue<Edge*> finished_;
+};
+
+bool DryRunCommandRunner::CanRunMore() {
+ return true;
+}
+
+bool DryRunCommandRunner::StartCommand(Edge* edge) {
+ finished_.push(edge);
+ return true;
+}
+
+Edge* DryRunCommandRunner::WaitForCommand(ExitStatus* status,
+ string* /*output*/) {
+ if (finished_.empty()) {
+ *status = ExitFailure;
+ return NULL;
+ }
+ *status = ExitSuccess;
+ Edge* edge = finished_.front();
+ finished_.pop();
+ return edge;
+}
+
+} // namespace
+
BuildStatus::BuildStatus(const BuildConfig& config)
: config_(config),
start_time_millis_(GetTimeMillis()),
@@ -528,30 +567,6 @@ Edge* RealCommandRunner::WaitForCommand(ExitStatus* status, string* output) {
return edge;
}
-/// A CommandRunner that doesn't actually run the commands.
-struct DryRunCommandRunner : public CommandRunner {
- virtual ~DryRunCommandRunner() {}
- virtual bool CanRunMore() {
- return true;
- }
- virtual bool StartCommand(Edge* edge) {
- finished_.push(edge);
- return true;
- }
- virtual Edge* WaitForCommand(ExitStatus* status, string* /* output */) {
- if (finished_.empty()) {
- *status = ExitFailure;
- return NULL;
- }
- *status = ExitSuccess;
- Edge* edge = finished_.front();
- finished_.pop();
- return edge;
- }
-
- queue<Edge*> finished_;
-};
-
Builder::Builder(State* state, const BuildConfig& config,
BuildLog* log, DiskInterface* disk_interface)
: state_(state), config_(config), disk_interface_(disk_interface),

0 comments on commit 8bd8d17

Please sign in to comment.