Merge topic 'refactor-cache-manager'
79a309d7
cmState: Port away from cmake instance.e2eecae2
cmState: Move ParseCacheEntry from cmCacheManager.b5212c68
cmState: Add API for cache version.95b0d761
cmState: Externalize logic to caller.6f02034e
cmState: Make AddCacheEntry method private.435a2f3c
cmCacheManager: Port away from cmake instance.062ed22e
cmState: Add cache file manipulation wrappers.a02e53eb
Inline unary LoadCache.bec3487f
cmCacheManager: Remove cmMakefile dependency.e0f740f1
Always cache entries through the cmake instance.2afadb0d
cmake: Port away from trivial cmCacheManager use.3d8c299f
cmake: Use existing cache API wrapper.
This commit is contained in:
commit
83d2b6f378
|
@ -51,14 +51,14 @@ 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();
|
||||
cmState *state = mf->GetState();
|
||||
return state->GetCacheMajorVersion();
|
||||
}
|
||||
unsigned int CCONV cmGetCacheMinorVersion(void *arg)
|
||||
{
|
||||
cmMakefile *mf = static_cast<cmMakefile *>(arg);
|
||||
cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager();
|
||||
return manager->GetCacheMinorVersion();
|
||||
cmState *state = mf->GetState();
|
||||
return state->GetCacheMinorVersion();
|
||||
}
|
||||
|
||||
unsigned int CCONV cmGetMajorVersion(void *)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "cmCacheManager.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmake.h"
|
||||
#include "cmVersion.h"
|
||||
|
||||
|
@ -22,101 +21,10 @@
|
|||
#include <cmsys/FStream.hxx>
|
||||
#include <cmsys/RegularExpression.hxx>
|
||||
|
||||
cmCacheManager::cmCacheManager(cmake* cm)
|
||||
cmCacheManager::cmCacheManager()
|
||||
{
|
||||
this->CacheMajorVersion = 0;
|
||||
this->CacheMinorVersion = 0;
|
||||
this->CMakeInstance = cm;
|
||||
}
|
||||
|
||||
bool cmCacheManager::LoadCache(const std::string& path)
|
||||
{
|
||||
std::set<std::string> emptySet;
|
||||
return this->LoadCache(path, true, emptySet, emptySet);
|
||||
}
|
||||
|
||||
static bool ParseEntryWithoutType(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value)
|
||||
{
|
||||
// input line is: key=value
|
||||
static cmsys::RegularExpression reg(
|
||||
"^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
// input line is: "key"=value
|
||||
static cmsys::RegularExpression regQuoted(
|
||||
"^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
value = regQuoted.match(2);
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
value = reg.match(2);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool cmCacheManager::ParseEntry(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value,
|
||||
cmState::CacheEntryType& type)
|
||||
{
|
||||
// input line is: key:type=value
|
||||
static cmsys::RegularExpression reg(
|
||||
"^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
// input line is: "key":type=value
|
||||
static cmsys::RegularExpression regQuoted(
|
||||
"^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
|
||||
value = regQuoted.match(3);
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
type = cmState::StringToCacheEntryType(reg.match(2).c_str());
|
||||
value = reg.match(3);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return ParseEntryWithoutType(entry, var, value);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
void cmCacheManager::CleanCMakeFiles(const std::string& path)
|
||||
|
@ -195,7 +103,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
|
|||
}
|
||||
}
|
||||
e.SetProperty("HELPSTRING", helpString.c_str());
|
||||
if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type))
|
||||
if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type))
|
||||
{
|
||||
if ( excludes.find(entryKey) == excludes.end() )
|
||||
{
|
||||
|
@ -678,7 +586,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key,
|
|||
}
|
||||
e.SetProperty("HELPSTRING", helpString? helpString :
|
||||
"(This variable does not exist and should not be used)");
|
||||
this->CMakeInstance->UnwatchUnusedCli(key);
|
||||
}
|
||||
|
||||
bool cmCacheManager::CacheIterator::IsAtEnd() const
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
#include "cmPropertyMap.h"
|
||||
#include "cmState.h"
|
||||
|
||||
class cmMakefile;
|
||||
class cmMarkAsAdvancedCommand;
|
||||
class cmake;
|
||||
|
||||
/** \class cmCacheManager
|
||||
* \brief Control class for cmake's cache
|
||||
|
@ -29,7 +27,7 @@ class cmake;
|
|||
class cmCacheManager
|
||||
{
|
||||
public:
|
||||
cmCacheManager(cmake* cm);
|
||||
cmCacheManager();
|
||||
class CacheIterator;
|
||||
friend class cmCacheManager::CacheIterator;
|
||||
|
||||
|
@ -100,7 +98,6 @@ public:
|
|||
}
|
||||
|
||||
///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
|
||||
bool LoadCache(const std::string& path);
|
||||
bool LoadCache(const std::string& path, bool internal,
|
||||
std::set<std::string>& excludes,
|
||||
std::set<std::string>& includes);
|
||||
|
@ -124,12 +121,6 @@ public:
|
|||
int GetSize() {
|
||||
return static_cast<int>(this->Cache.size()); }
|
||||
|
||||
///! Break up a line like VAR:type="value" into var, type and value
|
||||
static bool ParseEntry(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value,
|
||||
cmState::CacheEntryType& type);
|
||||
|
||||
///! Get a value from the cache given a key
|
||||
const char* GetInitializedCacheValue(const std::string& key) const;
|
||||
|
||||
|
@ -241,7 +232,7 @@ private:
|
|||
void WritePropertyEntries(std::ostream& os, CacheIterator const& i);
|
||||
|
||||
CacheEntryMap Cache;
|
||||
// Only cmake and cmMakefile should be able to add cache values
|
||||
// Only cmake and cmState should be able to add cache values
|
||||
// the commands should never use the cmCacheManager directly
|
||||
friend class cmState; // allow access to add cache values
|
||||
friend class cmake; // allow access to add cache values
|
||||
|
|
|
@ -1905,13 +1905,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
|||
nvalue += files[cc];
|
||||
}
|
||||
|
||||
this->GetState()->AddCacheEntry(name, nvalue.c_str(), doc, type);
|
||||
this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
|
||||
val = this->GetState()->GetInitializedCacheValue(name);
|
||||
haveVal = true;
|
||||
}
|
||||
|
||||
}
|
||||
this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
|
||||
this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
|
||||
doc, type);
|
||||
// if there was a definition then remove it
|
||||
this->StateSnapshot.RemoveDefinition(name);
|
||||
|
|
|
@ -39,7 +39,8 @@ bool cmMarkAsAdvancedCommand
|
|||
cmState* state = this->Makefile->GetState();
|
||||
if (!state->GetCacheEntryValue(variable))
|
||||
{
|
||||
state->AddCacheEntry(variable, 0, 0, cmState::UNINITIALIZED);
|
||||
this->Makefile->GetCMakeInstance()->AddCacheEntry(
|
||||
variable, 0, 0, cmState::UNINITIALIZED);
|
||||
overwrite = true;
|
||||
}
|
||||
if (!state->GetCacheEntryValue(variable))
|
||||
|
|
|
@ -82,9 +82,8 @@ struct cmState::BuildsystemDirectoryStateType
|
|||
std::vector<cmState::Snapshot> Children;
|
||||
};
|
||||
|
||||
cmState::cmState(cmake* cm)
|
||||
: CMakeInstance(cm),
|
||||
IsInTryCompile(false),
|
||||
cmState::cmState()
|
||||
: IsInTryCompile(false),
|
||||
WindowsShell(false),
|
||||
WindowsVSIDE(false),
|
||||
WatcomWMake(false),
|
||||
|
@ -92,10 +91,12 @@ cmState::cmState(cmake* cm)
|
|||
NMake(false),
|
||||
MSYSShell(false)
|
||||
{
|
||||
this->CacheManager = new cmCacheManager;
|
||||
}
|
||||
|
||||
cmState::~cmState()
|
||||
{
|
||||
delete this->CacheManager;
|
||||
cmDeleteAll(this->Commands);
|
||||
}
|
||||
|
||||
|
@ -147,12 +148,30 @@ bool cmState::IsCacheEntryType(std::string const& key)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool cmState::LoadCache(const std::string& path, bool internal,
|
||||
std::set<std::string>& excludes,
|
||||
std::set<std::string>& includes)
|
||||
{
|
||||
return this->CacheManager->LoadCache(path, internal,
|
||||
excludes, includes);
|
||||
}
|
||||
|
||||
bool cmState::SaveCache(const std::string& path)
|
||||
{
|
||||
return this->CacheManager->SaveCache(path);
|
||||
}
|
||||
|
||||
bool cmState::DeleteCache(const std::string& path)
|
||||
{
|
||||
return this->CacheManager->DeleteCache(path);
|
||||
}
|
||||
|
||||
std::vector<std::string> cmState::GetCacheEntryKeys() const
|
||||
{
|
||||
std::vector<std::string> definitions;
|
||||
definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize());
|
||||
definitions.reserve(this->CacheManager->GetSize());
|
||||
cmCacheManager::CacheIterator cit =
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator();
|
||||
this->CacheManager->GetCacheIterator();
|
||||
for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
|
||||
{
|
||||
definitions.push_back(cit.GetName());
|
||||
|
@ -162,7 +181,7 @@ std::vector<std::string> cmState::GetCacheEntryKeys() const
|
|||
|
||||
const char* cmState::GetCacheEntryValue(std::string const& key) const
|
||||
{
|
||||
cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager()
|
||||
cmCacheManager::CacheEntry* e = this->CacheManager
|
||||
->GetCacheEntry(key);
|
||||
if (!e)
|
||||
{
|
||||
|
@ -174,21 +193,21 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const
|
|||
const char*
|
||||
cmState::GetInitializedCacheValue(std::string const& key) const
|
||||
{
|
||||
return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key);
|
||||
return this->CacheManager->GetInitializedCacheValue(key);
|
||||
}
|
||||
|
||||
cmState::CacheEntryType
|
||||
cmState::GetCacheEntryType(std::string const& key) const
|
||||
{
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
||||
this->CacheManager->GetCacheIterator(key.c_str());
|
||||
return it.GetType();
|
||||
}
|
||||
|
||||
void cmState::SetCacheEntryValue(std::string const& key,
|
||||
std::string const& value)
|
||||
{
|
||||
this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value);
|
||||
this->CacheManager->SetCacheEntryValue(key, value);
|
||||
}
|
||||
|
||||
void cmState::SetCacheEntryProperty(std::string const& key,
|
||||
|
@ -196,7 +215,7 @@ void cmState::SetCacheEntryProperty(std::string const& key,
|
|||
std::string const& value)
|
||||
{
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
||||
this->CacheManager->GetCacheIterator(key.c_str());
|
||||
it.SetProperty(propertyName, value.c_str());
|
||||
}
|
||||
|
||||
|
@ -205,14 +224,14 @@ void cmState::SetCacheEntryBoolProperty(std::string const& key,
|
|||
bool value)
|
||||
{
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
||||
this->CacheManager->GetCacheIterator(key.c_str());
|
||||
it.SetProperty(propertyName, value);
|
||||
}
|
||||
|
||||
const char* cmState::GetCacheEntryProperty(std::string const& key,
|
||||
std::string const& propertyName)
|
||||
{
|
||||
cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()
|
||||
cmCacheManager::CacheIterator it = this->CacheManager
|
||||
->GetCacheIterator(key.c_str());
|
||||
if (!it.PropertyExists(propertyName))
|
||||
{
|
||||
|
@ -224,7 +243,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key,
|
|||
bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
|
||||
std::string const& propertyName)
|
||||
{
|
||||
return this->CMakeInstance->GetCacheManager()
|
||||
return this->CacheManager
|
||||
->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName);
|
||||
}
|
||||
|
||||
|
@ -232,13 +251,13 @@ void cmState::AddCacheEntry(const std::string& key, const char* value,
|
|||
const char* helpString,
|
||||
cmState::CacheEntryType type)
|
||||
{
|
||||
this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value,
|
||||
this->CacheManager->AddCacheEntry(key, value,
|
||||
helpString, type);
|
||||
}
|
||||
|
||||
void cmState::RemoveCacheEntry(std::string const& key)
|
||||
{
|
||||
this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key);
|
||||
this->CacheManager->RemoveCacheEntry(key);
|
||||
}
|
||||
|
||||
void cmState::AppendCacheEntryProperty(const std::string& key,
|
||||
|
@ -246,7 +265,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key,
|
|||
const std::string& value,
|
||||
bool asString)
|
||||
{
|
||||
this->CMakeInstance->GetCacheManager()
|
||||
this->CacheManager
|
||||
->GetCacheIterator(key.c_str()).AppendProperty(property,
|
||||
value.c_str(),
|
||||
asString);
|
||||
|
@ -255,7 +274,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key,
|
|||
void cmState::RemoveCacheEntryProperty(std::string const& key,
|
||||
std::string const& propertyName)
|
||||
{
|
||||
this->CMakeInstance->GetCacheManager()
|
||||
this->CacheManager
|
||||
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
|
||||
}
|
||||
|
||||
|
@ -659,6 +678,16 @@ bool cmState::UseMSYSShell() const
|
|||
return this->MSYSShell;
|
||||
}
|
||||
|
||||
unsigned int cmState::GetCacheMajorVersion() const
|
||||
{
|
||||
return this->CacheManager->GetCacheMajorVersion();
|
||||
}
|
||||
|
||||
unsigned int cmState::GetCacheMinorVersion() const
|
||||
{
|
||||
return this->CacheManager->GetCacheMinorVersion();
|
||||
}
|
||||
|
||||
const char* cmState::GetBinaryDirectory() const
|
||||
{
|
||||
return this->BinaryDirectory.c_str();
|
||||
|
@ -1741,3 +1770,87 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
|
|||
{
|
||||
return lhs.Position != rhs.Position;
|
||||
}
|
||||
|
||||
static bool ParseEntryWithoutType(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value)
|
||||
{
|
||||
// input line is: key=value
|
||||
static cmsys::RegularExpression reg(
|
||||
"^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
// input line is: "key"=value
|
||||
static cmsys::RegularExpression regQuoted(
|
||||
"^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
value = regQuoted.match(2);
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
value = reg.match(2);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool cmState::ParseCacheEntry(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value,
|
||||
CacheEntryType& type)
|
||||
{
|
||||
// input line is: key:type=value
|
||||
static cmsys::RegularExpression reg(
|
||||
"^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
// input line is: "key":type=value
|
||||
static cmsys::RegularExpression regQuoted(
|
||||
"^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
|
||||
value = regQuoted.match(3);
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
type = cmState::StringToCacheEntryType(reg.match(2).c_str());
|
||||
value = reg.match(3);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return ParseEntryWithoutType(entry, var, value);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class cmake;
|
|||
class cmCommand;
|
||||
class cmDefinitions;
|
||||
class cmListFileBacktrace;
|
||||
class cmCacheManager;
|
||||
|
||||
class cmState
|
||||
{
|
||||
|
@ -32,7 +33,7 @@ class cmState
|
|||
typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
|
||||
friend class Snapshot;
|
||||
public:
|
||||
cmState(cmake* cm);
|
||||
cmState();
|
||||
~cmState();
|
||||
|
||||
enum SnapshotType
|
||||
|
@ -208,6 +209,14 @@ public:
|
|||
static const char* CacheEntryTypeToString(CacheEntryType);
|
||||
static bool IsCacheEntryType(std::string const& key);
|
||||
|
||||
bool LoadCache(const std::string& path, bool internal,
|
||||
std::set<std::string>& excludes,
|
||||
std::set<std::string>& includes);
|
||||
|
||||
bool SaveCache(const std::string& path) ;
|
||||
|
||||
bool DeleteCache(const std::string& path);
|
||||
|
||||
std::vector<std::string> GetCacheEntryKeys() const;
|
||||
const char* GetCacheEntryValue(std::string const& key) const;
|
||||
const char* GetInitializedCacheValue(std::string const& key) const;
|
||||
|
@ -215,8 +224,6 @@ public:
|
|||
void SetCacheEntryValue(std::string const& key, std::string const& value);
|
||||
void SetCacheValue(std::string const& key, std::string const& value);
|
||||
|
||||
void AddCacheEntry(const std::string& key, const char* value,
|
||||
const char* helpString, CacheEntryType type);
|
||||
void RemoveCacheEntry(std::string const& key);
|
||||
|
||||
void SetCacheEntryProperty(std::string const& key,
|
||||
|
@ -236,6 +243,12 @@ public:
|
|||
void RemoveCacheEntryProperty(std::string const& key,
|
||||
std::string const& propertyName);
|
||||
|
||||
///! Break up a line like VAR:type="value" into var, type and value
|
||||
static bool ParseCacheEntry(const std::string& entry,
|
||||
std::string& var,
|
||||
std::string& value,
|
||||
CacheEntryType& type);
|
||||
|
||||
Snapshot Reset();
|
||||
// Define a property
|
||||
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
|
||||
|
@ -296,12 +309,19 @@ public:
|
|||
void SetMSYSShell(bool mSYSShell);
|
||||
bool UseMSYSShell() const;
|
||||
|
||||
unsigned int GetCacheMajorVersion() const;
|
||||
unsigned int GetCacheMinorVersion() const;
|
||||
|
||||
private:
|
||||
friend class cmake;
|
||||
void AddCacheEntry(const std::string& key, const char* value,
|
||||
const char* helpString, CacheEntryType type);
|
||||
|
||||
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
|
||||
std::vector<std::string> EnabledLanguages;
|
||||
std::map<std::string, cmCommand*> Commands;
|
||||
cmPropertyMap GlobalProperties;
|
||||
cmake* CMakeInstance;
|
||||
cmCacheManager* CacheManager;
|
||||
|
||||
cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory;
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
============================================================================*/
|
||||
#include "cmUtilitySourceCommand.h"
|
||||
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
// cmUtilitySourceCommand
|
||||
bool cmUtilitySourceCommand
|
||||
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
|
||||
|
@ -54,13 +52,13 @@ bool cmUtilitySourceCommand
|
|||
}
|
||||
else
|
||||
{
|
||||
cmCacheManager *manager =
|
||||
this->Makefile->GetCMakeInstance()->GetCacheManager();
|
||||
cmState *state =
|
||||
this->Makefile->GetState();
|
||||
haveCacheValue = (cacheValue &&
|
||||
(strstr(cacheValue, "(IntDir)") == 0 ||
|
||||
(intDir && strcmp(intDir, "$(IntDir)") == 0)) &&
|
||||
(manager->GetCacheMajorVersion() != 0 &&
|
||||
manager->GetCacheMinorVersion() != 0 ));
|
||||
(state->GetCacheMajorVersion() != 0 &&
|
||||
state->GetCacheMinorVersion() != 0 ));
|
||||
}
|
||||
|
||||
if(haveCacheValue)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
See the License for more information.
|
||||
============================================================================*/
|
||||
#include "cmake.h"
|
||||
#include "cmCacheManager.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmExternalMakefileProjectGenerator.h"
|
||||
|
@ -135,7 +134,7 @@ cmake::cmake()
|
|||
this->ClearBuildSystem = false;
|
||||
this->FileComparison = new cmFileTimeComparison;
|
||||
|
||||
this->State = new cmState(this);
|
||||
this->State = new cmState;
|
||||
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -151,7 +150,6 @@ cmake::cmake()
|
|||
#endif
|
||||
|
||||
this->Verbose = false;
|
||||
this->CacheManager = new cmCacheManager(this);
|
||||
this->GlobalGenerator = 0;
|
||||
this->ProgressCallback = 0;
|
||||
this->ProgressCallbackClientData = 0;
|
||||
|
@ -171,7 +169,6 @@ cmake::cmake()
|
|||
|
||||
cmake::~cmake()
|
||||
{
|
||||
delete this->CacheManager;
|
||||
delete this->State;
|
||||
if (this->GlobalGenerator)
|
||||
{
|
||||
|
@ -216,7 +213,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|||
}
|
||||
std::string var, value;
|
||||
cmState::CacheEntryType type = cmState::UNINITIALIZED;
|
||||
if(cmCacheManager::ParseEntry(entry, var, value, type))
|
||||
if(cmState::ParseCacheEntry(entry, var, value, type))
|
||||
{
|
||||
// The value is transformed if it is a filepath for example, so
|
||||
// we can't compare whether the value is already in the cache until
|
||||
|
@ -232,7 +229,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
|||
}
|
||||
}
|
||||
|
||||
this->State->AddCacheEntry(var, value.c_str(),
|
||||
this->AddCacheEntry(var, value.c_str(),
|
||||
"No help, variable specified on the command line.", type);
|
||||
|
||||
if(this->WarnUnusedCli)
|
||||
|
@ -848,14 +845,14 @@ void cmake::SetDirectoriesFromFile(const char* arg)
|
|||
int cmake::AddCMakePaths()
|
||||
{
|
||||
// Save the value in the cache
|
||||
this->CacheManager->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(),
|
||||
"Path to CMake executable.", cmState::INTERNAL);
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
this->CacheManager->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
|
||||
"Path to ctest program executable.", cmState::INTERNAL);
|
||||
this->CacheManager->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(),
|
||||
"Path to cpack program executable.", cmState::INTERNAL);
|
||||
#endif
|
||||
|
@ -869,7 +866,7 @@ int cmake::AddCMakePaths()
|
|||
cmSystemTools::GetCMakeRoot().c_str());
|
||||
return 0;
|
||||
}
|
||||
this->CacheManager->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
|
||||
"Path to CMake installation.", cmState::INTERNAL);
|
||||
|
||||
|
@ -1086,10 +1083,10 @@ int cmake::DoPreConfigureChecks()
|
|||
}
|
||||
|
||||
// do a sanity check on some values
|
||||
if(this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"))
|
||||
if(this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"))
|
||||
{
|
||||
std::string cacheStart =
|
||||
this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
|
||||
this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
|
||||
cacheStart += "/CMakeLists.txt";
|
||||
std::string currentStart = this->GetHomeDirectory();
|
||||
currentStart += "/CMakeLists.txt";
|
||||
|
@ -1146,12 +1143,12 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|||
save.value = *i;
|
||||
warning << *i << "\n";
|
||||
const char* existingValue =
|
||||
this->CacheManager->GetCacheEntryValue(save.key);
|
||||
this->State->GetCacheEntryValue(save.key);
|
||||
if(existingValue)
|
||||
{
|
||||
save.type = this->CacheManager->GetCacheEntryType(save.key);
|
||||
save.type = this->State->GetCacheEntryType(save.key);
|
||||
if(const char* help =
|
||||
this->CacheManager->GetCacheEntryProperty(save.key, "HELPSTRING"))
|
||||
this->State->GetCacheEntryProperty(save.key, "HELPSTRING"))
|
||||
{
|
||||
save.help = help;
|
||||
}
|
||||
|
@ -1160,7 +1157,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
|
|||
}
|
||||
|
||||
// remove the cache
|
||||
this->CacheManager->DeleteCache(this->GetHomeOutputDirectory());
|
||||
this->DeleteCache(this->GetHomeOutputDirectory());
|
||||
// load the empty cache
|
||||
this->LoadCache();
|
||||
// restore the changed compilers
|
||||
|
@ -1186,7 +1183,7 @@ int cmake::Configure()
|
|||
{
|
||||
if(this->SuppressDevWarnings)
|
||||
{
|
||||
this->CacheManager->
|
||||
this->
|
||||
AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE",
|
||||
"Suppress Warnings that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
|
@ -1194,7 +1191,7 @@ int cmake::Configure()
|
|||
}
|
||||
else
|
||||
{
|
||||
this->CacheManager->
|
||||
this->
|
||||
AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE",
|
||||
"Suppress Warnings that are meant for"
|
||||
" the author of the CMakeLists.txt files.",
|
||||
|
@ -1229,7 +1226,7 @@ int cmake::ActualConfigure()
|
|||
}
|
||||
if ( !res )
|
||||
{
|
||||
this->CacheManager->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("CMAKE_HOME_DIRECTORY",
|
||||
this->GetHomeDirectory(),
|
||||
"Source directory with the top level CMakeLists.txt file for this "
|
||||
|
@ -1241,9 +1238,9 @@ int cmake::ActualConfigure()
|
|||
if(!this->GlobalGenerator)
|
||||
{
|
||||
const char* genName =
|
||||
this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR");
|
||||
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
|
||||
const char* extraGenName =
|
||||
this->CacheManager->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
|
||||
this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
|
||||
if(genName)
|
||||
{
|
||||
std::string fullName = cmExternalMakefileProjectGenerator::
|
||||
|
@ -1321,7 +1318,7 @@ int cmake::ActualConfigure()
|
|||
}
|
||||
}
|
||||
|
||||
const char* genName = this->CacheManager
|
||||
const char* genName = this->State
|
||||
->GetInitializedCacheValue("CMAKE_GENERATOR");
|
||||
if(genName)
|
||||
{
|
||||
|
@ -1338,20 +1335,20 @@ int cmake::ActualConfigure()
|
|||
return -2;
|
||||
}
|
||||
}
|
||||
if(!this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR"))
|
||||
if(!this->State->GetInitializedCacheValue("CMAKE_GENERATOR"))
|
||||
{
|
||||
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR",
|
||||
this->AddCacheEntry("CMAKE_GENERATOR",
|
||||
this->GlobalGenerator->GetName().c_str(),
|
||||
"Name of generator.",
|
||||
cmState::INTERNAL);
|
||||
this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
|
||||
this->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
|
||||
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
|
||||
"Name of external makefile project generator.",
|
||||
cmState::INTERNAL);
|
||||
}
|
||||
|
||||
if(const char* platformName =
|
||||
this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM"))
|
||||
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM"))
|
||||
{
|
||||
if(this->GeneratorPlatform.empty())
|
||||
{
|
||||
|
@ -1372,14 +1369,14 @@ int cmake::ActualConfigure()
|
|||
}
|
||||
else
|
||||
{
|
||||
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
|
||||
this->GeneratorPlatform.c_str(),
|
||||
"Name of generator platform.",
|
||||
cmState::INTERNAL);
|
||||
}
|
||||
|
||||
if(const char* tsName =
|
||||
this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET"))
|
||||
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET"))
|
||||
{
|
||||
if(this->GeneratorToolset.empty())
|
||||
{
|
||||
|
@ -1400,7 +1397,7 @@ int cmake::ActualConfigure()
|
|||
}
|
||||
else
|
||||
{
|
||||
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
|
||||
this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
|
||||
this->GeneratorToolset.c_str(),
|
||||
"Name of generator toolset.",
|
||||
cmState::INTERNAL);
|
||||
|
@ -1434,7 +1431,7 @@ int cmake::ActualConfigure()
|
|||
{
|
||||
if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH"))
|
||||
{
|
||||
this->State->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("LIBRARY_OUTPUT_PATH", "",
|
||||
"Single output directory for building all libraries.",
|
||||
cmState::PATH);
|
||||
|
@ -1442,7 +1439,7 @@ int cmake::ActualConfigure()
|
|||
if(!this->State
|
||||
->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH"))
|
||||
{
|
||||
this->State->AddCacheEntry
|
||||
this->AddCacheEntry
|
||||
("EXECUTABLE_OUTPUT_PATH", "",
|
||||
"Single output directory for building all executables.",
|
||||
cmState::PATH);
|
||||
|
@ -1462,7 +1459,7 @@ int cmake::ActualConfigure()
|
|||
// only save the cache if there were no fatal errors
|
||||
if ( this->GetWorkingMode() == NORMAL_MODE )
|
||||
{
|
||||
this->CacheManager->SaveCache(this->GetHomeOutputDirectory());
|
||||
this->SaveCache(this->GetHomeOutputDirectory());
|
||||
}
|
||||
if(cmSystemTools::GetErrorOccuredFlag())
|
||||
{
|
||||
|
@ -1632,7 +1629,7 @@ int cmake::Generate()
|
|||
// for the Visual Studio and Xcode generators.)
|
||||
if ( this->GetWorkingMode() == NORMAL_MODE )
|
||||
{
|
||||
this->CacheManager->SaveCache(this->GetHomeOutputDirectory());
|
||||
this->SaveCache(this->GetHomeOutputDirectory());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1641,14 +1638,15 @@ void cmake::AddCacheEntry(const std::string& key, const char* value,
|
|||
const char* helpString,
|
||||
int type)
|
||||
{
|
||||
this->CacheManager->AddCacheEntry(key, value,
|
||||
this->State->AddCacheEntry(key, value,
|
||||
helpString,
|
||||
cmState::CacheEntryType(type));
|
||||
this->UnwatchUnusedCli(key);
|
||||
}
|
||||
|
||||
const char* cmake::GetCacheDefinition(const std::string& name) const
|
||||
{
|
||||
return this->CacheManager->GetInitializedCacheValue(name);
|
||||
return this->State->GetInitializedCacheValue(name);
|
||||
}
|
||||
|
||||
void cmake::AddDefaultCommands()
|
||||
|
@ -1721,7 +1719,7 @@ bool cmake::ParseCacheEntry(const std::string& entry,
|
|||
std::string& value,
|
||||
cmState::CacheEntryType& type)
|
||||
{
|
||||
return cmCacheManager::ParseEntry(entry, var, value, type);
|
||||
return cmState::ParseCacheEntry(entry, var, value, type);
|
||||
}
|
||||
|
||||
int cmake::LoadCache()
|
||||
|
@ -1752,24 +1750,43 @@ int cmake::LoadCache()
|
|||
|
||||
bool cmake::LoadCache(const std::string& path)
|
||||
{
|
||||
return this->CacheManager->LoadCache(path);
|
||||
std::set<std::string> emptySet;
|
||||
return this->LoadCache(path, true, emptySet, emptySet);
|
||||
}
|
||||
|
||||
bool cmake::LoadCache(const std::string& path, bool internal,
|
||||
std::set<std::string>& excludes,
|
||||
std::set<std::string>& includes)
|
||||
{
|
||||
return this->CacheManager->LoadCache(path, internal, excludes, includes);
|
||||
bool result = this->State->LoadCache(path, internal, excludes, includes);
|
||||
static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION",
|
||||
"CMAKE_CACHE_MINOR_VERSION"};
|
||||
for (const char* const* nameIt = cmArrayBegin(entries);
|
||||
nameIt != cmArrayEnd(entries); ++nameIt)
|
||||
{
|
||||
this->UnwatchUnusedCli(*nameIt);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool cmake::SaveCache(const std::string& path)
|
||||
{
|
||||
return this->CacheManager->SaveCache(path);
|
||||
bool result = this->State->SaveCache(path);
|
||||
static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION",
|
||||
"CMAKE_CACHE_MINOR_VERSION",
|
||||
"CMAKE_CACHE_PATCH_VERSION",
|
||||
"CMAKE_CACHEFILE_DIR"};
|
||||
for (const char* const* nameIt = cmArrayBegin(entries);
|
||||
nameIt != cmArrayEnd(entries); ++nameIt)
|
||||
{
|
||||
this->UnwatchUnusedCli(*nameIt);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool cmake::DeleteCache(const std::string& path)
|
||||
{
|
||||
return this->CacheManager->DeleteCache(path);
|
||||
return this->State->DeleteCache(path);
|
||||
}
|
||||
|
||||
void cmake::SetProgressCallback(ProgressCallbackType f, void *cd)
|
||||
|
@ -1834,7 +1851,7 @@ void cmake::UpdateConversionPathTable()
|
|||
{
|
||||
// Update the path conversion table with any specified file:
|
||||
const char* tablepath =
|
||||
this->CacheManager
|
||||
this->State
|
||||
->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
|
||||
|
||||
if(tablepath)
|
||||
|
|
Loading…
Reference in New Issue