From cc7e0dde330b51a5f8d3640f00ecf17b8b1507d5 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 332f1dc2..65de7d51 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -126,14 +126,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) {