diff options
author | Oleksandr Usov <a.s.usov@gmail.com> | 2012-03-12 19:14:07 (GMT) |
---|---|---|
committer | Oleksandr Usov <a.s.usov@gmail.com> | 2012-03-12 19:14:07 (GMT) |
commit | 73af0ec4d0074ce1e9b1677b3525ed92f5fd00c7 (patch) | |
tree | a8220600abd6f31fb3f9e7debc42b0c2589cc0f8 /src/depfile_parser.in.cc | |
parent | fffab7c868482cb8d24f40b42de958c074480226 (diff) | |
download | Ninja-73af0ec4d0074ce1e9b1677b3525ed92f5fd00c7.zip Ninja-73af0ec4d0074ce1e9b1677b3525ed92f5fd00c7.tar.gz Ninja-73af0ec4d0074ce1e9b1677b3525ed92f5fd00c7.tar.bz2 |
Issue #241 - handle depfiles generated by older versions of GCC
Older versions of GCC would produce broken depfiles when -MT or -MQ is used
gcc43 -MT foo.o -MMD -MF foo.o.d -o foo.o -c foo.c
will result in the following depfile
foo.o foo.o: <dependencies>
Parse multiple outputs unifying duplicates and correctly report errors if
they are different.
Diffstat (limited to 'src/depfile_parser.in.cc')
-rw-r--r-- | src/depfile_parser.in.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index de1c38f..419ed8d 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -31,8 +31,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). @@ -87,16 +89,22 @@ bool DepfileParser::Parse(string* content, string* err) { } 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; |