move dry run info inside build log
authorEvan Martin <martine@danga.com>
Sun, 23 Jan 2011 20:00:55 +0000 (12:00 -0800)
committerEvan Martin <martine@danga.com>
Sun, 23 Jan 2011 20:00:55 +0000 (12:00 -0800)
src/build_log.cc
src/ninja.cc

index 144ae14..b8a782f 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "build.h"
 #include "graph.h"
 #include "ninja.h"
 
@@ -18,6 +19,9 @@ BuildLog::BuildLog()
   : log_file_(NULL), config_(NULL), needs_recompaction_(false) {}
 
 bool BuildLog::OpenForWrite(const string& path, string* err) {
+  if (config_ && config_->dry_run)
+    return true;  // Do nothing, report success.
+
   if (needs_recompaction_) {
     if (!Recompact(path, err))
       return false;
@@ -61,7 +65,6 @@ void BuildLog::Close() {
   log_file_ = NULL;
 }
 
-// Load the on-disk log.
 bool BuildLog::Load(const string& path, string* err) {
   FILE* file = fopen(path.c_str(), "r");
   if (!file) {
@@ -115,7 +118,6 @@ bool BuildLog::Load(const string& path, string* err) {
   return true;
 }
 
-// Lookup a previously-run command by its output path.
 BuildLog::LogEntry* BuildLog::LookupByOutput(const string& path) {
   Log::iterator i = log_.find(path);
   if (i != log_.end())
index 608297e..dc878d0 100644 (file)
@@ -181,7 +181,7 @@ int main(int argc, char** argv) {
     return 1;
   }
 
-  if (!config.dry_run && !build_log.OpenForWrite(kLogPath, &err)) {
+  if (!build_log.OpenForWrite(kLogPath, &err)) {
     fprintf(stderr, "error opening build log: %s\n", err.c_str());
     return 1;
   }