diff options
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakeDepend.cxx | 38 | ||||
-rw-r--r-- | Source/cmMakeDepend.h | 8 |
3 files changed, 44 insertions, 9 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index ffcd929..157e218 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -1904,8 +1904,11 @@ void cmLocalUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout) (*source)->GetDepends().begin(); dep != (*source)->GetDepends().end(); ++dep) { - std::string dependfile = - cmSystemTools::ConvertToOutputPath(cmSystemTools::CollapseFullPath(dep->c_str()).c_str()); + // do not call CollapseFullPath on dep here, because it already + // has been done because m_FullPath on cmDependInformation + // always is it called. If it is called here, network builds are + // very slow because of the number of stats + std::string dependfile = cmSystemTools::ConvertToOutputPath(dep->c_str()); // use the lower path function to create uniqe names std::string lowerpath = this->LowerCasePath(dependfile.c_str()); if(emittedLowerPath.insert(lowerpath).second) diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index e8812e7..3f6b38e 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -230,10 +230,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info) void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file) { cmDependInformation* dependInfo = - this->GetDependInformation(file, - cmSystemTools::GetFilenamePath( - cmSystemTools::CollapseFullPath( - info->m_FullPath.c_str())).c_str()); + this->GetDependInformation(file, info->m_PathOnly.c_str()); this->GenerateDependInformation(dependInfo); info->AddDependencies(dependInfo); } @@ -257,6 +254,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file, // Didn't find an instance. Create a new one and save it. cmDependInformation* info = new cmDependInformation; info->m_FullPath = fullPath; + info->m_PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str()); info->m_IncludeName = file; m_DependInformationMap[fullPath] = info; return info; @@ -291,9 +289,31 @@ void cmMakeDepend::GenerateMakefileDependencies() // find the full path to fname by searching the m_IncludeDirectories array std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) { + DirectoryToFileToPathMap::iterator m; + if(extraPath) + { + m = m_DirectoryToFileToPathMap.find(extraPath); + } + else + { + m = m_DirectoryToFileToPathMap.find(""); + } + + if(m != m_DirectoryToFileToPathMap.end()) + { + FileToPathMap& map = m->second; + FileToPathMap::iterator p = map.find(fname); + if(p != map.end()) + { + return p->second; + } + } + if(cmSystemTools::FileExists(fname)) { - return std::string(cmSystemTools::CollapseFullPath(fname)); + std::string fp = cmSystemTools::CollapseFullPath(fname); + m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; } for(std::vector<std::string>::iterator i = m_IncludeDirectories.begin(); @@ -307,7 +327,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) path = path + fname; if(cmSystemTools::FileExists(path.c_str())) { - return cmSystemTools::CollapseFullPath(path.c_str()); + std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); + m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; } } @@ -321,7 +343,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) path = path + fname; if(cmSystemTools::FileExists(path.c_str())) { - return cmSystemTools::CollapseFullPath(path.c_str()); + std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); + m_DirectoryToFileToPathMap[extraPath][fname] = fp; + return fp; } } diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h index d9045a5..6d5792a 100644 --- a/Source/cmMakeDepend.h +++ b/Source/cmMakeDepend.h @@ -61,6 +61,11 @@ public: std::string m_FullPath; /** + * Full path not including file name. + */ + std::string m_PathOnly; + + /** * Name used to #include this file. */ std::string m_IncludeName; @@ -154,8 +159,11 @@ protected: cmsys::RegularExpression m_IncludeFileRegularExpression; cmsys::RegularExpression m_ComplainFileRegularExpression; std::vector<std::string> m_IncludeDirectories; + typedef std::map<cmStdString, cmStdString> FileToPathMap; + typedef std::map<cmStdString, FileToPathMap> DirectoryToFileToPathMap; typedef std::map<cmStdString, cmDependInformation*> DependInformationMap; DependInformationMap m_DependInformationMap; + DirectoryToFileToPathMap m_DirectoryToFileToPathMap; }; #endif |