Commit 3347c5e4 authored by Brad King's avatar Brad King

Revert topic 'refactor-cache-api'

This topic was never tested without some follow-up commits.  The
GetCacheEntryValue API returns a pointer to memory freed on return.
It will have to be revised along with the rest of the original topic.
parent 9410e24a
......@@ -18,6 +18,7 @@
#include "cmGlobalGenerator.h"
#include <cmsys/Process.h>
#include "cmCTestTestHandler.h"
#include "cmCacheManager.h"
//----------------------------------------------------------------------
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
......@@ -254,7 +255,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available.
cm.LoadCache(this->BinaryDir);
cm.GetCacheManager()->LoadCache(this->BinaryDir);
}
else
{
......
......@@ -18,9 +18,6 @@
#include "cmCursesFilePathWidget.h"
#include "cmCursesDummyWidget.h"
#include "../cmSystemTools.h"
#include "../cmake.h"
#include <assert.h>
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key,
......@@ -35,7 +32,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key, cmake *cm, bool isNew,
const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew,
int labelwidth, int entrywidth)
: Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
{
......@@ -50,13 +47,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
this->Entry = 0;
const char* value = cm->GetCacheManager()->GetCacheEntryValue(key);
assert(value);
switch (cm->GetCacheManager()->GetCacheEntryType(key))
switch ( it.GetType() )
{
case cmCacheManager::BOOL:
case cmCacheManager::BOOL:
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
if (cmSystemTools::IsOn(value))
if (cmSystemTools::IsOn(it.GetValue().c_str()))
{
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
}
......@@ -67,40 +62,40 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
break;
case cmCacheManager::PATH:
this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesPathWidget*>(this->Entry)->SetString(value);
static_cast<cmCursesPathWidget*>(this->Entry)->SetString(
it.GetValue());
break;
case cmCacheManager::FILEPATH:
this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(
it.GetValue());
break;
case cmCacheManager::STRING:
{
const char* stringsProp = cm->GetCacheManager()
->GetCacheEntryProperty(key, "STRINGS");
if(stringsProp)
if(it.PropertyExists("STRINGS"))
{
cmCursesOptionsWidget* ow =
new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
this->Entry = ow;
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(stringsProp, options);
cmSystemTools::ExpandListArgument(
std::string(it.GetProperty("STRINGS")), options);
for(std::vector<std::string>::iterator
si = options.begin(); si != options.end(); ++si)
{
ow->AddOption(*si);
}
ow->SetOption(value);
ow->SetOption(it.GetValue());
}
else
{
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesStringWidget*>(this->Entry)->SetString(value);
static_cast<cmCursesStringWidget*>(this->Entry)->SetString(
it.GetValue());
}
break;
}
case cmCacheManager::UNINITIALIZED:
cmSystemTools::Error("Found an undefined variable: ",
key.c_str());
it.GetName().c_str());
break;
default:
// TODO : put warning message here
......
......@@ -21,7 +21,7 @@ public:
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
int entrywidth);
cmCursesCacheEntryComposite(const std::string& key,
cmake *cm,
const cmCacheManager::CacheIterator& it,
bool isNew, int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();
const char* GetValue();
......
This diff is collapsed.
......@@ -96,7 +96,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
emit this->binaryDirChanged(this->BinaryDirectory);
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
this->setGenerator(QString());
if(!this->CMakeInstance->LoadCache(
if(!this->CMakeInstance->GetCacheManager()->LoadCache(
this->BinaryDirectory.toLocal8Bit().data()))
{
QDir testDir(this->BinaryDirectory);
......@@ -110,18 +110,16 @@ void QCMake::setBinaryDirectory(const QString& _dir)
QCMakePropertyList props = this->properties();
emit this->propertiesChanged(props);
const char* homeDir = cachem->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
if (homeDir)
cmCacheManager::CacheIterator itm = cachem->NewIterator();
if ( itm.Find("CMAKE_HOME_DIRECTORY"))
{
setSourceDirectory(QString::fromLocal8Bit(homeDir));
setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str()));
}
const char* gen = cachem->GetCacheEntryValue("CMAKE_GENERATOR");
if (gen)
if ( itm.Find("CMAKE_GENERATOR"))
{
const char* extraGen = cachem
->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen = cmExternalMakefileProjectGenerator::
CreateFullGeneratorName(gen, extraGen? extraGen : "");
CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
}
}
......@@ -196,35 +194,33 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it)
for(cmCacheManager::CacheIterator i = cachem->NewIterator();
!i.IsAtEnd(); i.Next())
{
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*it);
if(t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC)
if(i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC)
{
continue;
}
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(it->c_str());
prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
int idx = props.indexOf(prop);
if(idx == -1)
{
toremove.append(QString::fromLocal8Bit(it->c_str()));
toremove.append(QString::fromLocal8Bit(i.GetName().c_str()));
}
else
{
prop = props[idx];
if(prop.Value.type() == QVariant::Bool)
{
cachem->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
i.SetValue(prop.Value.toBool() ? "ON" : "OFF");
}
else
{
cachem->SetCacheEntryValue(*it,
prop.Value.toString().toLocal8Bit().data());
i.SetValue(prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
}
......@@ -274,7 +270,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
}
}
this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
cachem->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
}
QCMakePropertyList QCMake::properties() const
......@@ -282,47 +278,42 @@ QCMakePropertyList QCMake::properties() const
QCMakePropertyList ret;
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
i != cacheKeys.end(); ++i)
for(cmCacheManager::CacheIterator i = cachem->NewIterator();
!i.IsAtEnd(); i.Next())
{
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*i);
if(t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC ||
t == cmCacheManager::UNINITIALIZED)
if(i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED)
{
continue;
}
const char* cachedValue = cachem->GetCacheEntryValue(*i);
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i->c_str());
prop.Help = QString::fromLocal8Bit(
cachem->GetCacheEntryProperty(*i, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
prop.Advanced = cachem->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
if(t == cmCacheManager::BOOL)
prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING"));
prop.Value = QString::fromLocal8Bit(i.GetValue().c_str());
prop.Advanced = i.GetPropertyAsBool("ADVANCED");
if(i.GetType() == cmCacheManager::BOOL)
{
prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(cachedValue);
prop.Value = cmSystemTools::IsOn(i.GetValue().c_str());
}
else if(t == cmCacheManager::PATH)
else if(i.GetType() == cmCacheManager::PATH)
{
prop.Type = QCMakeProperty::PATH;
}
else if(t == cmCacheManager::FILEPATH)
else if(i.GetType() == cmCacheManager::FILEPATH)
{
prop.Type = QCMakeProperty::FILEPATH;
}
else if(t == cmCacheManager::STRING)
else if(i.GetType() == cmCacheManager::STRING)
{
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
cachem->GetCacheEntryProperty(*i, "STRINGS");
if (stringsProperty)
if (i.PropertyExists("STRINGS"))
{
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
prop.Strings = QString::fromLocal8Bit(i.GetProperty("STRINGS")).split(";");
}
}
......@@ -406,9 +397,9 @@ QStringList QCMake::availableGenerators() const
void QCMake::deleteCache()
{
// delete cache
this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
this->CMakeInstance->GetCacheManager()->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
// reload to make our cache empty
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
// emit no generator and no properties
this->setGenerator(QString());
QCMakePropertyList props = this->properties();
......@@ -421,7 +412,7 @@ void QCMake::reloadCache()
QCMakePropertyList props;
emit this->propertiesChanged(props);
// reload
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
// emit new cache properties
props = this->properties();
emit this->propertiesChanged(props);
......
......@@ -51,14 +51,12 @@ void CCONV cmSetError(void *info, const char *err)
unsigned int CCONV cmGetCacheMajorVersion(void *arg)
{
cmMakefile *mf = static_cast<cmMakefile *>(arg);
cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager();
return manager->GetCacheMajorVersion();
return mf->GetCacheMajorVersion();
}
unsigned int CCONV cmGetCacheMinorVersion(void *arg)
{
cmMakefile *mf = static_cast<cmMakefile *>(arg);
cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager();
return manager->GetCacheMinorVersion();
return mf->GetCacheMinorVersion();
}
unsigned int CCONV cmGetMajorVersion(void *)
......
......@@ -2281,7 +2281,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg)
std::string value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
if (cmake::ParseCacheEntry(arg, name, value, type))
if (cmCacheManager::ParseEntry(arg, name, value, type))
{
this->Definitions[name] = value;
return true;
......
......@@ -284,16 +284,14 @@ bool cmCacheManager::LoadCache(const std::string& path,
}
this->CacheMajorVersion = 0;
this->CacheMinorVersion = 0;
if(const char* cmajor =
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
if(const char* cmajor = this->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
{
unsigned int v=0;
if(sscanf(cmajor, "%u", &v) == 1)
{
this->CacheMajorVersion = v;
}
if(const char* cminor =
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION"))
if(const char* cminor = this->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"))
{
if(sscanf(cminor, "%u", &v) == 1)
{
......@@ -315,11 +313,10 @@ bool cmCacheManager::LoadCache(const std::string& path,
}
// check to make sure the cache directory has not
// been moved
const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
if (internal && oldDir)
if ( internal && this->GetCacheValue("CMAKE_CACHEFILE_DIR") )
{
std::string currentcwd = path;
std::string oldcwd = oldDir;
std::string oldcwd = this->GetCacheValue("CMAKE_CACHEFILE_DIR");
cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt";
......@@ -328,7 +325,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
std::string message =
std::string("The current CMakeCache.txt directory ") +
currentcwd + std::string(" is different than the directory ") +
std::string(this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) +
std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) +
std::string(" where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt");
......@@ -658,8 +655,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
return CacheIterator(*this, key);
}
const char*
cmCacheManager::GetInitializedCacheValue(const std::string& key) const
const char* cmCacheManager::GetCacheValue(const std::string& key) const
{
CacheEntryMap::const_iterator i = this->Cache.find(key);
if(i != this->Cache.end() &&
......
......@@ -137,82 +137,7 @@ public:
CacheEntryType& type);
///! Get a value from the cache given a key
const char* GetInitializedCacheValue(const std::string& key) const;
const char* GetCacheEntryValue(const std::string& key)
{
cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
if (it.IsAtEnd())
{
return 0;
}
return it.GetValue().c_str();
}
const char* GetCacheEntryProperty(std::string const& key,
std::string const& propName)
{
return this->GetCacheIterator(key.c_str()).GetProperty(propName);
}
CacheEntryType GetCacheEntryType(std::string const& key)
{
return this->GetCacheIterator(key.c_str()).GetType();
}
bool GetCacheEntryPropertyAsBool(std::string const& key,
std::string const& propName)
{
return this->GetCacheIterator(key.c_str()).GetPropertyAsBool(propName);
}
void SetCacheEntryProperty(std::string const& key,
std::string const& propName,
std::string const& value)
{
this->GetCacheIterator(key.c_str()).SetProperty(propName, value.c_str());
}
void SetCacheEntryBoolProperty(std::string const& key,
std::string const& propName,
bool value)
{
this->GetCacheIterator(key.c_str()).SetProperty(propName, value);
}
void SetCacheEntryValue(std::string const& key,
std::string const& value)
{
this->GetCacheIterator(key.c_str()).SetValue(value.c_str());
}
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propName)
{
this->GetCacheIterator(key.c_str()).SetProperty(propName, (void*)0);
}
void AppendCacheEntryProperty(std::string const& key,
std::string const& propName,
std::string const& value,
bool asString = false)
{
this->GetCacheIterator(key.c_str()).AppendProperty(propName,
value.c_str(),
asString);
}
std::vector<std::string> GetCacheEntryKeys()
{
std::vector<std::string> definitions;
definitions.reserve(this->GetSize());
cmCacheManager::CacheIterator cit = this->GetCacheIterator();
for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
{
definitions.push_back(cit.GetName());
}
return definitions;
}
const char* GetCacheValue(const std::string& key) const;
/** Get the version of CMake that wrote the cache. */
unsigned int GetCacheMajorVersion() const
......
......@@ -90,8 +90,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
}
if ( strcmp(key, "CACHE") == 0 )
{
if(const char* c = this->Makefile->GetCacheManager()
->GetInitializedCacheValue(var))
if(const char* c = this->Makefile->GetCacheManager()->GetCacheValue(var))
{
if(this->EscapeQuotes)
{
......
......@@ -205,7 +205,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
cacheEntryName += envVar;
const char* cacheValue = mf->GetCacheManager()->GetInitializedCacheValue(
const char* cacheValue = mf->GetCacheManager()->GetCacheValue(
cacheEntryName);
// now we have both, decide which one to use
......@@ -223,7 +223,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmCacheManager::STRING,
true);
mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory());
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
}
else if (envVarValue==0 && cacheValue!=0)
{
......@@ -244,7 +244,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmCacheManager::STRING,
true);
mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory());
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
}
}
......
......@@ -366,18 +366,18 @@ bool cmFindBase::CheckForVariableInCache()
if(const char* cacheValue =
this->Makefile->GetDefinition(this->VariableName))
{
cmCacheManager* manager = this->Makefile->GetCacheManager();
const char* cacheEntry = manager->GetCacheEntryValue(this->VariableName);
cmCacheManager::CacheIterator it =
this->Makefile->GetCacheManager()->
GetCacheIterator(this->VariableName.c_str());
bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
bool cached = cacheEntry ? true : false;
bool cached = !it.IsAtEnd();
if(found)
{
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the
// original value. Tell the subclass implementations to do
// this.
if(cached && manager->GetCacheEntryType(this->VariableName)
== cmCacheManager::UNINITIALIZED)
if(cached && it.GetType() == cmCacheManager::UNINITIALIZED)
{
this->AlreadyInCacheWithoutMetaInfo = true;
}
......@@ -385,8 +385,7 @@ bool cmFindBase::CheckForVariableInCache()
}
else if(cached)
{
const char* hs = manager->GetCacheEntryProperty(this->VariableName,
"HELPSTRING");
const char* hs = it.GetProperty("HELPSTRING");
this->VariableDocumentation = hs?hs:"(none)";
}
}
......
......@@ -391,10 +391,11 @@ bool cmGetPropertyCommand::HandleCacheMode()
}
const char* value = 0;
if(this->Makefile->GetCacheManager()->GetCacheEntryValue(this->Name))
cmCacheManager::CacheIterator it =
this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str());
if(!it.IsAtEnd())
{
value = this->Makefile->GetCacheManager()
->GetCacheEntryProperty(this->Name, this->PropertyName);
value = it.GetProperty(this->PropertyName);
}
this->StoreResult(value);
return true;
......
......@@ -179,7 +179,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
return;
}
const char* cname = this->GetCMakeInstance()->
GetCacheManager()->GetInitializedCacheValue(langComp);
GetCacheManager()->GetCacheValue(langComp);
std::string changeVars;
if(cname && !optional)
{
......@@ -1559,7 +1559,9 @@ void cmGlobalGenerator::CheckLocalGenerators()
cmSystemTools::IsNOTFOUND(lib->first.c_str()))
{
std::string varName = lib->first.substr(0, lib->first.size()-9);
if(manager->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
cmCacheManager::CacheIterator it =
manager->GetCacheIterator(varName.c_str());
if(it.GetPropertyAsBool("ADVANCED"))
{
varName += " (ADVANCED)";
}
......@@ -1590,7 +1592,9 @@ void cmGlobalGenerator::CheckLocalGenerators()
cmSystemTools::IsNOTFOUND(incDir->c_str()))
{
std::string varName = incDir->substr(0, incDir->size()-9);
if(manager->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
cmCacheManager::CacheIterator it =
manager->GetCacheIterator(varName.c_str());
if(it.GetPropertyAsBool("ADVANCED"))
{
varName += " (ADVANCED)";
}
......@@ -1637,7 +1641,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
// and there is a good chance that the try compile stuff will
// take the bulk of the time, so try and guess some progress
// by getting closer and closer to 100 without actually getting there.
if (!this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue
if (!this->CMakeInstance->GetCacheManager()->GetCacheValue
("CMAKE_NUMBER_OF_LOCAL_GENERATORS"))
{
// If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set
......@@ -1835,7 +1839,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
// update progress
// estimate how many lg there will be
const char *numGenC =
this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue
this->CMakeInstance->GetCacheManager()->GetCacheValue
("CMAKE_NUMBER_OF_LOCAL_GENERATORS");
if (!numGenC)
......
......@@ -3703,7 +3703,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
// Since this call may have created new cache entries, save the cache:
//
root->GetMakefile()->GetCMakeInstance()->SaveCache(
root->GetMakefile()->GetCacheManager()->SaveCache(
root->GetMakefile()->GetHomeOutputDirectory());
}
......
......@@ -81,8 +81,8 @@ bool cmLoadCacheCommand
{
break;
}
this->Makefile->GetCMakeInstance()->LoadCache(args[i], false,
excludes, includes);
this->Makefile->GetCacheManager()->LoadCache(args[i], false,
excludes, includes);
}
......@@ -173,7 +173,7 @@ void cmLoadCacheCommand::CheckLine(const char* line)
std::string var;
std::string value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
if(cmake::ParseCacheEntry(line, var, value, type))
if(cmCacheManager::ParseEntry(line, var, value, type))
{
// Found a real entry. See if this one was requested.
if(this->VariablesToRead.find(var) != this->VariablesToRead.end())
......
......@@ -174,6 +174,16 @@ void cmMakefile::Initialize()
this->CheckCMP0000 = false;
}
unsigned int cmMakefile::GetCacheMajorVersion() const
{
return this->GetCacheManager()->GetCacheMajorVersion();
}
unsigned int cmMakefile::GetCacheMinorVersion() const
{
return this->GetCacheManager()->GetCacheMinorVersion();
}
cmMakefile::~cmMakefile()
{
cmDeleteAll(this->InstallGenerators);
......@@ -1810,17 +1820,16 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
{
bool haveVal = value ? true : false;
std::string val = haveVal ? value : "";
const char* existingValue =
this->GetCacheManager()->GetInitializedCacheValue(name);
if(existingValue
&& (this->GetCacheManager()->GetCacheEntryType(name)
== cmCacheManager::UNINITIALIZED))
cmCacheManager::CacheIterator it =
this->GetCacheManager()->GetCacheIterator(name.c_str());
if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) &&
it.Initialized())
{
// if this is not a force, then use the value from the cache
// if it is a force, then use the value being passed in
if(!force)
{
val = existingValue;
val = it.GetValue();
haveVal = true;
}
if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH )
......@@ -1843,13 +1852,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
}
this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type);
val = this->GetCacheManager()->GetInitializedCacheValue(name);
val = it.GetValue();
haveVal = true;
}
}
this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
doc, type);
this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc,
type);
// if there was a definition then remove it
this->Internal->VarStack.top().Set(name, 0);
}
......@@ -2433,7 +2442,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
this->Internal->VarUsageStack.top().insert(name);
if(!def)
{
def = this->GetCacheManager()->GetInitializedCacheValue(name);
def = this->GetCacheManager()->GetCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
if(cmVariableWatch* vv = this->GetVariableWatch())
......@@ -2458,7 +2467,7 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
const char* def = this->Internal->VarStack.top().Get(name);