Merge topic 'clean-up-cmMakefile'
4c192fb5 cmMakefile: Remove cacheOnly option from GetDefinitions. 046aafff cmGetCMakePropertyCommand: Don't explicitly specify default param. 021c4b6f cmMakefile: Simplify handling of CACHE_VARIABLES property. 1981c971 cmMakefile: Simplify InitializeFromParent method. 353e422b cmMakefile: Remove unused GetPolicies method. 00bfa047 cmMakefile: Out-of-line the cmMakefileCall. db74ce58 cmMakefile: Inline PushScope into PushFunctionScope. ca140c2e cmMakefile: Create a unified raii for macro scopes. d5dc4169 cmMakefile: Create a unified raii for function scopes.
This commit is contained in:
commit
ccc6fe9445
@ -73,7 +73,6 @@ public:
|
|||||||
cmPolicies::PolicyMap Policies;
|
cmPolicies::PolicyMap Policies;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool cmFunctionHelperCommand::InvokeInitialPass
|
bool cmFunctionHelperCommand::InvokeInitialPass
|
||||||
(const std::vector<cmListFileArgument>& args,
|
(const std::vector<cmListFileArgument>& args,
|
||||||
cmExecutionStatus & inStatus)
|
cmExecutionStatus & inStatus)
|
||||||
@ -93,14 +92,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we push a scope on the makefile
|
cmMakefile::FunctionPushPop functionScope(this->Makefile,
|
||||||
cmMakefile::ScopePushPop varScope(this->Makefile);
|
this->Policies);
|
||||||
cmMakefile::LexicalPushPop lexScope(this->Makefile);
|
|
||||||
static_cast<void>(varScope);
|
|
||||||
|
|
||||||
// Push a weak policy scope which restores the policies recorded at
|
|
||||||
// function creation.
|
|
||||||
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
|
|
||||||
|
|
||||||
// set the value of argc
|
// set the value of argc
|
||||||
std::ostringstream strStream;
|
std::ostringstream strStream;
|
||||||
@ -145,8 +138,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
|
|||||||
{
|
{
|
||||||
// The error message should have already included the call stack
|
// The error message should have already included the call stack
|
||||||
// so we do not need to report an error here.
|
// so we do not need to report an error here.
|
||||||
lexScope.Quiet();
|
functionScope.Quiet();
|
||||||
polScope.Quiet();
|
|
||||||
inStatus.SetNestedError(true);
|
inStatus.SetNestedError(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,7 @@ bool cmGetCMakePropertyCommand
|
|||||||
|
|
||||||
if ( args[1] == "VARIABLES" )
|
if ( args[1] == "VARIABLES" )
|
||||||
{
|
{
|
||||||
int cacheonly = 0;
|
std::vector<std::string> vars = this->Makefile->GetDefinitions();
|
||||||
std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
|
|
||||||
if (!vars.empty())
|
if (!vars.empty())
|
||||||
{
|
{
|
||||||
output = cmJoin(vars, ";");
|
output = cmJoin(vars, ";");
|
||||||
|
@ -96,12 +96,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce matching logical blocks inside the macro.
|
cmMakefile::MacroPushPop macroScope(this->Makefile,
|
||||||
cmMakefile::LexicalPushPop lexScope(this->Makefile);
|
this->Policies);
|
||||||
|
|
||||||
// Push a weak policy scope which restores the policies recorded at
|
|
||||||
// macro creation.
|
|
||||||
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
|
|
||||||
|
|
||||||
// set the value of argc
|
// set the value of argc
|
||||||
std::ostringstream argcDefStream;
|
std::ostringstream argcDefStream;
|
||||||
@ -191,8 +187,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|||||||
{
|
{
|
||||||
// The error message should have already included the call stack
|
// The error message should have already included the call stack
|
||||||
// so we do not need to report an error here.
|
// so we do not need to report an error here.
|
||||||
lexScope.Quiet();
|
macroScope.Quiet();
|
||||||
polScope.Quiet();
|
|
||||||
inStatus.SetNestedError(true);
|
inStatus.SetNestedError(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1485,10 +1485,8 @@ void cmMakefile::AddLinkDirectory(const std::string& dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::InitializeFromParent()
|
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
||||||
{
|
{
|
||||||
cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
|
|
||||||
|
|
||||||
// Initialize definitions with the closure of the parent scope.
|
// Initialize definitions with the closure of the parent scope.
|
||||||
this->Internal->InitializeDefinitions(parent);
|
this->Internal->InitializeDefinitions(parent);
|
||||||
|
|
||||||
@ -1562,6 +1560,56 @@ void cmMakefile::InitializeFromParent()
|
|||||||
this->ImportedTargets = parent->ImportedTargets;
|
this->ImportedTargets = parent->ImportedTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm)
|
||||||
|
{
|
||||||
|
this->Internal->PushDefinitions();
|
||||||
|
|
||||||
|
this->PushLoopBlockBarrier();
|
||||||
|
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this->PushFunctionBlockerBarrier();
|
||||||
|
|
||||||
|
this->PushPolicy(true, pm);
|
||||||
|
this->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PopFunctionScope(bool reportError)
|
||||||
|
{
|
||||||
|
this->PopPolicyBarrier(reportError);
|
||||||
|
this->PopPolicy();
|
||||||
|
|
||||||
|
this->PopFunctionBlockerBarrier(reportError);
|
||||||
|
|
||||||
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
|
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this->PopLoopBlockBarrier();
|
||||||
|
|
||||||
|
this->CheckForUnusedVariables();
|
||||||
|
|
||||||
|
this->Internal->PopDefinitions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm)
|
||||||
|
{
|
||||||
|
this->PushFunctionBlockerBarrier();
|
||||||
|
|
||||||
|
this->PushPolicy(true, pm);
|
||||||
|
this->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PopMacroScope(bool reportError)
|
||||||
|
{
|
||||||
|
this->PopPolicyBarrier(reportError);
|
||||||
|
this->PopPolicy();
|
||||||
|
|
||||||
|
this->PopFunctionBlockerBarrier(reportError);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
class cmMakefileCurrent
|
class cmMakefileCurrent
|
||||||
{
|
{
|
||||||
@ -1622,7 +1670,7 @@ void cmMakefile::Configure()
|
|||||||
|
|
||||||
void cmMakefile::ConfigureSubDirectory(cmMakefile *mf)
|
void cmMakefile::ConfigureSubDirectory(cmMakefile *mf)
|
||||||
{
|
{
|
||||||
mf->InitializeFromParent();
|
mf->InitializeFromParent(this);
|
||||||
std::string currentStart = mf->GetCurrentSourceDirectory();
|
std::string currentStart = mf->GetCurrentSourceDirectory();
|
||||||
if (this->GetCMakeInstance()->GetDebugOutput())
|
if (this->GetCMakeInstance()->GetDebugOutput())
|
||||||
{
|
{
|
||||||
@ -2449,18 +2497,11 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> cmMakefile
|
std::vector<std::string> cmMakefile::GetDefinitions() const
|
||||||
::GetDefinitions(int cacheonly /* = 0 */) const
|
|
||||||
{
|
{
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res = this->Internal->ClosureKeys();
|
||||||
if ( !cacheonly )
|
std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
|
||||||
{
|
|
||||||
res = this->Internal->ClosureKeys();
|
|
||||||
}
|
|
||||||
std::vector<std::string> cacheKeys =
|
|
||||||
this->GetState()->GetCacheEntryKeys();
|
|
||||||
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
|
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
|
||||||
|
|
||||||
std::sort(res.begin(), res.end());
|
std::sort(res.begin(), res.end());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -4115,14 +4156,14 @@ const char *cmMakefile::GetProperty(const std::string& prop,
|
|||||||
output = cmJoin(this->ListFileStack, ";");
|
output = cmJoin(this->ListFileStack, ";");
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
|
else if ( prop == "CACHE_VARIABLES" )
|
||||||
{
|
{
|
||||||
int cacheonly = 0;
|
output = cmJoin(this->GetState()->GetCacheEntryKeys(), ";");
|
||||||
if ( prop == "CACHE_VARIABLES" )
|
return output.c_str();
|
||||||
{
|
}
|
||||||
cacheonly = 1;
|
else if (prop == "VARIABLES")
|
||||||
}
|
{
|
||||||
output = cmJoin(this->GetDefinitions(cacheonly), ";");
|
output = cmJoin(this->GetDefinitions(), ";");
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
else if (prop == "MACROS")
|
else if (prop == "MACROS")
|
||||||
@ -5396,3 +5437,41 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushFunctionScope(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefile::FunctionPushPop::~FunctionPushPop()
|
||||||
|
{
|
||||||
|
this->Makefile->PopFunctionScope(this->ReportError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
|
||||||
|
const cmPolicies::PolicyMap& pm)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushMacroScope(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefile::MacroPushPop::~MacroPushPop()
|
||||||
|
{
|
||||||
|
this->Makefile->PopMacroScope(this->ReportError);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmListFileContext& lfc,
|
||||||
|
cmExecutionStatus& status): Makefile(mf)
|
||||||
|
{
|
||||||
|
cmMakefile::CallStackEntry entry = {&lfc, &status};
|
||||||
|
this->Makefile->CallStack.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefileCall::~cmMakefileCall()
|
||||||
|
{
|
||||||
|
this->Makefile->CallStack.pop_back();
|
||||||
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "cmExecutionStatus.h"
|
#include "cmExecutionStatus.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
#include "cmPolicies.h"
|
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
@ -373,11 +372,6 @@ public:
|
|||||||
};
|
};
|
||||||
friend class PolicyPushPop;
|
friend class PolicyPushPop;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Policies Instance
|
|
||||||
*/
|
|
||||||
cmPolicies *GetPolicies() const;
|
|
||||||
|
|
||||||
mutable std::set<cmListFileContext> CMP0054ReportedIds;
|
mutable std::set<cmListFileContext> CMP0054ReportedIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -517,7 +511,7 @@ public:
|
|||||||
* cacheonly is specified and is greater than 0, then only cache
|
* cacheonly is specified and is greater than 0, then only cache
|
||||||
* variables will be listed.
|
* variables will be listed.
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> GetDefinitions(int cacheonly=0) const;
|
std::vector<std::string> GetDefinitions() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a boolean variable to see if it is true or false.
|
* Test a boolean variable to see if it is true or false.
|
||||||
@ -731,7 +725,7 @@ public:
|
|||||||
cmPropertyMap &GetProperties() { return this->Properties; }
|
cmPropertyMap &GetProperties() { return this->Properties; }
|
||||||
|
|
||||||
///! Initialize a makefile from its parent
|
///! Initialize a makefile from its parent
|
||||||
void InitializeFromParent();
|
void InitializeFromParent(cmMakefile* parent);
|
||||||
|
|
||||||
void AddInstallGenerator(cmInstallGenerator* g)
|
void AddInstallGenerator(cmInstallGenerator* g)
|
||||||
{ if(g) this->InstallGenerators.push_back(g); }
|
{ if(g) this->InstallGenerators.push_back(g); }
|
||||||
@ -743,7 +737,36 @@ public:
|
|||||||
const std::vector<cmTestGenerator*>& GetTestGenerators() const
|
const std::vector<cmTestGenerator*>& GetTestGenerators() const
|
||||||
{ return this->TestGenerators; }
|
{ return this->TestGenerators; }
|
||||||
|
|
||||||
// push and pop variable scopes
|
class FunctionPushPop
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FunctionPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm);
|
||||||
|
~FunctionPushPop();
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MacroPushPop
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MacroPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm);
|
||||||
|
~MacroPushPop();
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
|
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
|
||||||
|
void PopFunctionScope(bool reportError);
|
||||||
|
void PushMacroScope(cmPolicies::PolicyMap const& pm);
|
||||||
|
void PopMacroScope(bool reportError);
|
||||||
void PushScope();
|
void PushScope();
|
||||||
void PopScope();
|
void PopScope();
|
||||||
void RaiseScope(const std::string& var, const char *value);
|
void RaiseScope(const std::string& var, const char *value);
|
||||||
@ -1054,15 +1077,8 @@ class cmMakefileCall
|
|||||||
public:
|
public:
|
||||||
cmMakefileCall(cmMakefile* mf,
|
cmMakefileCall(cmMakefile* mf,
|
||||||
cmListFileContext const& lfc,
|
cmListFileContext const& lfc,
|
||||||
cmExecutionStatus& status): Makefile(mf)
|
cmExecutionStatus& status);
|
||||||
{
|
~cmMakefileCall();
|
||||||
cmMakefile::CallStackEntry entry = {&lfc, &status};
|
|
||||||
this->Makefile->CallStack.push_back(entry);
|
|
||||||
}
|
|
||||||
~cmMakefileCall()
|
|
||||||
{
|
|
||||||
this->Makefile->CallStack.pop_back();
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
};
|
};
|
||||||
|
@ -222,9 +222,6 @@ class cmake
|
|||||||
///! this is called by generators to update the progress
|
///! this is called by generators to update the progress
|
||||||
void UpdateProgress(const char *msg, float prog);
|
void UpdateProgress(const char *msg, float prog);
|
||||||
|
|
||||||
///! get the cmake policies instance
|
|
||||||
cmPolicies *GetPolicies() {return this->Policies;}
|
|
||||||
|
|
||||||
///! Get the variable watch object
|
///! Get the variable watch object
|
||||||
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
|
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user