diff options
author | Evan Martin <martine@danga.com> | 2011-01-23 19:58:01 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-01-23 19:58:01 (GMT) |
commit | 8a95f48ad50c380cc8d30e7cd6720535547ca2dd (patch) | |
tree | c65e03351d3b8013651a57545ed1b760b8d5aece /src | |
parent | 4d463b48b8feb0691719a520d7ab825ece377a52 (diff) | |
download | Ninja-8a95f48ad50c380cc8d30e7cd6720535547ca2dd.zip Ninja-8a95f48ad50c380cc8d30e7cd6720535547ca2dd.tar.gz Ninja-8a95f48ad50c380cc8d30e7cd6720535547ca2dd.tar.bz2 |
pass config into build log
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 3 | ||||
-rw-r--r-- | src/build_log.cc | 3 | ||||
-rw-r--r-- | src/build_log.h | 3 | ||||
-rw-r--r-- | src/ninja.cc | 8 | ||||
-rw-r--r-- | src/ninja_jumble.cc | 1 |
5 files changed, 13 insertions, 5 deletions
diff --git a/src/build.cc b/src/build.cc index 9686b74..a75659a 100644 --- a/src/build.cc +++ b/src/build.cc @@ -373,5 +373,6 @@ void Builder::FinishEdge(Edge* edge) { return; int ms = status_->BuildEdgeFinished(edge); - log_->RecordCommand(edge, ms); + if (log_) + log_->RecordCommand(edge, ms); } diff --git a/src/build_log.cc b/src/build_log.cc index b5b429a..144ae14 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -14,7 +14,8 @@ // Once the number of redundant entries exceeds a threshold, we write // out a new file and replace the existing one with it. -BuildLog::BuildLog() : log_file_(NULL), needs_recompaction_(false) {} +BuildLog::BuildLog() + : log_file_(NULL), config_(NULL), needs_recompaction_(false) {} bool BuildLog::OpenForWrite(const string& path, string* err) { if (needs_recompaction_) { diff --git a/src/build_log.h b/src/build_log.h index 265f378..58a598e 100644 --- a/src/build_log.h +++ b/src/build_log.h @@ -2,6 +2,7 @@ #include <string> using namespace std; +struct BuildConfig; struct Edge; // Store a log of every command ran for every build. @@ -14,6 +15,7 @@ struct Edge; struct BuildLog { BuildLog(); + void SetConfig(BuildConfig* config) { config_ = config; } bool OpenForWrite(const string& path, string* err); void RecordCommand(Edge* edge, int time_ms); void Close(); @@ -42,5 +44,6 @@ struct BuildLog { typedef map<string, LogEntry*> Log; Log log_; FILE* log_file_; + BuildConfig* config_; bool needs_recompaction_; }; diff --git a/src/ninja.cc b/src/ninja.cc index 5daf2bd..608297e 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -171,13 +171,17 @@ int main(int argc, char** argv) { if (browse) return CmdBrowse(&state, argc, argv); + BuildLog build_log; + build_log.SetConfig(&config); + state.build_log_ = &build_log; + const char* kLogPath = ".ninja_log"; - if (!state.build_log_->Load(kLogPath, &err)) { + if (!build_log.Load(kLogPath, &err)) { fprintf(stderr, "error loading build log: %s\n", err.c_str()); return 1; } - if (!config.dry_run && !state.build_log_->OpenForWrite(kLogPath, &err)) { + if (!config.dry_run && !build_log.OpenForWrite(kLogPath, &err)) { fprintf(stderr, "error opening build log: %s\n", err.c_str()); return 1; } diff --git a/src/ninja_jumble.cc b/src/ninja_jumble.cc index 930ed59..a1ba219 100644 --- a/src/ninja_jumble.cc +++ b/src/ninja_jumble.cc @@ -118,7 +118,6 @@ const Rule State::kPhonyRule("phony"); State::State() : build_log_(NULL) { AddRule(&kPhonyRule); - build_log_ = new BuildLog; } const Rule* State::LookupRule(const string& rule_name) { |