diff options
author | Jan Niklas Hasse <jhasse@bixense.com> | 2020-05-18 10:46:18 (GMT) |
---|---|---|
committer | Jan Niklas Hasse <jhasse@bixense.com> | 2020-05-23 16:44:25 (GMT) |
commit | cc79afbc0510b7320d35fb481f0f200dec92cb43 (patch) | |
tree | 51485cf06f219f729167299f428242ed8c2cb04a /src/deps_log.h | |
parent | cf021f32e62370b7f9c8249a6c600cbe48e849c7 (diff) | |
download | Ninja-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/deps_log.h')
-rw-r--r-- | src/deps_log.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/deps_log.h b/src/deps_log.h index e7974a1..c4ada8b 100644 --- a/src/deps_log.h +++ b/src/deps_log.h @@ -110,8 +110,13 @@ struct DepsLog { // Write a node name record, assigning it an id. bool RecordId(Node* node); + /// Should be called before using file_. When false is returned, errno will + /// be set. + bool OpenForWriteIfNeeded(); + bool needs_recompaction_; FILE* file_; + std::string file_path_; /// Maps id -> Node. vector<Node*> nodes_; |