From 06a0f67f93435e49d14c45c234a0bf2246b28b83 Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Wed, 15 Aug 2001 13:40:56 -0400 Subject: 1. Added EXCLUDE option to LOAD_CACHE. 2. Entries brought in from another cache are now marked as internal. --- Source/cmCacheManager.cxx | 50 ++++++++++++++++++++++++++++++++++++------- Source/cmCacheManager.h | 2 ++ Source/cmLoadCacheCommand.cxx | 33 +++++++++++++++++++++++----- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 3715f09..7c01fe2 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -106,9 +106,18 @@ bool cmCacheManager::LoadCache(const char* path) { return this->LoadCache(path,true); } + bool cmCacheManager::LoadCache(const char* path, bool internal) { + std::set emptySet; + return this->LoadCache(path, internal, emptySet); +} + +bool cmCacheManager::LoadCache(const char* path, + bool internal, + std::set& excludes) +{ std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; // clear the old cache, if we are reading in internal values @@ -127,6 +136,9 @@ bool cmCacheManager::LoadCache(const char* path, cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); // input line is: "key":type=value cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); + + std::set::const_iterator iter; + std::string entryKey; while(fin) { // Format is key:type=value @@ -148,22 +160,44 @@ bool cmCacheManager::LoadCache(const char* path, } if(regQuoted.find(buffer)) { - e.m_Type = cmCacheManager::StringToType(regQuoted.match(2).c_str()); - // only load internal values if internal is set - if (internal || e.m_Type != INTERNAL) + entryKey = regQuoted.match(1); + if ( excludes.find(entryKey) == excludes.end() ) { + e.m_Type = cmCacheManager::StringToType(regQuoted.match(2).c_str()); + // only load internal values if internal is set + if (internal || e.m_Type != INTERNAL) + { + // If we are loading the cache from another project, + // make all loaded entries internal so that it is + // not visible in the gui + if (!internal) + { + e.m_Type = INTERNAL; + } e.m_Value = regQuoted.match(3); - m_Cache[regQuoted.match(1)] = e; + m_Cache[entryKey] = e; + } } } else if (reg.find(buffer)) { - e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str()); - // only load internal values if internal is set - if (internal || e.m_Type != INTERNAL) + entryKey = reg.match(1); + if ( excludes.find(entryKey) == excludes.end() ) { + e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str()); + // only load internal values if internal is set + if (internal || e.m_Type != INTERNAL) + { + // If we are loading the cache from another project, + // make all loaded entries internal so that it is + // not visible in the gui + if (!internal) + { + e.m_Type = INTERNAL; + } e.m_Value = reg.match(3); - m_Cache[reg.match(1)] = e; + m_Cache[entryKey] = e; + } } } else diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index bb7a971..206cec8 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -78,6 +78,8 @@ public: ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. bool LoadCache(const char* path); bool LoadCache(const char* path, bool internal); + bool LoadCache(const char* path, bool internal, + std::set& excludes); ///! Put cache definitions into makefile void DefineCache(cmMakefile*); diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 3c2c0f1..09e0480 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -21,16 +21,39 @@ bool cmLoadCacheCommand::InitialPass(std::vector& args) { if (args.size()< 1) { - this->SetError("called with wrong number of arguments."); + this->SetError("called with wrong number of arguments."); } - for( unsigned int i=0; i< args.size(); i++) + bool excludeFiles=false; + unsigned int excludeIndex=0; + unsigned int i; + std::set excludes; + + for(i=0; iExpandVariablesInString( args[i]); - cmCacheManager::GetInstance()->LoadCache(args[i].c_str(),false); - cmCacheManager::GetInstance()->DefineCache(m_Makefile); + if (excludeFiles) + { + m_Makefile->ExpandVariablesInString(args[i]); + excludes.insert(args[i]); + } + if (args[i] == "EXCLUDE") + { + excludeFiles=true; + } } + for(i=0; iExpandVariablesInString(args[i]); + cmCacheManager::GetInstance()->LoadCache(args[i].c_str(),false,excludes); + cmCacheManager::GetInstance()->DefineCache(m_Makefile); + } + + return true; } -- cgit v0.12