Genex: Track whether an expression depends on the 'head' target

This commit is contained in:
Brad King 2014-07-21 13:02:22 -04:00
parent 46099b82ed
commit 807e4ffeef
4 changed files with 23 additions and 0 deletions

View File

@ -97,6 +97,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.Quiet = quiet; context.Quiet = quiet;
context.HadError = false; context.HadError = false;
context.HadContextSensitiveCondition = false; context.HadContextSensitiveCondition = false;
context.HadHeadSensitiveCondition = false;
context.HeadTarget = headTarget; context.HeadTarget = headTarget;
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem; context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
context.CurrentTarget = currentTarget ? currentTarget : headTarget; context.CurrentTarget = currentTarget ? currentTarget : headTarget;
@ -124,6 +125,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
if (!context.HadError) if (!context.HadError)
{ {
this->HadContextSensitiveCondition = context.HadContextSensitiveCondition; this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
this->HadHeadSensitiveCondition = context.HadHeadSensitiveCondition;
} }
this->DependTargets = context.DependTargets; this->DependTargets = context.DependTargets;
@ -137,6 +139,7 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
const std::string& input) const std::string& input)
: Backtrace(backtrace), Input(input), : Backtrace(backtrace), Input(input),
HadContextSensitiveCondition(false), HadContextSensitiveCondition(false),
HadHeadSensitiveCondition(false),
EvaluateForBuildsystem(false) EvaluateForBuildsystem(false)
{ {
cmGeneratorExpressionLexer l; cmGeneratorExpressionLexer l;

View File

@ -111,6 +111,10 @@ public:
{ {
return this->HadContextSensitiveCondition; return this->HadContextSensitiveCondition;
} }
bool GetHadHeadSensitiveCondition() const
{
return this->HadHeadSensitiveCondition;
}
void SetEvaluateForBuildsystem(bool eval) void SetEvaluateForBuildsystem(bool eval)
{ {
@ -141,6 +145,7 @@ private:
MaxLanguageStandard; MaxLanguageStandard;
mutable std::string Output; mutable std::string Output;
mutable bool HadContextSensitiveCondition; mutable bool HadContextSensitiveCondition;
mutable bool HadHeadSensitiveCondition;
bool EvaluateForBuildsystem; bool EvaluateForBuildsystem;
}; };

View File

@ -840,6 +840,10 @@ getLinkedTargetsContent(
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
} }
if (cge->GetHadHeadSensitiveCondition())
{
context->HadHeadSensitiveCondition = true;
}
} }
linkedTargetsContent = linkedTargetsContent =
cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent); cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
@ -871,6 +875,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmTarget const* target = context->HeadTarget; cmTarget const* target = context->HeadTarget;
std::string propertyName = *parameters.begin(); std::string propertyName = *parameters.begin();
if (parameters.size() == 1)
{
context->HadHeadSensitiveCondition = true;
}
if (!target && parameters.size() == 1) if (!target && parameters.size() == 1)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -1190,6 +1198,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
} }
if (cge->GetHadHeadSensitiveCondition())
{
context->HadHeadSensitiveCondition = true;
}
if (!linkedTargetsContent.empty()) if (!linkedTargetsContent.empty())
{ {
result += (result.empty() ? "" : ";") + linkedTargetsContent; result += (result.empty() ? "" : ";") + linkedTargetsContent;
@ -1313,6 +1325,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
"not be used with add_custom_command or add_custom_target."); "not be used with add_custom_command or add_custom_target.");
return std::string(); return std::string();
} }
context->HadHeadSensitiveCondition = true;
typedef std::map<std::string, std::vector<std::string> > LangMap; typedef std::map<std::string, std::vector<std::string> > LangMap;
static LangMap availableFeatures; static LangMap availableFeatures;
@ -1446,6 +1459,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
} }
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
context->HadHeadSensitiveCondition = true;
for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i) for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i)
{ {

View File

@ -41,6 +41,7 @@ struct cmGeneratorExpressionContext
bool Quiet; bool Quiet;
bool HadError; bool HadError;
bool HadContextSensitiveCondition; bool HadContextSensitiveCondition;
bool HadHeadSensitiveCondition;
bool EvaluateForBuildsystem; bool EvaluateForBuildsystem;
}; };