Move property definition to cmState.

This commit is contained in:
Stephen Kelly 2015-04-04 23:33:26 +02:00
parent 62c5e6f1a1
commit b159bff732
12 changed files with 87 additions and 97 deletions

View File

@ -867,7 +867,7 @@ void CCONV DefineSourceFileProperty (void *arg, const char *name,
int chained) int chained)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
mf->GetCMakeInstance()->DefineProperty(name,cmProperty::SOURCE_FILE, mf->GetState()->DefineProperty(name,cmProperty::SOURCE_FILE,
briefDocs, longDocs, briefDocs, longDocs,
chained != 0); chained != 0);
} }

View File

@ -11,6 +11,7 @@
============================================================================*/ ============================================================================*/
#include "cmDefinePropertyCommand.h" #include "cmDefinePropertyCommand.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
bool cmDefinePropertyCommand bool cmDefinePropertyCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@ -127,7 +128,7 @@ bool cmDefinePropertyCommand
} }
// Actually define the property. // Actually define the property.
this->Makefile->GetCMakeInstance()->DefineProperty this->Makefile->GetState()->DefineProperty
(this->PropertyName, scope, (this->PropertyName, scope,
this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited); this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);

View File

@ -143,7 +143,7 @@ bool cmGetPropertyCommand
// Lookup brief documentation. // Lookup brief documentation.
std::string output; std::string output;
if(cmPropertyDefinition* def = if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()-> this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
output = def->GetShortDescription(); output = def->GetShortDescription();
@ -159,7 +159,7 @@ bool cmGetPropertyCommand
// Lookup full documentation. // Lookup full documentation.
std::string output; std::string output;
if(cmPropertyDefinition* def = if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()-> this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
output = def->GetFullDescription(); output = def->GetFullDescription();
@ -173,7 +173,7 @@ bool cmGetPropertyCommand
else if(this->InfoType == OutDefined) else if(this->InfoType == OutDefined)
{ {
// Lookup if the property is defined // Lookup if the property is defined
if(this->Makefile->GetCMakeInstance()-> if(this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
this->Makefile->AddDefinition(this->Variable, "1"); this->Makefile->AddDefinition(this->Variable, "1");

View File

@ -4476,21 +4476,6 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
} }
} }
// define properties
void cmMakefile::DefineProperties(cmake *cm)
{
cm->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
"", "", true);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmMakefile::AddImportedTarget(const std::string& name, cmMakefile::AddImportedTarget(const std::string& name,

View File

@ -851,9 +851,6 @@ public:
const std::vector<cmTestGenerator*>& GetTestGenerators() const const std::vector<cmTestGenerator*>& GetTestGenerators() const
{ return this->TestGenerators; } { return this->TestGenerators; }
// Define the properties
static void DefineProperties(cmake *cm);
// push and pop variable scopes // push and pop variable scopes
void PushScope(); void PushScope();
void PopScope(); void PopScope();

View File

@ -12,6 +12,7 @@
#include "cmPropertyMap.h" #include "cmPropertyMap.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
{ {
@ -73,7 +74,8 @@ const char *cmPropertyMap
// should we chain up? // should we chain up?
if (this->CMakeInstance) if (this->CMakeInstance)
{ {
chain = this->CMakeInstance->IsPropertyChained(name,scope); chain = this->CMakeInstance->GetState()->
IsPropertyChained(name,scope);
} }
return 0; return 0;
} }

View File

@ -178,3 +178,61 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
this->CMakeInstance->GetCacheManager() this->CMakeInstance->GetCacheManager()
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
} }
void cmState::Initialize()
{
this->PropertyDefinitions.clear();
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::TARGET,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
"", "", true);
}
void cmState::DefineProperty(const std::string& name,
cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
{
this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
FullDescription,
chained);
}
cmPropertyDefinition *cmState
::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
{
return &(this->PropertyDefinitions[scope][name]);
}
return 0;
}
bool cmState::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
bool cmState::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}

View File

@ -13,6 +13,7 @@
#define cmState_h #define cmState_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmPropertyDefinitionMap.h"
class cmake; class cmake;
@ -55,7 +56,25 @@ public:
void RemoveCacheEntryProperty(std::string const& key, void RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName); std::string const& propertyName);
void Initialize();
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
(const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
private: private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
cmake* CMakeInstance; cmake* CMakeInstance;
}; };

View File

@ -264,20 +264,6 @@ cmTarget::cmTarget()
this->LinkImplementationLanguageIsContextDependent = true; this->LinkImplementationLanguageIsContextDependent = true;
} }
//----------------------------------------------------------------------------
void cmTarget::DefineProperties(cmake *cm)
{
cm->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::TARGET,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
"", "", true);
}
void cmTarget::SetType(TargetType type, const std::string& name) void cmTarget::SetType(TargetType type, const std::string& name)
{ {
this->Name = name; this->Name = name;

View File

@ -489,9 +489,6 @@ public:
const char** imp, const char** imp,
std::string& suffix) const; std::string& suffix) const;
// Define the properties
static void DefineProperties(cmake *cm);
/** Get the macro to define when building sources in this target. /** Get the macro to define when building sources in this target.
If no macro should be defined null is returned. */ If no macro should be defined null is returned. */
const char* GetExportMacro() const; const char* GetExportMacro() const;

View File

@ -191,11 +191,8 @@ cmake::~cmake()
void cmake::InitializeProperties() void cmake::InitializeProperties()
{ {
this->Properties.clear(); this->Properties.clear();
this->PropertyDefinitions.clear();
// initialize properties this->State->Initialize();
cmTarget::DefineProperties(this);
cmMakefile::DefineProperties(this);
} }
void cmake::CleanupCommandsAndMacros() void cmake::CleanupCommandsAndMacros()
@ -2298,40 +2295,6 @@ void cmake::GenerateGraphViz(const char* fileName) const
#endif #endif
} }
void cmake::DefineProperty(const std::string& name,
cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
{
this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
FullDescription,
chained);
}
cmPropertyDefinition *cmake
::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
{
return &(this->PropertyDefinitions[scope][name]);
}
return 0;
}
bool cmake::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
bool cmake::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}
void cmake::SetProperty(const std::string& prop, const char* value) void cmake::SetProperty(const std::string& prop, const char* value)
{ {
this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);

View File

@ -15,7 +15,6 @@
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmPropertyDefinitionMap.h"
#include "cmPropertyMap.h" #include "cmPropertyMap.h"
#include "cmInstalledFile.h" #include "cmInstalledFile.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
@ -323,20 +322,6 @@ class cmake
void MarkCliAsUsed(const std::string& variable); void MarkCliAsUsed(const std::string& variable);
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
(const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
/** Get the list of configurations (in upper case) considered to be /** Get the list of configurations (in upper case) considered to be
debugging configurations.*/ debugging configurations.*/
std::vector<std::string> GetDebugConfigs(); std::vector<std::string> GetDebugConfigs();
@ -373,9 +358,6 @@ protected:
int HandleDeleteCacheVariables(const std::string& var); int HandleDeleteCacheVariables(const std::string& var);
cmPropertyMap Properties; cmPropertyMap Properties;
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>
PropertyDefinitions;
typedef typedef
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
typedef std::map<std::string, typedef std::map<std::string,