diff options
-rw-r--r-- | Source/CursesDialog/cmCursesCacheEntryComposite.cxx | 15 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesCacheEntryComposite.h | 2 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 86 | ||||
-rw-r--r-- | Source/cmCacheManager.cxx | 232 | ||||
-rw-r--r-- | Source/cmCacheManager.h | 45 | ||||
-rw-r--r-- | Source/cmFindPathCommand.cxx | 9 | ||||
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 9 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 4 | ||||
-rw-r--r-- | Source/cmMarkAsAdvancedCommand.cxx | 21 | ||||
-rw-r--r-- | Source/cmVariableRequiresCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmakewizard.cxx | 58 | ||||
-rw-r--r-- | Source/cmakewizard.h | 2 |
12 files changed, 334 insertions, 153 deletions
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 8c11aee..8804a03 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -34,7 +34,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const char* key, const cmCacheManager::CacheEntry& value, bool isNew, + const char* key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth) : m_Key(key), m_LabelWidth(labelwidth), m_EntryWidth(entrywidth) { @@ -49,11 +49,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } m_Entry = 0; - switch ( value.m_Type ) + switch ( it.GetType() ) { case cmCacheManager::BOOL: m_Entry = new cmCursesBoolWidget(m_EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(value.m_Value.c_str())) + if (cmSystemTools::IsOn(it.GetValue())) { static_cast<cmCursesBoolWidget*>(m_Entry)->SetValueAsBool(true); } @@ -65,17 +65,20 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( case cmCacheManager::PATH: m_Entry = new cmCursesPathWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesPathWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); break; case cmCacheManager::FILEPATH: m_Entry = new cmCursesFilePathWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesFilePathWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); break; case cmCacheManager::STRING: m_Entry = new cmCursesStringWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesStringWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); + break; + case cmCacheManager::UNINITIALIZED: + cmSystemTools::Error("Found an undefined variable: ", it.GetName()); break; default: // TODO : put warning message here diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 2145d1c..4eac85e 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -25,7 +25,7 @@ class cmCursesCacheEntryComposite public: cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth); cmCursesCacheEntryComposite(const char* key, - const cmCacheManager::CacheEntry& value, + const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); const char* GetValue(); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index cd4aff2..c004cba 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -117,9 +117,9 @@ void cmCursesMainForm::InitializeUI() this->m_CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type != cmCacheManager::INTERNAL && - value.m_Type != cmCacheManager::STATIC ) + if ( i.GetType() != cmCacheManager::INTERNAL && + i.GetType() != cmCacheManager::STATIC && + i.GetType() != cmCacheManager::UNINITIALIZED) { ++count; } @@ -146,16 +146,16 @@ void cmCursesMainForm::InitializeUI() !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type == cmCacheManager::INTERNAL || - value.m_Type == cmCacheManager::STATIC ) + if ( i.GetType() == cmCacheManager::INTERNAL || + i.GetType() == cmCacheManager::STATIC || + i.GetType() == cmCacheManager::UNINITIALIZED ) { continue; } if (!this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, value, + newEntries->push_back(new cmCursesCacheEntryComposite(key, i, true, 30, entrywidth)); m_OkToGenerate = false; @@ -168,16 +168,16 @@ void cmCursesMainForm::InitializeUI() !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type == cmCacheManager::INTERNAL || - value.m_Type == cmCacheManager::STATIC ) + if ( i.GetType() == cmCacheManager::INTERNAL || + i.GetType() == cmCacheManager::STATIC || + i.GetType() == cmCacheManager::UNINITIALIZED ) { continue; } if (this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, value, + newEntries->push_back(new cmCursesCacheEntryComposite(key, i, false, 30, entrywidth)); } @@ -224,9 +224,9 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && - this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -243,8 +243,9 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && - this->m_CMakeInstance->GetCacheManager()->IsAdvanced((*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -302,9 +303,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) - { + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + { continue; } m_NumberOfVisibleEntries++; @@ -318,8 +320,9 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -453,14 +456,20 @@ void cmCursesMainForm::UpdateStatusBar() // Get the help string of the current entry // and add it to the help string char help[128]; - const char* helpString; - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry(curField); - if (entry) + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField); + if (!it.IsAtEnd()) { - helpString = entry->m_HelpString.c_str(); - strncpy(help, helpString, 127); - help[127] = '\0'; + const char* hs = it.GetProperty("HELPSTRING"); + if ( hs ) + { + strncpy(help, hs, 127); + help[127] = '\0'; + } + else + { + help[0] = 0; + } } else { @@ -686,23 +695,22 @@ void cmCursesMainForm::FillCacheManagerFromUI() int size = m_Entries->size(); for(int i=0; i < size; i++) { - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry( + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator( (*m_Entries)[i]->m_Key.c_str()); - if (entry) + if (!it.IsAtEnd()) { tmpString = (*m_Entries)[i]->m_Entry->GetValue(); // Remove trailing spaces, convert path to unix slashes std::string tmpSubString = tmpString.substr(0,tmpString.find_last_not_of(" ")+1); - if ( entry->m_Type == cmCacheManager::PATH || - entry->m_Type == cmCacheManager::FILEPATH ) + if ( it.GetType() == cmCacheManager::PATH || + it.GetType() == cmCacheManager::FILEPATH ) { cmSystemTools::ConvertToUnixSlashes(tmpSubString); } - entry->m_Value = tmpSubString; - + it.SetValue(tmpSubString.c_str()); } } } @@ -842,11 +850,11 @@ void cmCursesMainForm::HandleInput() m_Fields[index-2])); const char* curField = lbl->GetValue(); const char* helpString=0; - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry(curField); - if (entry) + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField); + if (!it.IsAtEnd()) { - helpString = entry->m_HelpString.c_str(); + helpString = it.GetProperty("HELPSTRING"); } if (helpString) { diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 598deb8..64a2edc 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -33,6 +33,7 @@ const char* cmCacheManagerTypes[] = "STRING", "INTERNAL", "STATIC", + "UNINITIALIZED", 0 }; @@ -153,7 +154,7 @@ bool cmCacheManager::LoadCache(const char* path, } while(realbuffer[0] == '/' && realbuffer[1] == '/') { - e.m_HelpString += &realbuffer[2]; + e.m_Properties["HELPSTRING"] += &realbuffer[2]; fin.getline(realbuffer, bsize); if(!fin) { @@ -177,14 +178,34 @@ bool cmCacheManager::LoadCache(const char* path, if (!internal) { e.m_Type = INTERNAL; - e.m_HelpString = "DO NOT EDIT, "; - e.m_HelpString += entryKey; - e.m_HelpString += " loaded from external file. " + e.m_Properties["HELPSTRING"] = "DO NOT EDIT, "; + e.m_Properties["HELPSTRING"] += entryKey; + e.m_Properties["HELPSTRING"] += " loaded from external file. " "To change this value edit this file: "; - e.m_HelpString += path; - e.m_HelpString += "/CMakeCache.txt" ; + e.m_Properties["HELPSTRING"] += path; + e.m_Properties["HELPSTRING"] += "/CMakeCache.txt" ; } - m_Cache[entryKey] = e; + if ( e.m_Type == cmCacheManager::INTERNAL && + (entryKey.size() > strlen("-ADVANCED")) && + strcmp(entryKey.c_str() + (entryKey.size() - strlen("-ADVANCED")), + "-ADVANCED") == 0 ) + { + std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-ADVANCED"))); + cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str()); + if ( it.IsAtEnd() ) + { + e.m_Type = cmCacheManager::UNINITIALIZED; + m_Cache[akey] = e; + } + else + { + it.SetProperty("ADVANCED", true); + } + } + else + { + m_Cache[entryKey] = e; + } } } } @@ -295,10 +316,24 @@ bool cmCacheManager::SaveCache(const char* path) { const CacheEntry& ce = (*i).second; CacheEntryType t = ce.m_Type; - if(t != INTERNAL) + if(t == cmCacheManager::UNINITIALIZED) + { + cmSystemTools::Error("Cache entry \"", (*i).first.c_str(), + "\" is uninitialized"); + } + else if(t != INTERNAL) { // Format is key:type=value - cmCacheManager::OutputHelpString(fout, ce.m_HelpString); + std::map<cmStdString,cmStdString>::const_iterator it = + ce.m_Properties.find("HELPSTRING"); + if ( it == ce.m_Properties.end() ) + { + cmCacheManager::OutputHelpString(fout, "Missing description"); + } + else + { + cmCacheManager::OutputHelpString(fout, it->second); + } std::string key; // support : in key name by double quoting if((*i).first.find(':') != std::string::npos || @@ -335,42 +370,72 @@ bool cmCacheManager::SaveCache(const char* path) fout << "########################\n"; fout << "\n"; - for( std::map<cmStdString, CacheEntry>::const_iterator i = m_Cache.begin(); - i != m_Cache.end(); ++i) + for( cmCacheManager::CacheIterator i = this->NewIterator(); + !i.IsAtEnd(); i.Next()) { - const CacheEntry& ce = (*i).second; - CacheEntryType t = ce.m_Type; - if(t == INTERNAL) + CacheEntryType t = i.GetType(); + bool advanced = i.GetPropertyAsBool("ADVANCED"); + if ( advanced ) { // Format is key:type=value - cmCacheManager::OutputHelpString(fout, ce.m_HelpString); std::string key; + std::string rkey = i.GetName(); + std::string helpstring; + // If this is advanced variable, we have to do some magic for + // backward compatibility + helpstring = "Advanced flag for variable: "; + helpstring += i.GetName(); + rkey += "-ADVANCED"; + cmCacheManager::OutputHelpString(fout, helpstring.c_str()); // support : in key name by double quoting - if((*i).first.find(':') != std::string::npos || - (*i).first.find("//") == 0) + if(rkey.find(':') != std::string::npos || + rkey.find("//") == 0) { key = "\""; - key += i->first; + key += rkey; key += "\""; } else { - key = i->first; + key = rkey; + } + fout << key.c_str() << ":INTERNAL=1\n"; + } + if(t == cmCacheManager::INTERNAL) + { + // Format is key:type=value + std::string key; + std::string rkey = i.GetName(); + std::string helpstring; + helpstring = i.GetProperty("HELPSTRING"); + cmCacheManager::OutputHelpString(fout, helpstring.c_str()); + // support : in key name by double quoting + if(rkey.find(':') != std::string::npos || + rkey.find("//") == 0) + { + key = "\""; + key += rkey; + key += "\""; + } + else + { + key = rkey; } fout << key.c_str() << ":" << cmCacheManagerTypes[t] << "="; // if value has trailing space or tab, enclose it in single quotes - if (ce.m_Value.size() && - (ce.m_Value[ce.m_Value.size() - 1] == ' ' || - ce.m_Value[ce.m_Value.size() - 1] == '\t')) + std::string value = i.GetValue(); + if (value.size() && + (value[value.size() - 1] == ' ' || + value[value.size() - 1] == '\t')) { - fout << '\'' << ce.m_Value << '\''; - } + fout << '\'' << value << '\''; + } else { - fout << ce.m_Value; + fout << value; } - fout << "\n"; + fout << "\n"; } } fout << "\n"; @@ -439,6 +504,11 @@ cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key) return 0; } +cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char *key) +{ + return CacheIterator(*this, key); +} + const char* cmCacheManager::GetCacheValue(const char* key) const { CacheEntryMap::const_iterator i = m_Cache.find(key); @@ -473,15 +543,29 @@ void cmCacheManager::AddCacheEntry(const char* key, const char* helpString, CacheEntryType type) { - CacheEntry e; - e.m_Value = value; + CacheEntry& e = m_Cache[key]; + if ( value ) + { + e.m_Value = value; + } + else + { + e.m_Value = "(none)"; + } e.m_Type = type; // make sure we only use unix style paths if(type == FILEPATH || type == PATH) { cmSystemTools::ConvertToUnixSlashes(e.m_Value); - } - e.m_HelpString = helpString; + } + if ( helpString ) + { + e.m_Properties["HELPSTRING"] = helpString; + } + else + { + e.m_Properties["HELPSTRING"] = "(This variable does not exists and should not be used)"; + } m_Cache[key] = e; } @@ -498,29 +582,91 @@ void cmCacheManager::AddCacheEntry(const char* key, bool v, } } -bool cmCacheManager::IsAdvanced(const char* key) +bool cmCacheManager::CacheIterator::IsAtEnd() +{ + return m_Position == m_Container.m_Cache.end(); +} + +void cmCacheManager::CacheIterator::Begin() +{ + m_Position = m_Container.m_Cache.begin(); +} + +bool cmCacheManager::CacheIterator::Find(const char* key) +{ + m_Position = m_Container.m_Cache.find(key); + return this->IsAtEnd(); +} + +void cmCacheManager::CacheIterator::Next() +{ + ++m_Position; +} + +void cmCacheManager::CacheIterator::SetValue(const char* value) +{ + CacheEntry* entry = &this->GetEntry(); + entry->m_Value = value; +} + +const char* cmCacheManager::CacheIterator::GetProperty(const char* property) const { - std::string advancedVar = key; - advancedVar += "-ADVANCED"; - const char* value = this->GetCacheValue(advancedVar.c_str()); - if(value) + if ( !strcasecmp(property, "TYPE") || !strcasecmp(property, "VALUE") ) + { + cmSystemTools::Error("Property \"", property, + "\" cannot be accessed through the GetProperty()"); + return 0; + } + const CacheEntry* ent = &this->GetEntry(); + std::map<cmStdString,cmStdString>::const_iterator it = + ent->m_Properties.find(property); + if ( it == ent->m_Properties.end() ) { - return cmSystemTools::IsOn(value); + return 0; } - return false; + return it->second.c_str(); } -bool cmCacheManager::CacheIterator::IsAtEnd() +void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) { - return position == m_Container.m_Cache.end(); + if ( !strcasecmp(p, "TYPE") || !strcasecmp(p, "VALUE") ) + { + cmSystemTools::Error("Property \"", p, + "\" cannot be accessed through the SetProperty()"); + return; + } + CacheEntry* ent = &this->GetEntry(); + ent->m_Properties[p] = v; } -void cmCacheManager::CacheIterator::Begin() +bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* property) const { - position = m_Container.m_Cache.begin(); + if ( !strcasecmp(property, "TYPE") || !strcasecmp(property, "VALUE") ) + { + cmSystemTools::Error("Property \"", property, + "\" cannot be accessed through the GetPropertyAsBool()"); + return false; + } + const CacheEntry* ent = &this->GetEntry(); + std::map<cmStdString,cmStdString>::const_iterator it = + ent->m_Properties.find(property); + if ( it == ent->m_Properties.end() ) + { + return false; + } + return cmSystemTools::IsOn(it->second.c_str()); } -void cmCacheManager::CacheIterator::Next() + +void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) { - ++position; + if ( !strcasecmp(p, "TYPE") || !strcasecmp(p, "VALUE") ) + { + cmSystemTools::Error("Property \"", p, + "\" cannot be accessed through the SetProperty()"); + return; + } + CacheEntry* ent = &this->GetEntry(); + ent->m_Properties[p] = v ? "ON" : "OFF"; } + diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 243506e..bdf7760 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -29,28 +29,44 @@ class cmMakefile; class cmCacheManager { public: - enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC }; + enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,UNINITIALIZED }; + +private: struct CacheEntry { std::string m_Value; - std::string m_HelpString; CacheEntryType m_Type; + std::map<cmStdString,cmStdString> m_Properties; }; + +public: class CacheIterator { public: void Begin(); + bool Find(const char*); bool IsAtEnd(); void Next(); - const char *GetName() { - return position->first.c_str(); } - CacheEntry const &GetEntry() { - return position->second; } - cmCacheManager const &m_Container; - std::map<cmStdString, CacheEntry>::const_iterator position; - CacheIterator(cmCacheManager const &foo) : m_Container(foo) { + const char *GetName() const { + return m_Position->first.c_str(); } + const char* GetProperty(const char*) const ; + bool GetPropertyAsBool(const char*) const ; + void SetProperty(const char* property, const char* value); + void SetProperty(const char* property, bool value); + const char* GetValue() const { return this->GetEntry().m_Value.c_str(); } + void SetValue(const char*); + CacheEntryType GetType() const { return this->GetEntry().m_Type; } + cmCacheManager &m_Container; + std::map<cmStdString, CacheEntry>::iterator m_Position; + CacheIterator(cmCacheManager &foo) : m_Container(foo) { this->Begin(); } + CacheIterator(cmCacheManager &foo, const char* key) : m_Container(foo) { + this->Find(key); + } + private: + CacheEntry const& GetEntry() const { return m_Position->second; } + CacheEntry& GetEntry() { return m_Position->second; } }; friend class cmCacheManager::CacheIterator; @@ -60,7 +76,6 @@ public: return CacheIterator(*this); } - typedef std::map<cmStdString, CacheEntry> CacheEntryMap; /** * Types for the cache entries. These are useful as * hints for a cache editor program. Path should bring @@ -87,10 +102,8 @@ public: ///! Print the cache to a stream void PrintCache(std::ostream&) const; - ///! Get a cache entry object for a key - CacheEntry *GetCacheEntry(const char *key); - - bool IsAdvanced(const char* key); + ///! Get the iterator for an entry with a given key. + cmCacheManager::CacheIterator GetCacheIterator(const char *key); ///! Remove an entry from the cache void RemoveCacheEntry(const char* key); @@ -116,7 +129,11 @@ protected: ///! Add a BOOL entry into the cache void AddCacheEntry(const char* key, bool, const char* helpString); + ///! Get a cache entry object for a key + CacheEntry *GetCacheEntry(const char *key); + private: + typedef std::map<cmStdString, CacheEntry> CacheEntryMap; static void OutputHelpString(std::ofstream& fout, const std::string& helpString); CacheEntryMap m_Cache; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 6141826..e291fd2 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -58,11 +58,12 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) } if(cacheValue) { - cmCacheManager::CacheEntry* e = - m_Makefile->GetCacheManager()->GetCacheEntry(args[0].c_str()); - if(e) + cmCacheManager::CacheIterator it = + m_Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); + if(!it.IsAtEnd()) { - helpString = e->m_HelpString; + const char* hs = it.GetProperty("HELPSTRING"); + helpString = hs?hs:"(none)"; } } std::vector<std::string> path; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 1efea58..8782fc3 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -64,11 +64,12 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn) } if(cacheValue) { - cmCacheManager::CacheEntry* e = - m_Makefile->GetCacheManager()->GetCacheEntry(args[0].c_str()); - if(e) + cmCacheManager::CacheIterator it = + m_Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); + if(!it.IsAtEnd()) { - doc = e->m_HelpString; + const char* hs = it.GetProperty("HELPSTRING"); + doc = hs?hs:"(none)"; } } std::vector<std::string> path; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ae9b362..e945b17 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -547,6 +547,10 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before) void cmMakefile::AddDefinition(const char* name, const char* value) { + if (!value ) + { + return; + } m_Definitions.erase( DefinitionMap::key_type(name)); m_Definitions.insert(DefinitionMap::value_type(name, value)); } diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 30a401c..17f3002 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -42,17 +42,20 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& argsIn for(; i < args.size(); ++i) { std::string variable = args[i]; - variable += "-ADVANCED"; - std::string doc = "Advanced flag for variable: "; - doc += args[i]; - // if not CLEAR or FORCE or it is not yet defined, - // then define variable-ADVANCED - if(overwrite || !m_Makefile->GetDefinition(variable.c_str())) + cmCacheManager* manager = m_Makefile->GetCacheManager(); + cmCacheManager::CacheIterator it = manager->GetCacheIterator(variable.c_str()); + if ( it.IsAtEnd() ) { - m_Makefile->AddCacheDefinition(variable.c_str(), value, - doc.c_str(), - cmCacheManager::INTERNAL); + m_Makefile->AddCacheDefinition(variable.c_str(), 0, 0, + cmCacheManager::UNINITIALIZED); } + it.Find(variable.c_str()); + if ( it.IsAtEnd() ) + { + cmSystemTools::Error("This should never happen..."); + return false; + } + it.SetProperty("ADVANCED", value); } return true; } diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 6ac0b77..640e270 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -47,7 +47,9 @@ void cmVariableRequiresCommand::FinalPass() requirementsMet = false; notSet += m_Arguments[i]; notSet += "\n"; - if(m_Makefile->GetCacheManager()->IsAdvanced(m_Arguments[i].c_str())) + cmCacheManager::CacheIterator it = + m_Makefile->GetCacheManager()->GetCacheIterator(m_Arguments[i].c_str()); + if(!it.IsAtEnd() && it.GetPropertyAsBool("ADVANCED")) { hasAdvanced = true; } diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 4669206..2144a41 100644 --- a/Source/cmakewizard.cxx +++ b/Source/cmakewizard.cxx @@ -24,39 +24,33 @@ cmakewizard::cmakewizard() } -void cmakewizard::AskUser(const char* key, cmCacheManager::CacheEntry & entry, +void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter, cmCacheManager *cacheManager) { std::cout << "Variable Name: " << key << "\n"; - std::cout << "Description: " << entry.m_HelpString << "\n"; - std::cout << "Current Value: " << entry.m_Value.c_str() << "\n"; + const char* helpstring = iter.GetProperty("HELPSTRING"); + std::cout << "Description: " << (helpstring?helpstring:"(none)") << "\n"; + std::cout << "Current Value: " << iter.GetValue() << "\n"; std::cout << "New Value (Enter to keep current value): "; char buffer[4096]; buffer[0] = 0; std::cin.getline(buffer, sizeof(buffer)); if(buffer[0]) { - cmCacheManager::CacheEntry *entry = cacheManager->GetCacheEntry(key); - if(entry) + std::string value = buffer; + if(iter.GetType() == cmCacheManager::PATH || + iter.GetType() == cmCacheManager::FILEPATH) { - entry->m_Value = buffer; - if(entry->m_Type == cmCacheManager::PATH || - entry->m_Type == cmCacheManager::FILEPATH) - { - cmSystemTools::ConvertToUnixSlashes(entry->m_Value); - } - if(entry->m_Type == cmCacheManager::BOOL) - { - if(!cmSystemTools::IsOn(buffer)) - { - entry->m_Value = "OFF"; - } - } + cmSystemTools::ConvertToUnixSlashes(value); } - else + if(iter.GetType() == cmCacheManager::BOOL) { - std::cerr << "strange error, should be in cache but is not... " << key << "\n"; + if(!cmSystemTools::IsOn(value.c_str())) + { + value = "OFF"; + } } + iter.SetValue(value.c_str()); } std::cout << "\n"; } @@ -90,7 +84,8 @@ void cmakewizard::RunWizard(std::vector<std::string> const& args) m_ShowAdvanced = this->AskAdvanced(); cmSystemTools::DisableRunCommandOutput(); cmake make; - cmCacheManager::CacheEntryMap askedCache; + make.SetArgs(args); + std::map<std::string,std::string> askedCache; bool asked = false; // continue asking questions until no new questions are asked do @@ -98,6 +93,7 @@ void cmakewizard::RunWizard(std::vector<std::string> const& args) asked = false; // run cmake this->ShowMessage("Please wait while cmake processes CMakeLists.txt files....\n"); + make.Configure(args[0].c_str(),&args); this->ShowMessage("\n"); // load the cache from disk @@ -109,33 +105,33 @@ void cmakewizard::RunWizard(std::vector<std::string> const& args) for(;!i.IsAtEnd(); i.Next()) { std::string key = i.GetName(); - cmCacheManager::CacheEntry ce = i.GetEntry(); - if(ce.m_Type == cmCacheManager::INTERNAL - || ce.m_Type == cmCacheManager::STATIC) + if( i.GetType() == cmCacheManager::INTERNAL || + i.GetType() == cmCacheManager::STATIC || + i.GetType() == cmCacheManager::UNINITIALIZED ) { continue; } if(askedCache.count(key)) { - cmCacheManager::CacheEntry& e = askedCache.find(key)->second; - if(e.m_Value != ce.m_Value) + std::string& e = askedCache.find(key)->second; + if(e != i.GetValue()) { - if(m_ShowAdvanced || !cachem->IsAdvanced(key.c_str())) + if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) { - this->AskUser(key.c_str(), ce, cachem); + this->AskUser(key.c_str(), i, cachem); asked = true; } } } else { - if(m_ShowAdvanced || !cachem->IsAdvanced(key.c_str())) + if(m_ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) { - this->AskUser(key.c_str(), ce, cachem); + this->AskUser(key.c_str(), i, cachem); asked = true; } } - askedCache[key] = i.GetEntry(); + askedCache[key] = i.GetValue(); } cachem->SaveCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()); } diff --git a/Source/cmakewizard.h b/Source/cmakewizard.h index b8d21bc..9b0b5eb 100644 --- a/Source/cmakewizard.h +++ b/Source/cmakewizard.h @@ -31,7 +31,7 @@ public: /** * Prompt the User for a new value for key, the answer is put in entry. */ - virtual void AskUser(const char* key, cmCacheManager::CacheEntry & entry, + virtual void AskUser(const char* key, cmCacheManager::CacheIterator& iter, cmCacheManager *cm); ///! Show a message to wait for cmake to run. virtual void ShowMessage(const char*); |