summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-09-23 18:02:05 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-09-23 18:02:05 (GMT)
commit39383ef8cb691656012275721064baef1e4f7511 (patch)
tree8d16274bd2092a6abe925bc7756c8a23594fd4b6 /Source/cmDependsC.cxx
parent551fcc23c220fd75eaeea7671f28e8360e466b75 (diff)
downloadCMake-39383ef8cb691656012275721064baef1e4f7511.zip
CMake-39383ef8cb691656012275721064baef1e4f7511.tar.gz
CMake-39383ef8cb691656012275721064baef1e4f7511.tar.bz2
Major optimization of C/C++ dependency scanning.
Now only the dependencies for the file where the dependencies actually may have changed are rescanned, before that this was done for all source files even if only one source file had changed. This reduces e.g. on my machine the time for scanning the dependencies of kdelibs/khtml/ when only one file (khtml_global.cpp) has changed from around 7.5 seconds to 1.2 seconds. The tests succeed, it does what I expected it to do on kdelibs, and Brad also reviewed the patch, so I think it should be ok. Alex
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx35
1 files changed, 33 insertions, 2 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index b431b29..99d17aa 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -34,12 +34,17 @@
//----------------------------------------------------------------------------
cmDependsC::cmDependsC()
+: ValidDeps(0)
{
}
//----------------------------------------------------------------------------
-cmDependsC::cmDependsC(cmLocalGenerator* lg, const char* targetDir,
- const char* lang): cmDepends(lg, targetDir)
+cmDependsC::cmDependsC(cmLocalGenerator* lg,
+ const char* targetDir,
+ const char* lang,
+ const std::map<std::string, DependencyVector>* validDeps)
+: cmDepends(lg, targetDir)
+, ValidDeps(validDeps)
{
cmMakefile* mf = lg->GetMakefile();
@@ -113,6 +118,32 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
return false;
}
+ if (this->ValidDeps != 0)
+ {
+ std::map<std::string, DependencyVector>::const_iterator tmpIt =
+ this->ValidDeps->find(obj);
+ if (tmpIt!= this->ValidDeps->end())
+ {
+ // Write the dependencies to the output stream. Makefile rules
+ // 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.
+ internalDepends << obj << std::endl;
+ for(DependencyVector::const_iterator i=tmpIt->second.begin();
+ i != tmpIt->second.end(); ++i)
+ {
+ makeDepends << obj << ": " <<
+ this->LocalGenerator->Convert(i->c_str(),
+ cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKEFILE)
+ << std::endl;
+ internalDepends << " " << i->c_str() << std::endl;
+ }
+ makeDepends << std::endl;
+ return true;
+ }
+ }
+
// Walk the dependency graph starting with the source file.
bool first = true;
UnscannedEntry root;