summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/build.cc3
-rw-r--r--src/build_log.cc5
-rw-r--r--src/build_log.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/build.cc b/src/build.cc
index 3483848..d02027d 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -337,6 +337,5 @@ void Builder::FinishEdge(Edge* edge) {
}
plan_.EdgeFinished(edge);
status_->BuildEdgeFinished(edge);
- if (log_)
- log_->RecordCommand(edge, 0); // XXX get edge timing.
+ log_->RecordCommand(edge, 0); // XXX get edge timing.
}
diff --git a/src/build_log.cc b/src/build_log.cc
index 4ee7cf1..666b80b 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -12,6 +12,8 @@
// older runs.
// XXX figure out recompaction strategy
+BuildLog::BuildLog() : log_file_(NULL) {}
+
bool BuildLog::OpenForWrite(const string& path, string* err) {
log_file_ = fopen(path.c_str(), "ab");
if (!log_file_) {
@@ -23,6 +25,9 @@ bool BuildLog::OpenForWrite(const string& path, string* err) {
}
void BuildLog::RecordCommand(Edge* edge, int time_ms) {
+ if (!log_file_)
+ return;
+
const string command = edge->EvaluateCommand();
for (vector<Node*>::iterator out = edge->outputs_.begin();
out != edge->outputs_.end(); ++out) {
diff --git a/src/build_log.h b/src/build_log.h
index 1d9463c..2442f70 100644
--- a/src/build_log.h
+++ b/src/build_log.h
@@ -12,6 +12,8 @@ struct Edge;
// 3) maybe we can generate some sort of build overview output
// from it
struct BuildLog {
+ BuildLog();
+
bool OpenForWrite(const string& path, string* err);
void RecordCommand(Edge* edge, int time_ms);
void Close();