summaryrefslogtreecommitdiffstats
path: root/src/build_log.h
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2020-05-18 10:46:18 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2020-05-23 16:44:25 (GMT)
commitcc79afbc0510b7320d35fb481f0f200dec92cb43 (patch)
tree51485cf06f219f729167299f428242ed8c2cb04a /src/build_log.h
parentcf021f32e62370b7f9c8249a6c600cbe48e849c7 (diff)
downloadNinja-cc79afbc0510b7320d35fb481f0f200dec92cb43.zip
Ninja-cc79afbc0510b7320d35fb481f0f200dec92cb43.tar.gz
Ninja-cc79afbc0510b7320d35fb481f0f200dec92cb43.tar.bz2
Delay actually opening log files until the first write, fix #1724
Calling DepsLog/BuildLog::OpenForWrite will now only save the file path. The actual opening of the file (moved to OpenForWriteIfNeeded) happens right before the first write attempt. This is needed so that the files aren't held open when the generator runs (i.e. RebuildManifest) as it may call tools like recompact which won't be able to open the file on Windows. The disadvantage is that now the error reporting happens at a later time and will be reported as a failed write, not a failed open.
Diffstat (limited to 'src/build_log.h')
-rw-r--r--src/build_log.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/build_log.h b/src/build_log.h
index ebe0530..6d060d1 100644
--- a/src/build_log.h
+++ b/src/build_log.h
@@ -45,7 +45,10 @@ struct BuildLog {
BuildLog();
~BuildLog();
+ /// Prepares writing to the log file without actually opening it - that will
+ /// happen when/if it's needed
bool OpenForWrite(const string& path, const BuildLogUser& user, string* err);
+
bool RecordCommand(Edge* edge, int start_time, int end_time,
TimeStamp mtime = 0);
void Close();
@@ -91,8 +94,13 @@ struct BuildLog {
const Entries& entries() const { return entries_; }
private:
+ /// Should be called before using log_file_. When false is returned, errno
+ /// will be set.
+ bool OpenForWriteIfNeeded();
+
Entries entries_;
FILE* log_file_;
+ std::string log_file_path_;
bool needs_recompaction_;
};