Commit 62c5e6f1 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'introduce-cmState'

f081c5bd cmState: Move CacheEntryType enum from cmCacheManager.
f71fdf0e cmMakefile: Remove unused CacheManager accessor.
ff7169a0 Port to cmState.
a6b1ad13 Introduce cmState class.
parents 92d61798 f081c5bd
......@@ -329,6 +329,8 @@ set(SRCS
cmSourceFileLocation.h
cmSourceGroup.cxx
cmSourceGroup.h
cmState.cxx
cmState.h
cmSystemTools.cxx
cmSystemTools.h
cmTarget.cxx
......
......@@ -9,7 +9,6 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
#include "../cmake.h"
#include "../cmDocumentation.h"
......
......@@ -16,7 +16,7 @@ cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
int left, int top) :
cmCursesWidget(width, height, left, top)
{
this->Type = cmCacheManager::BOOL;
this->Type = cmState::BOOL;
set_field_fore(this->Field, A_NORMAL);
set_field_back(this->Field, A_STANDOUT);
field_opts_off(this->Field, O_STATIC);
......
......@@ -19,6 +19,7 @@
#include "cmCursesDummyWidget.h"
#include "../cmSystemTools.h"
#include "../cmake.h"
#include "../cmState.h"
#include <assert.h>
......@@ -50,11 +51,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
this->Entry = 0;
const char* value = cm->GetCacheManager()->GetCacheEntryValue(key);
const char* value = cm->GetState()->GetCacheEntryValue(key);
assert(value);
switch (cm->GetCacheManager()->GetCacheEntryType(key))
switch (cm->GetState()->GetCacheEntryType(key))
{
case cmCacheManager::BOOL:
case cmState::BOOL:
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
if (cmSystemTools::IsOn(value))
{
......@@ -65,17 +66,17 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
}
break;
case cmCacheManager::PATH:
case cmState::PATH:
this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesPathWidget*>(this->Entry)->SetString(value);
break;
case cmCacheManager::FILEPATH:
case cmState::FILEPATH:
this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
break;
case cmCacheManager::STRING:
case cmState::STRING:
{
const char* stringsProp = cm->GetCacheManager()
const char* stringsProp = cm->GetState()
->GetCacheEntryProperty(key, "STRINGS");
if(stringsProp)
{
......@@ -98,7 +99,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
break;
}
case cmCacheManager::UNINITIALIZED:
case cmState::UNINITIALIZED:
cmSystemTools::Error("Found an undefined variable: ",
key.c_str());
break;
......
......@@ -12,7 +12,6 @@
#ifndef cmCursesCacheEntryComposite_h
#define cmCursesCacheEntryComposite_h
#include "../cmCacheManager.h"
#include "cmCursesLabelWidget.h"
class cmCursesCacheEntryComposite
......
......@@ -15,7 +15,7 @@ cmCursesDummyWidget::cmCursesDummyWidget(int width, int height,
int left, int top) :
cmCursesWidget(width, height, left, top)
{
this->Type = cmCacheManager::INTERNAL;
this->Type = cmState::INTERNAL;
}
......
......@@ -15,6 +15,6 @@ cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height,
int left, int top) :
cmCursesPathWidget(width, height, left, top)
{
this->Type = cmCacheManager::FILEPATH;
this->Type = cmState::FILEPATH;
}
......@@ -9,7 +9,6 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
#include "../cmake.h"
#include "../cmVersion.h"
......
......@@ -9,7 +9,6 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
#include "../cmVersion.h"
#include "../cmake.h"
......@@ -23,6 +22,7 @@
#include "cmCursesCacheEntryComposite.h"
#include "cmCursesLongMessageForm.h"
#include "cmAlgorithms.h"
#include "cmState.h"
inline int ctrl(int z)
......@@ -107,21 +107,21 @@ void cmCursesMainForm::InitializeUI()
// which contain labels, entries and new entry markers
std::vector<cmCursesCacheEntryComposite*>* newEntries =
new std::vector<cmCursesCacheEntryComposite*>;
newEntries->reserve(this->CMakeInstance->GetCacheManager()->GetSize());
std::vector<std::string> cacheKeys =
this->CMakeInstance->GetState()->GetCacheEntryKeys();
newEntries->reserve(cacheKeys.size());
// Count non-internal and non-static entries
int count=0;
std::vector<std::string> cacheKeys =
this->CMakeInstance->GetCacheManager()->GetCacheEntryKeys();
for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it)
{
cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager()
cmState::CacheEntryType t = this->CMakeInstance->GetState()
->GetCacheEntryType(*it);
if (t != cmCacheManager::INTERNAL &&
t != cmCacheManager::STATIC &&
t != cmCacheManager::UNINITIALIZED)
if (t != cmState::INTERNAL &&
t != cmState::STATIC &&
t != cmState::UNINITIALIZED)
{
++count;
}
......@@ -147,11 +147,11 @@ void cmCursesMainForm::InitializeUI()
it != cacheKeys.end(); ++it)
{
std::string key = *it;
cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager()
cmState::CacheEntryType t = this->CMakeInstance->GetState()
->GetCacheEntryType(*it);
if (t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC ||
t == cmCacheManager::UNINITIALIZED )
if (t == cmState::INTERNAL ||
t == cmState::STATIC ||
t == cmState::UNINITIALIZED )
{
continue;
}
......@@ -171,11 +171,11 @@ void cmCursesMainForm::InitializeUI()
it != cacheKeys.end(); ++it)
{
std::string key = *it;
cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager()
cmState::CacheEntryType t = this->CMakeInstance->GetState()
->GetCacheEntryType(*it);
if (t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC ||
t == cmCacheManager::UNINITIALIZED )
if (t == cmState::INTERNAL ||
t == cmState::STATIC ||
t == cmState::UNINITIALIZED )
{
continue;
}
......@@ -225,10 +225,10 @@ void cmCursesMainForm::RePost()
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
const char* existingValue =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryValue((*it)->GetValue());
bool advanced =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced))
{
......@@ -257,10 +257,10 @@ void cmCursesMainForm::RePost()
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
const char* existingValue =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryValue((*it)->GetValue());
bool advanced =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced))
{
......@@ -293,9 +293,9 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
cmCursesWidget* cw = reinterpret_cast<cmCursesWidget*>
(field_userptr(currentField));
// If in edit mode, get out of it
if ( cw->GetType() == cmCacheManager::STRING ||
cw->GetType() == cmCacheManager::PATH ||
cw->GetType() == cmCacheManager::FILEPATH )
if ( cw->GetType() == cmState::STRING ||
cw->GetType() == cmState::PATH ||
cw->GetType() == cmState::FILEPATH )
{
cmCursesStringWidget* sw = static_cast<cmCursesStringWidget*>(cw);
sw->SetInEdit(false);
......@@ -329,10 +329,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
const char* existingValue =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryValue((*it)->GetValue());
bool advanced =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced))
{
......@@ -352,10 +352,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
const char* existingValue =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryValue((*it)->GetValue());
bool advanced =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced))
{
......@@ -516,10 +516,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
// Get the help string of the current entry
// and add it to the help string
const char* existingValue =
this->CMakeInstance->GetCacheManager()->GetCacheEntryValue(curField);
this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
if (existingValue)
{
const char* hs = this->CMakeInstance->GetCacheManager()
const char* hs = this->CMakeInstance->GetState()
->GetCacheEntryProperty(curField, "HELPSTRING");
if ( hs )
{
......@@ -814,7 +814,7 @@ void cmCursesMainForm::FillCacheManagerFromUI()
for(size_t i=0; i < size; i++)
{
std::string cacheKey = (*this->Entries)[i]->Key;
const char* existingValue = this->CMakeInstance->GetCacheManager()
const char* existingValue = this->CMakeInstance->GetState()
->GetCacheEntryValue(cacheKey);
if (existingValue)
{
......@@ -822,8 +822,8 @@ void cmCursesMainForm::FillCacheManagerFromUI()
std::string newValue = (*this->Entries)[i]->Entry->GetValue();
std::string fixedOldValue;
std::string fixedNewValue;
cmCacheManager::CacheEntryType t =
this->CMakeInstance->GetCacheManager()
cmState::CacheEntryType t =
this->CMakeInstance->GetState()
->GetCacheEntryType(cacheKey);
this->FixValue(t, oldValue, fixedOldValue);
this->FixValue(t, newValue, fixedNewValue);
......@@ -831,24 +831,24 @@ void cmCursesMainForm::FillCacheManagerFromUI()
if(!(fixedOldValue == fixedNewValue))
{
// The user has changed the value. Mark it as modified.
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->SetCacheEntryBoolProperty(cacheKey, "MODIFIED", true);
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->SetCacheEntryValue(cacheKey, fixedNewValue);
}
}
}
}
void cmCursesMainForm::FixValue(cmCacheManager::CacheEntryType type,
void cmCursesMainForm::FixValue(cmState::CacheEntryType type,
const std::string& in, std::string& out) const
{
out = in.substr(0,in.find_last_not_of(" ")+1);
if(type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH)
if(type == cmState::PATH || type == cmState::FILEPATH)
{
cmSystemTools::ConvertToUnixSlashes(out);
}
if(type == cmCacheManager::BOOL)
if(type == cmState::BOOL)
{
if(cmSystemTools::IsOff(out.c_str()))
{
......@@ -1046,11 +1046,11 @@ void cmCursesMainForm::HandleInput()
const char* helpString = 0;
const char* existingValue =
this->CMakeInstance->GetCacheManager()
this->CMakeInstance->GetState()
->GetCacheEntryValue(curField);
if (existingValue)
{
helpString = this->CMakeInstance->GetCacheManager()
helpString = this->CMakeInstance->GetState()
->GetCacheEntryProperty(curField, "HELPSTRING");
}
if (helpString)
......@@ -1161,7 +1161,7 @@ void cmCursesMainForm::HandleInput()
field_userptr(this->Fields[findex-2]));
if ( lbl )
{
this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(lbl->GetValue());
this->CMakeInstance->GetState()->RemoveCacheEntry(lbl->GetValue());
std::string nextVal;
if (nextCur)
......
......@@ -113,7 +113,7 @@ protected:
// cache.
void FillCacheManagerFromUI();
// Fix formatting of values to a consistent form.
void FixValue(cmCacheManager::CacheEntryType type,
void FixValue(cmState::CacheEntryType type,
const std::string& in, std::string& out) const;
// Re-post the existing fields. Used to toggle between
// normal and advanced modes. Render() should be called
......
......@@ -21,7 +21,7 @@ cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height,
int left, int top) :
cmCursesWidget(width, height, left, top)
{
this->Type = cmCacheManager::BOOL; // this is a bit of a hack
this->Type = cmState::BOOL; // this is a bit of a hack
// there is no option type, and string type causes ccmake to cast
// the widget into a string widget at some point. BOOL is safe for
// now.
......
......@@ -18,7 +18,7 @@ cmCursesPathWidget::cmCursesPathWidget(int width, int height,
int left, int top) :
cmCursesStringWidget(width, height, left, top)
{
this->Type = cmCacheManager::PATH;
this->Type = cmState::PATH;
this->Cycle = false;
this->CurrentIndex = 0;
}
......@@ -59,7 +59,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
}
std::vector<std::string> dirs;
cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmCacheManager::PATH?-1:0));
cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmState::PATH?-1:0));
if ( this->CurrentIndex < dirs.size() )
{
cstr = dirs[this->CurrentIndex];
......
......@@ -22,7 +22,7 @@ cmCursesStringWidget::cmCursesStringWidget(int width, int height,
cmCursesWidget(width, height, left, top)
{
this->InEdit = false;
this->Type = cmCacheManager::STRING;
this->Type = cmState::STRING;
set_field_fore(this->Field, A_NORMAL);
set_field_back(this->Field, A_STANDOUT);
field_opts_off(this->Field, O_STATIC);
......
......@@ -12,7 +12,7 @@
#ifndef cmCursesWidget_h
#define cmCursesWidget_h
#include "../cmCacheManager.h"
#include "../cmState.h"
#include "cmCursesStandardIncludes.h"
class cmCursesMainForm;
......@@ -46,7 +46,7 @@ public:
/**
* Get the type of the widget (STRING, PATH etc...)
*/
cmCacheManager::CacheEntryType GetType()
cmState::CacheEntryType GetType()
{ return this->Type; }
/**
......@@ -77,7 +77,7 @@ protected:
cmCursesWidget(const cmCursesWidget& from);
void operator=(const cmCursesWidget&);
cmCacheManager::CacheEntryType Type;
cmState::CacheEntryType Type;
std::string Value;
FIELD* Field;
// The page in the main form this widget is in
......
......@@ -16,7 +16,7 @@
#include <QCoreApplication>
#include "cmake.h"
#include "cmCacheManager.h"
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmExternalMakefileProjectGenerator.h"
......@@ -94,7 +94,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
{
this->BinaryDirectory = QDir::fromNativeSeparators(dir);
emit this->binaryDirChanged(this->BinaryDirectory);
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
cmState* state = this->CMakeInstance->GetState();
this->setGenerator(QString());
if(!this->CMakeInstance->LoadCache(
this->BinaryDirectory.toLocal8Bit().data()))
......@@ -110,15 +110,15 @@ void QCMake::setBinaryDirectory(const QString& _dir)
QCMakePropertyList props = this->properties();
emit this->propertiesChanged(props);
const char* homeDir = cachem->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
const char* homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
if (homeDir)
{
setSourceDirectory(QString::fromLocal8Bit(homeDir));
}
const char* gen = cachem->GetCacheEntryValue("CMAKE_GENERATOR");
const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
if (gen)
{
const char* extraGen = cachem
const char* extraGen = state
->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen = cmExternalMakefileProjectGenerator::
CreateFullGeneratorName(gen, extraGen? extraGen : "");
......@@ -195,14 +195,14 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
QStringList toremove;
// set the value of properties
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it)
{
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*it);
if(t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC)
cmState::CacheEntryType t = state->GetCacheEntryType(*it);
if(t == cmState::INTERNAL ||
t == cmState::STATIC)
{
continue;
}
......@@ -219,11 +219,11 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
prop = props[idx];
if(prop.Value.type() == QVariant::Bool)
{
cachem->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
}
else
{
cachem->SetCacheEntryValue(*it,
state->SetCacheEntryValue(*it,
prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
......@@ -236,7 +236,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
{
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
cachem->RemoveCacheEntry(s.toLocal8Bit().data());
state->RemoveCacheEntry(s.toLocal8Bit().data());
}
// add some new properites
......@@ -249,28 +249,28 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
s.Value.toBool() ? "ON" : "OFF",
s.Help.toLocal8Bit().data(),
cmCacheManager::BOOL);
cmState::BOOL);
}
else if(s.Type == QCMakeProperty::STRING)
{
this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
s.Value.toString().toLocal8Bit().data(),
s.Help.toLocal8Bit().data(),
cmCacheManager::STRING);
cmState::STRING);
}
else if(s.Type == QCMakeProperty::PATH)
{
this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
s.Value.toString().toLocal8Bit().data(),
s.Help.toLocal8Bit().data(),
cmCacheManager::PATH);
cmState::PATH);
}
else if(s.Type == QCMakeProperty::FILEPATH)
{
this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
s.Value.toString().toLocal8Bit().data(),
s.Help.toLocal8Bit().data(),
cmCacheManager::FILEPATH);
cmState::FILEPATH);
}
}
......@@ -281,45 +281,45 @@ QCMakePropertyList QCMake::properties() const
{
QCMakePropertyList ret;
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
i != cacheKeys.end(); ++i)
{
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*i);
if(t == cmCacheManager::INTERNAL ||
t == cmCacheManager::STATIC ||
t == cmCacheManager::UNINITIALIZED)
cmState::CacheEntryType t = state->GetCacheEntryType(*i);
if(t == cmState::INTERNAL ||
t == cmState::STATIC ||
t == cmState::UNINITIALIZED)
{
continue;
}
const char* cachedValue = cachem->GetCacheEntryValue(*i);
const char* cachedValue = state->GetCacheEntryValue(*i);
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i->c_str());
prop.Help = QString::fromLocal8Bit(
cachem->GetCacheEntryProperty(*i, "HELPSTRING"));
state->GetCacheEntryProperty(*i, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
prop.Advanced = cachem->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
if(t == cmCacheManager::BOOL)
prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
if(t == cmState::BOOL)
{
prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(cachedValue);
}
else if(t == cmCacheManager::PATH)
else if(t == cmState::PATH)
{
prop.Type = QCMakeProperty::PATH;
}
else if(t == cmCacheManager::FILEPATH)
else if(t == cmState::FILEPATH)
{
prop.Type = QCMakeProperty::FILEPATH;
}
else if(t == cmCacheManager::STRING)
else if(t == cmState::STRING)
{
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
cachem->GetCacheEntryProperty(*i, "STRINGS");
state->GetCacheEntryProperty(*i, "STRINGS");
if (stringsProperty)
{
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
......
......@@ -147,6 +147,6 @@ bool cmBuildCommand
makecommand.c_str(),
"Command used to build entire project "
"from the command line.",