diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 5220fc800..a32d2e679 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -48,10 +48,8 @@ int cmCTestBuildAndTestHandler::ProcessHandler() m_Output = ""; std::string output; cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); int retv = this->RunCMakeAndTest(&m_Output); cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); return retv; } diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index a6ebc460e..534f71347 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -212,7 +212,6 @@ CMakeSetupDialog::~CMakeSetupDialog() { delete m_CMakeInstance; // clean up globals - cmListFileCache::GetInstance()->ClearCache(); cmDynamicLoader::FlushCache(); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 29e7f1d9a..fd96447a0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1656,13 +1656,6 @@ int cmCTest::Run(std::vectorconst& args, std::string* output) cmCTestBuildAndTestHandler* handler = static_cast(this->GetHandler("buildtest")); int retv = handler->ProcessHandler(); - /* - cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); - int retv = this->RunCMakeAndTest(output); - cmSystemTools::ResetErrorOccuredFlag(); - cmListFileCache::ClearCache(); - */ *output = handler->GetOutput(); #ifdef CMAKE_BUILD_WITH_CMAKE cmDynamicLoader::FlushCache(); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 35a596d7b..2013fb42f 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -25,65 +25,7 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer, cmListFileFunction& function, const char* filename); -cmListFileCache* cmListFileCache::Instance = 0; - - -cmListFileCache* cmListFileCache::GetInstance() -{ - if(!cmListFileCache::Instance) - { - cmListFileCache::Instance = new cmListFileCache; - } - return cmListFileCache::Instance; -} - - -void cmListFileCache::ClearCache() -{ - delete cmListFileCache::Instance; - cmListFileCache::Instance = 0; -} - - - -cmListFile* cmListFileCache::GetFileCache(const char* path, - bool requireProjectCommand) -{ - ListFileMap::iterator sl = m_ListFileCache.find(path); - if (sl == m_ListFileCache.end()) - { - // if not already in the map, then parse and store the - // file - if(!this->CacheFile(path, requireProjectCommand)) - { - return 0; - } - sl = m_ListFileCache.find(path); - if (sl == m_ListFileCache.end()) - { - cmSystemTools::Error("Fatal error, in cmListFileCache CacheFile failed", - path); - return 0; - } - } - cmListFile& ret = sl->second; - if(cmSystemTools::ModifiedTime(path) > ret.m_ModifiedTime ) - { - if(!this->CacheFile(path, requireProjectCommand)) - { - return 0; - } - else - { - sl = m_ListFileCache.find(path); - return &sl->second; - } - } - return &ret; -} - - -bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) +bool cmListFile::ParseFile(const char* path, bool requireProjectCommand) { if(!cmSystemTools::FileExists(path)) { @@ -110,8 +52,7 @@ bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) // Use a simple recursive-descent parser to process the token // stream. - cmListFile inFile; - inFile.m_ModifiedTime = cmSystemTools::ModifiedTime(filename); + this->m_ModifiedTime = cmSystemTools::ModifiedTime(filename); bool parseError = false; bool haveNewline = true; cmListFileLexer_Token* token; @@ -132,7 +73,7 @@ bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) inFunction.m_Line = token->line; if(cmListFileCacheParseFunction(lexer, inFunction, filename)) { - inFile.m_Functions.push_back(inFunction); + this->m_Functions.push_back(inFunction); } else { @@ -166,7 +107,7 @@ bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) } if (parseError) { - inFile.m_ModifiedTime = 0; + this->m_ModifiedTime = 0; } cmListFileLexer_Delete(lexer); @@ -176,8 +117,8 @@ bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) bool hasProject = false; // search for a project command for(std::vector::iterator i - = inFile.m_Functions.begin(); - i != inFile.m_Functions.end(); ++i) + = this->m_Functions.begin(); + i != this->m_Functions.end(); ++i) { if(cmSystemTools::LowerCase(i->m_Name) == "project") { @@ -192,23 +133,12 @@ bool cmListFileCache::CacheFile(const char* path, bool requireProjectCommand) project.m_Name = "PROJECT"; cmListFileArgument prj("Project", false, filename, 0); project.m_Arguments.push_back(prj); - inFile.m_Functions.insert(inFile.m_Functions.begin(),project); + this->m_Functions.insert(this->m_Functions.begin(),project); } } - m_ListFileCache[filename] = inFile; return true; } -void cmListFileCache::FlushCache(const char* path) -{ - ListFileMap::iterator it = m_ListFileCache.find(path); - if ( it != m_ListFileCache.end() ) - { - m_ListFileCache.erase(it); - return; - } -} - bool cmListFileCacheParseFunction(cmListFileLexer* lexer, cmListFileFunction& function, const char* filename) @@ -284,7 +214,7 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer, } //---------------------------------------------------------------------------- -const char* cmListFileCache::GetUniqueStringPointer(const char* name) +const char* cmListFile::GetUniqueStringPointer(const char* name) { UniqueStrings::iterator i = m_UniqueStrings.find(name); if(i == m_UniqueStrings.end()) @@ -296,12 +226,3 @@ const char* cmListFileCache::GetUniqueStringPointer(const char* name) return i->second; } -//---------------------------------------------------------------------------- -cmListFileCache::~cmListFileCache() -{ - for(UniqueStrings::iterator i = m_UniqueStrings.begin(); - i != m_UniqueStrings.end(); ++i) - { - delete [] i->second; - } -} diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 17239d2d6..fc35c379f 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -62,42 +62,12 @@ struct cmListFile :m_ModifiedTime(0) { } + bool ParseFile(const char* path, bool requireProjectCommand); long int m_ModifiedTime; std::vector m_Functions; -}; - -class cmListFileCache -{ -public: - static cmListFileCache* GetInstance(); - static void ClearCache(); - - - /** Return the cached version of the given file. - * If the file is not already in the cache, a cache entry - * will be made. If there is an error loading the file, - * NULL is returned. If requireProjectCommand is true, - * then a PROJECT(Project) command will be added to the file - * if it does not have a PROJECT command in it. - */ - cmListFile* GetFileCache(const char* path, bool requireProjectCommand); - - //! Flush cache file out of cache. - void FlushCache(const char* path); - - ~cmListFileCache(); -private: - // Cache the file - bool CacheFile(const char* path, bool requireProjectCommand); - // private data - typedef std::map ListFileMap; - ListFileMap m_ListFileCache; // file name to ListFile map - typedef std::map UniqueStrings; UniqueStrings m_UniqueStrings; const char* GetUniqueStringPointer(const char* name); - - static cmListFileCache* Instance; // singelton pointer }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7d38accb9..4fb853b1d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -378,20 +378,18 @@ bool cmMakefile::ReadListFile(const char* filename_in, const char *external_in) } } - cmListFile* lf = - cmListFileCache::GetInstance()->GetFileCache(filenametoread, - requireProjectCommand); - if(!lf) + cmListFile cacheFile; + if( !cacheFile.ParseFile(filenametoread, requireProjectCommand) ) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentFile.c_str()); return false; } // add this list file to the list of dependencies m_ListFiles.push_back( filenametoread); - const size_t numberFunctions = lf->m_Functions.size(); + const size_t numberFunctions = cacheFile.m_Functions.size(); for(size_t i =0; i < numberFunctions; ++i) { - this->ExecuteCommand(lf->m_Functions[i]); + this->ExecuteCommand(cacheFile.m_Functions[i]); if ( cmSystemTools::GetFatalErrorOccured() ) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentFile.c_str()); diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 900d2d750..faafde952 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -243,7 +243,6 @@ int cmTryCompileCommand::CoreTryCompileCode( // if They specified clean then we clean up what we can if (srcFileSignature && clean) { - cmListFileCache::GetInstance()->FlushCache(outFileName.c_str()); if(!mf->GetCMakeInstance()->GetDebugTryCompile()) { cmTryCompileCommand::CleanupFiles(binaryDirectory); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index a2179d8a7..f8525a387 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -152,7 +152,6 @@ bool cmTryRunCommand::InitialPass(std::vector const& argv) // if we created a directory etc, then cleanup after ourselves std::string cacheFile = binaryDirectory; cacheFile += "/CMakeLists.txt"; - cmListFileCache::GetInstance()->FlushCache(cacheFile.c_str()); if(!m_Makefile->GetCMakeInstance()->GetDebugTryCompile()) { cmTryCompileCommand::CleanupFiles(binaryDirectory.c_str()); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e63c3198f..1b52f2617 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -121,7 +121,6 @@ int main(int ac, char** av) #ifdef CMAKE_BUILD_WITH_CMAKE cmDynamicLoader::FlushCache(); #endif - cmListFileCache::ClearCache(); return ret; } diff --git a/Source/ctest.cxx b/Source/ctest.cxx index a2471d4f3..5a9053ff2 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -237,7 +237,6 @@ int main (int argc, char *argv[]) std::string output; int res = inst.Run(args,&output); cmCTestLog(&inst, OUTPUT, output); - cmListFileCache::ClearCache(); return res; }