ENH: Since list file cache does not make much sense any more (because of proper list file parsing), and it actually adds unnecessary complications and make ctest scripting not work, take it out

This commit is contained in:
Andy Cedilnik 2006-02-07 08:49:42 -05:00
parent 515757007a
commit 4259971961
10 changed files with 13 additions and 138 deletions

View File

@ -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;
}

View File

@ -212,7 +212,6 @@ CMakeSetupDialog::~CMakeSetupDialog()
{
delete m_CMakeInstance;
// clean up globals
cmListFileCache::GetInstance()->ClearCache();
cmDynamicLoader::FlushCache();
}

View File

@ -1656,13 +1656,6 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
cmCTestBuildAndTestHandler* handler =
static_cast<cmCTestBuildAndTestHandler*>(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();

View File

@ -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<cmListFileFunction>::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;
}
}

View File

@ -62,42 +62,12 @@ struct cmListFile
:m_ModifiedTime(0)
{
}
bool ParseFile(const char* path, bool requireProjectCommand);
long int m_ModifiedTime;
std::vector<cmListFileFunction> 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<cmStdString, cmListFile> ListFileMap;
ListFileMap m_ListFileCache; // file name to ListFile map
typedef std::map<cmStdString, char*> UniqueStrings;
UniqueStrings m_UniqueStrings;
const char* GetUniqueStringPointer(const char* name);
static cmListFileCache* Instance; // singelton pointer
};
#endif

View File

@ -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());

View File

@ -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);

View File

@ -152,7 +152,6 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> 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());

View File

@ -121,7 +121,6 @@ int main(int ac, char** av)
#ifdef CMAKE_BUILD_WITH_CMAKE
cmDynamicLoader::FlushCache();
#endif
cmListFileCache::ClearCache();
return ret;
}

View File

@ -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;
}