diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-02-19 20:13:48 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-02-19 20:13:48 (GMT) |
commit | 89e037ee19ed033fee0830a0c56c7ae956265512 (patch) | |
tree | 7a98427243bde8b3e73210dee288784981b46f9c /Source/cmCacheManager.cxx | |
parent | a4bbb55efdbb8d1b948b55248b54a3532f2f9d41 (diff) | |
download | CMake-89e037ee19ed033fee0830a0c56c7ae956265512.zip CMake-89e037ee19ed033fee0830a0c56c7ae956265512.tar.gz CMake-89e037ee19ed033fee0830a0c56c7ae956265512.tar.bz2 |
ENH: first pass at cache, clean up the unix generator, clean up configure.in some
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r-- | Source/cmCacheManager.cxx | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 79d6366..f1682a9 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -16,10 +16,13 @@ #include "cmCacheManager.h" #include "cmSystemTools.h" +#include "cmCacheManager.h" +#include "cmMakefile.h" const char* cmCacheManagerTypes[] = { "BOOL", "PATH", + "FILEPATH", "STRING", 0 }; @@ -33,6 +36,7 @@ cmCacheManager::CacheEntryType cmCacheManager::StringToType(const char* s) { return static_cast<CacheEntryType>(i); } + ++i; } return STRING; } @@ -51,12 +55,15 @@ cmCacheManager* cmCacheManager::GetInstance() -bool cmCacheManager::LoadCache(const char* path) +bool cmCacheManager::LoadCache(cmMakefile* mf) { - std::ifstream fin(path); + std::string cacheFile = mf->GetHomeOutputDirectory(); + cacheFile += "/CMakeCache.txt"; + // clear the old cache + m_Cache.clear(); + std::ifstream fin(cacheFile.c_str()); if(!fin) { - cmSystemTools::Error("Unable to open cache file for load. ", path); return false; } const int bsize = 4096; @@ -64,37 +71,45 @@ bool cmCacheManager::LoadCache(const char* path) std::string inputLine; while(fin) { + // Format is key:type=value CacheEntry e; std::string key; - fin.getline(buffer, bsize, '|'); + fin.getline(buffer, bsize, ':'); key = buffer; - fin.getline(buffer, bsize, '|'); - e.m_Value = buffer; - fin.getline(buffer, bsize); // last token is separated by a newline + fin.getline(buffer, bsize, '='); e.m_Type = cmCacheManager::StringToType(buffer); + fin.getline(buffer, bsize); // last token is separated by a newline + e.m_Value = buffer; if(fin) { m_Cache[key] = e; } } + return true; } -bool cmCacheManager::SaveCache(const char* path) +bool cmCacheManager::SaveCache(cmMakefile* mf) { - std::ofstream fout(path); + std::string cacheFile = mf->GetHomeOutputDirectory(); + cacheFile += "/CMakeCache.txt"; + std::ofstream fout(cacheFile.c_str()); if(!fout) { - cmSystemTools::Error("Unable to open cache file for save. ", path); + cmSystemTools::Error("Unable to open cache file for save. ", + cacheFile.c_str()); return false; } for( std::map<std::string, CacheEntry>::iterator i = m_Cache.begin(); i != m_Cache.end(); ++i) { - fout << (*i).first.c_str() << " | " << (*i).second.m_Value << " | "; CacheEntryType t = (*i).second.m_Type; - fout << cmCacheManagerTypes[t]; + // Format is key:type=value + fout << (*i).first.c_str() << ":" + << cmCacheManagerTypes[t] << "=" + << (*i).second.m_Value << "\n"; } fout << "\n"; + return true; } void cmCacheManager::AddCacheEntry(const char* key, |