cmState: Port away from cmake instance.

This commit is contained in:
Stephen Kelly 2015-10-10 15:42:02 +02:00
parent e2eecae205
commit 79a309d786
3 changed files with 28 additions and 29 deletions

View File

@ -82,9 +82,8 @@ struct cmState::BuildsystemDirectoryStateType
std::vector<cmState::Snapshot> Children; std::vector<cmState::Snapshot> Children;
}; };
cmState::cmState(cmake* cm) cmState::cmState()
: CMakeInstance(cm), : IsInTryCompile(false),
IsInTryCompile(false),
WindowsShell(false), WindowsShell(false),
WindowsVSIDE(false), WindowsVSIDE(false),
WatcomWMake(false), WatcomWMake(false),
@ -92,10 +91,12 @@ cmState::cmState(cmake* cm)
NMake(false), NMake(false),
MSYSShell(false) MSYSShell(false)
{ {
this->CacheManager = new cmCacheManager;
} }
cmState::~cmState() cmState::~cmState()
{ {
delete this->CacheManager;
cmDeleteAll(this->Commands); cmDeleteAll(this->Commands);
} }
@ -151,26 +152,26 @@ bool cmState::LoadCache(const std::string& path, bool internal,
std::set<std::string>& excludes, std::set<std::string>& excludes,
std::set<std::string>& includes) std::set<std::string>& includes)
{ {
return this->CMakeInstance->GetCacheManager()->LoadCache(path, internal, return this->CacheManager->LoadCache(path, internal,
excludes, includes); excludes, includes);
} }
bool cmState::SaveCache(const std::string& path) bool cmState::SaveCache(const std::string& path)
{ {
return this->CMakeInstance->GetCacheManager()->SaveCache(path); return this->CacheManager->SaveCache(path);
} }
bool cmState::DeleteCache(const std::string& path) bool cmState::DeleteCache(const std::string& path)
{ {
return this->CMakeInstance->GetCacheManager()->DeleteCache(path); return this->CacheManager->DeleteCache(path);
} }
std::vector<std::string> cmState::GetCacheEntryKeys() const std::vector<std::string> cmState::GetCacheEntryKeys() const
{ {
std::vector<std::string> definitions; std::vector<std::string> definitions;
definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize()); definitions.reserve(this->CacheManager->GetSize());
cmCacheManager::CacheIterator cit = cmCacheManager::CacheIterator cit =
this->CMakeInstance->GetCacheManager()->GetCacheIterator(); this->CacheManager->GetCacheIterator();
for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
{ {
definitions.push_back(cit.GetName()); definitions.push_back(cit.GetName());
@ -180,7 +181,7 @@ std::vector<std::string> cmState::GetCacheEntryKeys() const
const char* cmState::GetCacheEntryValue(std::string const& key) const const char* cmState::GetCacheEntryValue(std::string const& key) const
{ {
cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager() cmCacheManager::CacheEntry* e = this->CacheManager
->GetCacheEntry(key); ->GetCacheEntry(key);
if (!e) if (!e)
{ {
@ -192,21 +193,21 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const
const char* const char*
cmState::GetInitializedCacheValue(std::string const& key) const cmState::GetInitializedCacheValue(std::string const& key) const
{ {
return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key); return this->CacheManager->GetInitializedCacheValue(key);
} }
cmState::CacheEntryType cmState::CacheEntryType
cmState::GetCacheEntryType(std::string const& key) const cmState::GetCacheEntryType(std::string const& key) const
{ {
cmCacheManager::CacheIterator it = cmCacheManager::CacheIterator it =
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); this->CacheManager->GetCacheIterator(key.c_str());
return it.GetType(); return it.GetType();
} }
void cmState::SetCacheEntryValue(std::string const& key, void cmState::SetCacheEntryValue(std::string const& key,
std::string const& value) std::string const& value)
{ {
this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value); this->CacheManager->SetCacheEntryValue(key, value);
} }
void cmState::SetCacheEntryProperty(std::string const& key, void cmState::SetCacheEntryProperty(std::string const& key,
@ -214,7 +215,7 @@ void cmState::SetCacheEntryProperty(std::string const& key,
std::string const& value) std::string const& value)
{ {
cmCacheManager::CacheIterator it = cmCacheManager::CacheIterator it =
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); this->CacheManager->GetCacheIterator(key.c_str());
it.SetProperty(propertyName, value.c_str()); it.SetProperty(propertyName, value.c_str());
} }
@ -223,14 +224,14 @@ void cmState::SetCacheEntryBoolProperty(std::string const& key,
bool value) bool value)
{ {
cmCacheManager::CacheIterator it = cmCacheManager::CacheIterator it =
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); this->CacheManager->GetCacheIterator(key.c_str());
it.SetProperty(propertyName, value); it.SetProperty(propertyName, value);
} }
const char* cmState::GetCacheEntryProperty(std::string const& key, const char* cmState::GetCacheEntryProperty(std::string const& key,
std::string const& propertyName) std::string const& propertyName)
{ {
cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager() cmCacheManager::CacheIterator it = this->CacheManager
->GetCacheIterator(key.c_str()); ->GetCacheIterator(key.c_str());
if (!it.PropertyExists(propertyName)) if (!it.PropertyExists(propertyName))
{ {
@ -242,7 +243,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key,
bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
std::string const& propertyName) std::string const& propertyName)
{ {
return this->CMakeInstance->GetCacheManager() return this->CacheManager
->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName); ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName);
} }
@ -250,13 +251,13 @@ void cmState::AddCacheEntry(const std::string& key, const char* value,
const char* helpString, const char* helpString,
cmState::CacheEntryType type) cmState::CacheEntryType type)
{ {
this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value, this->CacheManager->AddCacheEntry(key, value,
helpString, type); helpString, type);
} }
void cmState::RemoveCacheEntry(std::string const& key) void cmState::RemoveCacheEntry(std::string const& key)
{ {
this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key); this->CacheManager->RemoveCacheEntry(key);
} }
void cmState::AppendCacheEntryProperty(const std::string& key, void cmState::AppendCacheEntryProperty(const std::string& key,
@ -264,7 +265,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key,
const std::string& value, const std::string& value,
bool asString) bool asString)
{ {
this->CMakeInstance->GetCacheManager() this->CacheManager
->GetCacheIterator(key.c_str()).AppendProperty(property, ->GetCacheIterator(key.c_str()).AppendProperty(property,
value.c_str(), value.c_str(),
asString); asString);
@ -273,7 +274,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key,
void cmState::RemoveCacheEntryProperty(std::string const& key, void cmState::RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName) std::string const& propertyName)
{ {
this->CMakeInstance->GetCacheManager() this->CacheManager
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
} }
@ -679,12 +680,12 @@ bool cmState::UseMSYSShell() const
unsigned int cmState::GetCacheMajorVersion() const unsigned int cmState::GetCacheMajorVersion() const
{ {
return this->CMakeInstance->GetCacheManager()->GetCacheMajorVersion(); return this->CacheManager->GetCacheMajorVersion();
} }
unsigned int cmState::GetCacheMinorVersion() const unsigned int cmState::GetCacheMinorVersion() const
{ {
return this->CMakeInstance->GetCacheManager()->GetCacheMinorVersion(); return this->CacheManager->GetCacheMinorVersion();
} }
const char* cmState::GetBinaryDirectory() const const char* cmState::GetBinaryDirectory() const

View File

@ -23,6 +23,7 @@ class cmake;
class cmCommand; class cmCommand;
class cmDefinitions; class cmDefinitions;
class cmListFileBacktrace; class cmListFileBacktrace;
class cmCacheManager;
class cmState class cmState
{ {
@ -32,7 +33,7 @@ class cmState
typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
friend class Snapshot; friend class Snapshot;
public: public:
cmState(cmake* cm); cmState();
~cmState(); ~cmState();
enum SnapshotType enum SnapshotType
@ -320,7 +321,7 @@ private:
std::vector<std::string> EnabledLanguages; std::vector<std::string> EnabledLanguages;
std::map<std::string, cmCommand*> Commands; std::map<std::string, cmCommand*> Commands;
cmPropertyMap GlobalProperties; cmPropertyMap GlobalProperties;
cmake* CMakeInstance; cmCacheManager* CacheManager;
cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory;

View File

@ -10,7 +10,6 @@
See the License for more information. See the License for more information.
============================================================================*/ ============================================================================*/
#include "cmake.h" #include "cmake.h"
#include "cmCacheManager.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmExternalMakefileProjectGenerator.h" #include "cmExternalMakefileProjectGenerator.h"
@ -135,7 +134,7 @@ cmake::cmake()
this->ClearBuildSystem = false; this->ClearBuildSystem = false;
this->FileComparison = new cmFileTimeComparison; this->FileComparison = new cmFileTimeComparison;
this->State = new cmState(this); this->State = new cmState;
this->CurrentSnapshot = this->State->CreateBaseSnapshot(); this->CurrentSnapshot = this->State->CreateBaseSnapshot();
#ifdef __APPLE__ #ifdef __APPLE__
@ -151,7 +150,6 @@ cmake::cmake()
#endif #endif
this->Verbose = false; this->Verbose = false;
this->CacheManager = new cmCacheManager;
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
this->ProgressCallback = 0; this->ProgressCallback = 0;
this->ProgressCallbackClientData = 0; this->ProgressCallbackClientData = 0;
@ -171,7 +169,6 @@ cmake::cmake()
cmake::~cmake() cmake::~cmake()
{ {
delete this->CacheManager;
delete this->State; delete this->State;
if (this->GlobalGenerator) if (this->GlobalGenerator)
{ {