summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-12-30 18:10:03 (GMT)
committerEvan Martin <martine@danga.com>2013-04-08 21:45:07 (GMT)
commit7c357182a4f672b9bdb901e5710887613eef20e8 (patch)
tree839542d5342207c07e904c053196ab8a23682436 /src/ninja.cc
parent78ed77667671cde08b5ef045226aae3f848b1b40 (diff)
downloadNinja-7c357182a4f672b9bdb901e5710887613eef20e8.zip
Ninja-7c357182a4f672b9bdb901e5710887613eef20e8.tar.gz
Ninja-7c357182a4f672b9bdb901e5710887613eef20e8.tar.bz2
load deps log at startup
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index da99020..9f4d67b 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -32,6 +32,7 @@
#include "browse.h"
#include "build.h"
#include "build_log.h"
+#include "deps_log.h"
#include "clean.h"
#include "disk_interface.h"
#include "edit_distance.h"
@@ -670,6 +671,36 @@ bool OpenBuildLog(BuildLog* build_log, const string& build_dir,
return true;
}
+/// Open the deps log: load it, then open for writing.
+/// @return false on error.
+bool OpenDepsLog(DepsLog* deps_log, const string& build_dir,
+ Globals* globals, DiskInterface* disk_interface) {
+ string path = ".ninja_deps";
+ if (!build_dir.empty())
+ path = build_dir + "/" + path;
+
+ string err;
+ if (!deps_log->Load(path, globals->state, &err)) {
+ Error("loading deps log %s: %s", path.c_str(), err.c_str());
+ return false;
+ }
+ if (!err.empty()) {
+ // Hack: Load() can return a warning via err by returning true.
+ Warning("%s", err.c_str());
+ err.clear();
+ }
+
+ if (!globals->config->dry_run) {
+ if (!deps_log->OpenForWrite(path, &err)) {
+ Error("opening deps log: %s", err.c_str());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
/// Dump the output requested by '-d stats'.
void DumpMetrics(Globals* globals) {
g_metrics->Report();
@@ -882,6 +913,10 @@ reload:
if (!OpenBuildLog(&build_log, build_dir, &globals, &disk_interface))
return 1;
+ DepsLog deps_log;
+ if (!OpenDepsLog(&deps_log, build_dir, &globals, &disk_interface))
+ return 1;
+
if (!rebuilt_manifest) { // Don't get caught in an infinite loop by a rebuild
// target that is never up to date.
Builder manifest_builder(globals.state, config, &build_log,