summaryrefslogtreecommitdiffstats
path: root/src/depfile_parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/depfile_parser.cc')
-rw-r--r--src/depfile_parser.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc
index 8f8f9fe..7219eb0 100644
--- a/src/depfile_parser.cc
+++ b/src/depfile_parser.cc
@@ -32,8 +32,10 @@
bool DepfileParser::Parse(string* content, string* err) {
// in: current parser input point.
// end: end of input.
+ // parsing_targets: whether we are parsing targets or dependencies.
char* in = &(*content)[0];
char* end = in + content->size();
+ bool parsing_targets = true;
while (in < end) {
// out: current output point (typically same as in, but can fall behind
// as we de-escape backslashes).
@@ -180,16 +182,22 @@ yy13:
}
int len = out - filename;
- if (len > 0 && filename[len - 1] == ':')
+ const bool is_target = parsing_targets;
+ if (len > 0 && filename[len - 1] == ':') {
len--; // Strip off trailing colon, if any.
+ parsing_targets = false;
+ }
if (len == 0)
continue;
- if (!out_.str_) {
- out_ = StringPiece(filename, len);
- } else {
+ if (!is_target) {
ins_.push_back(StringPiece(filename, len));
+ } else if (!out_.str_) {
+ out_ = StringPiece(filename, len);
+ } else if (out_ != StringPiece(filename, len)) {
+ *err = "depfile has multiple output paths.";
+ return false;
}
}
return true;