From 08a5452d05eae55bec40cd351718d62fd767227c Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Fri, 7 Jan 2011 16:32:38 -0800 Subject: don't crash in tests where we don't use a log file --- src/build.cc | 3 +-- src/build_log.cc | 5 +++++ src/build_log.h | 2 ++ 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::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(); -- cgit v0.12