ENH: Create notion of a 'weak' policy stack entry
A 'weak' poilcy stack entry responds normally to queries. However, setting a policy in a weak entry will recursively set the policy in the next entry too. This also gives the internal interface to create a weak entry the option to provide an initial PolicyMap for it.
This commit is contained in:
parent
3a4f76949a
commit
26bf8b2cda
|
@ -3666,8 +3666,14 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the setting.
|
// Update the policy stack from the top to the top-most strong entry.
|
||||||
this->PolicyStack.back()[id] = status;
|
bool previous_was_weak = true;
|
||||||
|
for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
|
||||||
|
previous_was_weak && psi != this->PolicyStack.rend(); ++psi)
|
||||||
|
{
|
||||||
|
(*psi)[id] = status;
|
||||||
|
previous_was_weak = psi->Weak;
|
||||||
|
}
|
||||||
|
|
||||||
// Special hook for presenting compatibility variable as soon as
|
// Special hook for presenting compatibility variable as soon as
|
||||||
// the user requests it.
|
// the user requests it.
|
||||||
|
@ -3692,10 +3698,11 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m):
|
cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
|
||||||
|
cmPolicies::PolicyMap const& pm):
|
||||||
Makefile(m), ReportError(true)
|
Makefile(m), ReportError(true)
|
||||||
{
|
{
|
||||||
this->Makefile->PushPolicy();
|
this->Makefile->PushPolicy(weak, pm);
|
||||||
this->Makefile->PushPolicyBarrier();
|
this->Makefile->PushPolicyBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3707,10 +3714,10 @@ cmMakefile::PolicyPushPop::~PolicyPushPop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefile::PushPolicy()
|
void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
|
||||||
{
|
{
|
||||||
// Allocate a new stack entry.
|
// Allocate a new stack entry.
|
||||||
this->PolicyStack.push_back(PolicyStackEntry());
|
this->PolicyStack.push_back(PolicyStackEntry(pm, weak));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -349,7 +349,9 @@ public:
|
||||||
class PolicyPushPop
|
class PolicyPushPop
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolicyPushPop(cmMakefile* m);
|
PolicyPushPop(cmMakefile* m,
|
||||||
|
bool weak = false,
|
||||||
|
cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
|
||||||
~PolicyPushPop();
|
~PolicyPushPop();
|
||||||
void Quiet() { this->ReportError = false; }
|
void Quiet() { this->ReportError = false; }
|
||||||
private:
|
private:
|
||||||
|
@ -943,7 +945,8 @@ private:
|
||||||
std::map<cmStdString, cmTarget*> ImportedTargets;
|
std::map<cmStdString, cmTarget*> ImportedTargets;
|
||||||
|
|
||||||
// Internal policy stack management.
|
// Internal policy stack management.
|
||||||
void PushPolicy();
|
void PushPolicy(bool weak = false,
|
||||||
|
cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
|
||||||
void PopPolicy();
|
void PopPolicy();
|
||||||
void PushPolicyBarrier();
|
void PushPolicyBarrier();
|
||||||
void PopPolicyBarrier(bool reportError = true);
|
void PopPolicyBarrier(bool reportError = true);
|
||||||
|
@ -955,9 +958,10 @@ private:
|
||||||
struct PolicyStackEntry: public cmPolicies::PolicyMap
|
struct PolicyStackEntry: public cmPolicies::PolicyMap
|
||||||
{
|
{
|
||||||
typedef cmPolicies::PolicyMap derived;
|
typedef cmPolicies::PolicyMap derived;
|
||||||
PolicyStackEntry(): derived() {}
|
PolicyStackEntry(bool w = false): derived(), Weak(w) {}
|
||||||
PolicyStackEntry(derived const& d): derived(d) {}
|
PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
|
||||||
PolicyStackEntry(PolicyStackEntry const& r): derived(r) {}
|
PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
|
||||||
|
bool Weak;
|
||||||
};
|
};
|
||||||
typedef std::vector<PolicyStackEntry> PolicyStackType;
|
typedef std::vector<PolicyStackEntry> PolicyStackType;
|
||||||
PolicyStackType PolicyStack;
|
PolicyStackType PolicyStack;
|
||||||
|
|
Loading…
Reference in New Issue