return;
int ms = status_->BuildEdgeFinished(edge);
- log_->RecordCommand(edge, ms);
+ if (log_)
+ log_->RecordCommand(edge, ms);
}
// 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_) {
#include <string>
using namespace std;
+struct BuildConfig;
struct Edge;
// Store a log of every command ran for every build.
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();
typedef map<string, LogEntry*> Log;
Log log_;
FILE* log_file_;
+ BuildConfig* config_;
bool needs_recompaction_;
};
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;
}
State::State() : build_log_(NULL) {
AddRule(&kPhonyRule);
- build_log_ = new BuildLog;
}
const Rule* State::LookupRule(const string& rule_name) {