Makefile: Restore use of dependency scanning cache

Since commit v2.8.0~27 (Major optimization of C/C++ dependency scanning,
2009-09-23) our `VaildDeps` cache of `depend.internal` content is
supposed to avoid re-scanning dependencies of object files whose
dependencies have not changed.  However, this was broken by changes to
`cmDependsC::WriteDependencies` by commit v3.1.0-rc1~272^2~1 (cmDepends:
Refactor object file path conversion, 2014-07-22).  The object file path
written to `depend.internal` was changed to a relative path, but the
lookup in the `ValidDeps` cache of that information was not updated too.
Therefore the cache is not used.

Fix the object file path used for the `ValidDeps` lookup to restore the
original optimization.
This commit is contained in:
tsecer harry 2018-03-20 15:59:00 +08:00 committed by Brad King
parent 882ba7fd11
commit 8c0f12c4aa

View File

@ -96,9 +96,16 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
std::set<std::string> dependencies;
bool haveDeps = false;
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
// Compute a path to the object file to write to the internal depend file.
// Any existing content of the internal depend file has already been
// loaded in ValidDeps with this path as a key.
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
if (this->ValidDeps != nullptr) {
std::map<std::string, DependencyVector>::const_iterator tmpIt =
this->ValidDeps->find(obj);
this->ValidDeps->find(obj_i);
if (tmpIt != this->ValidDeps->end()) {
dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
haveDeps = true;
@ -222,8 +229,6 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory
// convert the dependencies to paths relative to the home output
// directory. We must do the same here.
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
internalDepends << obj_i << std::endl;