BUG: All variable accesses should produce watch callbacks, including IF(DEFINED <var>) ones. Instead we define a new access type for IF(DEFINED) so that the error does not show up for backward compatibility variables.
This commit is contained in:
parent
b47807fc15
commit
9a5b4eba97
|
@ -307,17 +307,18 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
|
|||
if (*arg == "DEFINED" && argP1 != newArgs.end())
|
||||
{
|
||||
size_t argP1len = argP1->size();
|
||||
bool bdef = false;
|
||||
if(argP1len > 4 && argP1->substr(0, 4) == "ENV{" &&
|
||||
argP1->operator[](argP1len-1) == '}')
|
||||
{
|
||||
std::string env = argP1->substr(4, argP1len-5);
|
||||
def = cmSystemTools::GetEnv(env.c_str());
|
||||
bdef = cmSystemTools::GetEnv(env.c_str())?true:false;
|
||||
}
|
||||
else
|
||||
{
|
||||
def = makefile->GetDefinitionNoWatch((argP1)->c_str());
|
||||
bdef = makefile->IsDefinitionSet((argP1)->c_str());
|
||||
}
|
||||
if(def)
|
||||
if(bdef)
|
||||
{
|
||||
*arg = "1";
|
||||
}
|
||||
|
|
|
@ -1633,7 +1633,7 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetDefinitionNoWatch(const char* name) const
|
||||
bool cmMakefile::IsDefinitionSet(const char* name) const
|
||||
{
|
||||
const char* def = 0;
|
||||
DefinitionMap::const_iterator pos = this->Definitions.find(name);
|
||||
|
@ -1645,12 +1645,32 @@ const char* cmMakefile::GetDefinitionNoWatch(const char* name) const
|
|||
{
|
||||
def = this->GetCacheManager()->GetCacheValue(name);
|
||||
}
|
||||
return def;
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
if(cmVariableWatch* vv = this->GetVariableWatch())
|
||||
{
|
||||
if(!def)
|
||||
{
|
||||
vv->VariableAccessed
|
||||
(name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS,
|
||||
def, this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return def?true:false;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetDefinition(const char* name) const
|
||||
{
|
||||
const char* def = this->GetDefinitionNoWatch(name);
|
||||
const char* def = 0;
|
||||
DefinitionMap::const_iterator pos = this->Definitions.find(name);
|
||||
if(pos != this->Definitions.end())
|
||||
{
|
||||
def = (*pos).second.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
def = this->GetCacheManager()->GetCacheValue(name);
|
||||
}
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
cmVariableWatch* vv = this->GetVariableWatch();
|
||||
if ( vv )
|
||||
|
|
|
@ -492,9 +492,9 @@ public:
|
|||
* cache is then queried.
|
||||
*/
|
||||
const char* GetDefinition(const char*) const;
|
||||
const char* GetDefinitionNoWatch(const char*) const;
|
||||
const char* GetSafeDefinition(const char*) const;
|
||||
const char* GetRequiredDefinition(const char* name) const;
|
||||
bool IsDefinitionSet(const char*) const;
|
||||
/**
|
||||
* Get the list of all variables in the current space. If argument
|
||||
* cacheonly is specified and is greater than 0, then only cache
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
{
|
||||
VARIABLE_READ_ACCESS = 0,
|
||||
UNKNOWN_VARIABLE_READ_ACCESS,
|
||||
UNKNOWN_VARIABLE_DEFINED_ACCESS,
|
||||
ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS,
|
||||
VARIABLE_MODIFIED_ACCESS,
|
||||
VARIABLE_REMOVED_ACCESS,
|
||||
|
|
Loading…
Reference in New Issue