summaryrefslogtreecommitdiffstats
path: root/src/depfile_parser.cc
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit+github@google.com>2024-03-13 15:26:47 (GMT)
committerDavid 'Digit' Turner <digit+github@google.com>2024-03-15 21:43:16 (GMT)
commit9792634a1762e74552ac14ffc51a81fa5a3f353e (patch)
tree1e2c1c09ba3d228263544b8fe3f8e6b900ff9278 /src/depfile_parser.cc
parentab510c7a8cccbea0ea2c82531dc23893b551d55e (diff)
downloadNinja-9792634a1762e74552ac14ffc51a81fa5a3f353e.zip
Ninja-9792634a1762e74552ac14ffc51a81fa5a3f353e.tar.gz
Ninja-9792634a1762e74552ac14ffc51a81fa5a3f353e.tar.bz2
Support empty depfiles.
Some tools generate completely empty depfiles when there are no implicit inputs. This patch modifies the depfile parser to support them. Fixes #2357
Diffstat (limited to 'src/depfile_parser.cc')
-rw-r--r--src/depfile_parser.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc
index 98fba2e..7ce7290 100644
--- a/src/depfile_parser.cc
+++ b/src/depfile_parser.cc
@@ -54,6 +54,7 @@ bool DepfileParser::Parse(string* content, string* err) {
bool have_target = false;
bool parsing_targets = true;
bool poisoned_input = false;
+ bool is_empty = true;
while (in < end) {
bool have_newline = false;
// out: current output point (typically same as in, but can fall behind
@@ -335,6 +336,7 @@ yy32:
}
if (len > 0) {
+ is_empty = false;
StringPiece piece = StringPiece(filename, len);
// If we've seen this as an input before, skip it.
std::vector<StringPiece>::iterator pos = std::find(ins_.begin(), ins_.end(), piece);
@@ -363,7 +365,7 @@ yy32:
poisoned_input = false;
}
}
- if (!have_target) {
+ if (!have_target && !is_empty) {
*err = "expected ':' in depfile";
return false;
}