From ab4b4efcaf07d79bf7ef351faf2d20b513f568b5 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 27 Jun 2019 01:41:25 -0700 Subject: [PATCH] pipeline: report changed arg --- src/pipeline.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index 9bbddf14..298f55d2 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -114,14 +114,20 @@ bool CacheInvalid(VFS *vfs, IndexFile *prev, const std::string &path, // For inferred files, allow -o a a.cc -> -o b b.cc std::string stem = sys::path::stem(path); - bool changed = prev->args.size() != args.size(); - for (size_t i = 0; !changed && i < args.size(); i++) - if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem) - changed = true; - if (changed) + int changed = -1, size = std::min(prev->args.size(), args.size()); + for (int i = 0; i < size; i++) + if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem) { + changed = i; + break; + } + if (changed < 0 && prev->args.size() != args.size()) + changed = size; + if (changed >= 0) LOG_V(1) << "args changed for " << path - << (from ? " (via " + *from + ")" : std::string()); - return changed; + << (from ? " (via " + *from + ")" : std::string()) << "; old: " + << (changed < prev->args.size() ? prev->args[changed] : "") + << "; new: " << (changed < size ? args[changed] : ""); + return changed >= 0; }; std::string AppendSerializationFormat(const std::string &base) {