| author | |
| committer | |
| log | 2caf39c96169be8eede11f2ec9887923b650315f |
| tree | a1b32a1fb4eff85406852bd377e8926cecc02229 |
| parent | 431b3b245959830ac385dd162b779a78c93b1c2d |
5 files changed, 39 insertions(+), 5 deletions(-)
src/cache_hash.cpp+35-5| ... | @@ -426,7 +426,7 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) { | ... | @@ -426,7 +426,7 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) { |
| 426 | } | 426 | } |
| 427 | return ErrorReadingDepFile; | 427 | return ErrorReadingDepFile; |
| 428 | } | 428 | } |
| 429 | SplitIterator it = memSplit(buf_to_slice(contents), str("\n")); | 429 | SplitIterator it = memSplit(buf_to_slice(contents), str("\r\n")); |
| 430 | // skip first line | 430 | // skip first line |
| 431 | SplitIterator_next(&it); | 431 | SplitIterator_next(&it); |
| 432 | for (;;) { | 432 | for (;;) { |
| ... | @@ -435,14 +435,44 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) { | ... | @@ -435,14 +435,44 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) { |
| 435 | break; | 435 | break; |
| 436 | if (opt_line.value.len == 0) | 436 | if (opt_line.value.len == 0) |
| 437 | continue; | 437 | continue; |
| 438 | SplitIterator line_it = memSplit(opt_line.value, str(" \t")); | 438 | // skip over indentation |
| 439 | Slice<uint8_t> filename; | 439 | while (opt_line.value.len != 0 && (opt_line.value.ptr[0] == ' ' || opt_line.value.ptr[0] == '\t')) { |
| 440 | if (!SplitIterator_next(&line_it).unwrap(&filename)) | 440 | opt_line.value.ptr += 1; |
| 441 | opt_line.value.len -= 1; | ||
| 442 | } | ||
| 443 | if (opt_line.value.len == 0) | ||
| 441 | continue; | 444 | continue; |
| 442 | Buf *filename_buf = buf_create_from_slice(filename); | 445 | if (opt_line.value.ptr[0] == '"') { |
| 446 | if (opt_line.value.len < 2) { | ||
| 447 | if (verbose) { | ||
| 448 | fprintf(stderr, "unable to process invalid .d file %s: line too short\n", buf_ptr(dep_file_path)); | ||
| 449 | } | ||
| 450 | return ErrorInvalidDepFile; | ||
| 451 | } | ||
| 452 | opt_line.value.ptr += 1; | ||
| 453 | opt_line.value.len -= 2; | ||
| 454 | while (opt_line.value.len != 0 && opt_line.value.ptr[opt_line.value.len] != '"') { | ||
| 455 | opt_line.value.len -= 1; | ||
| 456 | } | ||
| 457 | if (opt_line.value.len == 0) { | ||
| 458 | if (verbose) { | ||
| 459 | fprintf(stderr, "unable to process invalid .d file %s: missing double quote\n", buf_ptr(dep_file_path)); | ||
| 460 | } | ||
| 461 | return ErrorInvalidDepFile; | ||
| 462 | } | ||
| 463 | } else { | ||
| 464 | if (opt_line.value.ptr[opt_line.value.len - 1] == '\\') { | ||
| 465 | opt_line.value.len -= 2; // cut off ` \` | ||
| 466 | } | ||
| 467 | if (opt_line.value.len == 0) | ||
| 468 | continue; | ||
| 469 | } | ||
| 470 | |||
| 471 | Buf *filename_buf = buf_create_from_slice(opt_line.value); | ||
| 443 | if ((err = cache_add_file(ch, filename_buf))) { | 472 | if ((err = cache_add_file(ch, filename_buf))) { |
| 444 | if (verbose) { | 473 | if (verbose) { |
| 445 | fprintf(stderr, "unable to add %s to cache: %s\n", buf_ptr(filename_buf), err_str(err)); | 474 | fprintf(stderr, "unable to add %s to cache: %s\n", buf_ptr(filename_buf), err_str(err)); |
| 475 | fprintf(stderr, "when processing .d file: %s\n", buf_ptr(dep_file_path)); | ||
| 446 | } | 476 | } |
| 447 | return err; | 477 | return err; |
| 448 | } | 478 | } |
src/codegen.cpp+1| ... | @@ -8367,6 +8367,7 @@ static bool gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -8367,6 +8367,7 @@ static bool gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 8367 | 8367 | ||
| 8368 | Buf *out_dep_path = buf_sprintf("%s.d", buf_ptr(out_obj_path)); | 8368 | Buf *out_dep_path = buf_sprintf("%s.d", buf_ptr(out_obj_path)); |
| 8369 | args.append("-MD"); | 8369 | args.append("-MD"); |
| 8370 | args.append("-MV"); | ||
| 8370 | args.append("-MF"); | 8371 | args.append("-MF"); |
| 8371 | args.append(buf_ptr(out_dep_path)); | 8372 | args.append(buf_ptr(out_dep_path)); |
| 8372 | 8373 |
src/error.cpp+1| ... | @@ -38,6 +38,7 @@ const char *err_str(Error err) { | ... | @@ -38,6 +38,7 @@ const char *err_str(Error err) { |
| 38 | case ErrorPathTooLong: return "path too long"; | 38 | case ErrorPathTooLong: return "path too long"; |
| 39 | case ErrorCCompilerCannotFindFile: return "C compiler cannot find file"; | 39 | case ErrorCCompilerCannotFindFile: return "C compiler cannot find file"; |
| 40 | case ErrorReadingDepFile: return "failed to read .d file"; | 40 | case ErrorReadingDepFile: return "failed to read .d file"; |
| 41 | case ErrorInvalidDepFile: return "invalid .d file"; | ||
| 41 | case ErrorMissingArchitecture: return "missing architecture"; | 42 | case ErrorMissingArchitecture: return "missing architecture"; |
| 42 | case ErrorMissingOperatingSystem: return "missing operating system"; | 43 | case ErrorMissingOperatingSystem: return "missing operating system"; |
| 43 | case ErrorUnknownArchitecture: return "unrecognized architecture"; | 44 | case ErrorUnknownArchitecture: return "unrecognized architecture"; |
src/error.hpp+1| ... | @@ -40,6 +40,7 @@ enum Error { | ... | @@ -40,6 +40,7 @@ enum Error { |
| 40 | ErrorPathTooLong, | 40 | ErrorPathTooLong, |
| 41 | ErrorCCompilerCannotFindFile, | 41 | ErrorCCompilerCannotFindFile, |
| 42 | ErrorReadingDepFile, | 42 | ErrorReadingDepFile, |
| 43 | ErrorInvalidDepFile, | ||
| 43 | ErrorMissingArchitecture, | 44 | ErrorMissingArchitecture, |
| 44 | ErrorMissingOperatingSystem, | 45 | ErrorMissingOperatingSystem, |
| 45 | ErrorUnknownArchitecture, | 46 | ErrorUnknownArchitecture, |
src/translate_c.cpp+1| ... | @@ -4781,6 +4781,7 @@ Error parse_h_file(ZigType *import, ZigList<ErrorMsg *> *errors, const char *tar | ... | @@ -4781,6 +4781,7 @@ Error parse_h_file(ZigType *import, ZigList<ErrorMsg *> *errors, const char *tar |
| 4781 | Buf *prefix = buf_sprintf("%s" OS_SEP, buf_ptr(codegen->cache_dir)); | 4781 | Buf *prefix = buf_sprintf("%s" OS_SEP, buf_ptr(codegen->cache_dir)); |
| 4782 | out_dep_path = os_tmp_filename(prefix, buf_create_from_str(".d")); | 4782 | out_dep_path = os_tmp_filename(prefix, buf_create_from_str(".d")); |
| 4783 | clang_argv.append("-MD"); | 4783 | clang_argv.append("-MD"); |
| 4784 | clang_argv.append("-MV"); | ||
| 4784 | clang_argv.append("-MF"); | 4785 | clang_argv.append("-MF"); |
| 4785 | clang_argv.append(buf_ptr(out_dep_path)); | 4786 | clang_argv.append(buf_ptr(out_dep_path)); |
| 4786 | } | 4787 | } |