summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-01-08 00:32:38 (GMT)
committerEvan Martin <martine@danga.com>2011-01-08 00:32:38 (GMT)
commit08a5452d05eae55bec40cd351718d62fd767227c (patch)
treeff6b10249c3400df7d7cf18bdd11788c4df6523d /src
parentbe51721782291cf5f8087729c574b1182f98c96c (diff)
downloadNinja-08a5452d05eae55bec40cd351718d62fd767227c.zip
Ninja-08a5452d05eae55bec40cd351718d62fd767227c.tar.gz
Ninja-08a5452d05eae55bec40cd351718d62fd767227c.tar.bz2
don't crash in tests where we don't use a log file
Diffstat (limited to 'src')
-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();