Genex: Port implementation to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-10 18:27:10 +02:00
parent 088fcbf733
commit 6d27a3dbfb
3 changed files with 45 additions and 49 deletions

View File

@ -24,8 +24,8 @@ cmGeneratorExpressionContext::cmGeneratorExpressionContext(
LG(lg), LG(lg),
Config(config), Config(config),
Language(language), Language(language),
HeadTarget(headTarget ? headTarget->Target : 0), HeadTarget(headTarget),
CurrentTarget(currentTarget ? currentTarget->Target : 0), CurrentTarget(currentTarget),
Quiet(quiet), Quiet(quiet),
HadError(false), HadError(false),
HadContextSensitiveCondition(false), HadContextSensitiveCondition(false),

View File

@ -43,9 +43,11 @@ struct cmGeneratorExpressionContext
cmLocalGenerator *LG; cmLocalGenerator *LG;
std::string Config; std::string Config;
std::string Language; std::string Language;
cmTarget const* HeadTarget; // The target whose property is being evaluated. // The target whose property is being evaluated.
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears cmGeneratorTarget const* HeadTarget;
// directly or indirectly in the property. // The dependent of HeadTarget which appears
// directly or indirectly in the property.
cmGeneratorTarget const* CurrentTarget;
bool Quiet; bool Quiet;
bool HadError; bool HadError;
bool HadContextSensitiveCondition; bool HadContextSensitiveCondition;

View File

@ -705,7 +705,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
const char* loc = 0; const char* loc = 0;
const char* imp = 0; const char* imp = 0;
std::string suffix; std::string suffix;
if (context->CurrentTarget->GetMappedConfig(context->Config, if (context->CurrentTarget->Target->GetMappedConfig(context->Config,
&loc, &loc,
&imp, &imp,
suffix)) suffix))
@ -893,7 +893,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$"); static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
cmTarget const* target = context->HeadTarget; cmGeneratorTarget const* target = context->HeadTarget;
std::string propertyName = *parameters.begin(); std::string propertyName = *parameters.begin();
if (parameters.size() == 1) if (parameters.size() == 1)
@ -945,15 +945,15 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{ {
if(context->LG->GetMakefile()->IsAlias(targetName)) if(context->LG->GetMakefile()->IsAlias(targetName))
{ {
if(cmTarget* tgt = if(cmGeneratorTarget* tgt =
context->LG->GetMakefile()->FindTargetToUse(targetName)) context->LG->FindGeneratorTargetToUse(targetName))
{ {
return tgt->GetName(); return tgt->GetName();
} }
} }
return ""; return "";
} }
target = context->LG->GetMakefile()->FindTargetToUse(targetName); target = context->LG->FindGeneratorTargetToUse(targetName);
if (!target) if (!target)
{ {
@ -964,7 +964,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
reportError(context, content->GetOriginalExpression(), e.str()); reportError(context, content->GetOriginalExpression(), e.str());
return std::string(); return std::string();
} }
context->AllTargets.insert(target); context->AllTargets.insert(target->Target);
} }
if (target == context->HeadTarget) if (target == context->HeadTarget)
@ -977,7 +977,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
if (propertyName == "SOURCES") if (propertyName == "SOURCES")
{ {
context->SourceSensitiveTargets.insert(target); context->SourceSensitiveTargets.insert(target->Target);
} }
if (propertyName.empty()) if (propertyName.empty())
@ -997,12 +997,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
assert(target); assert(target);
cmGeneratorTarget* gtgt =
context->LG->GetGlobalGenerator()->GetGeneratorTarget(target);
if (propertyName == "LINKER_LANGUAGE") if (propertyName == "LINKER_LANGUAGE")
{ {
if (target->LinkLanguagePropagatesToDependents() && if (target->Target->LinkLanguagePropagatesToDependents() &&
dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries() dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
|| dagCheckerParent->EvaluatingSources())) || dagCheckerParent->EvaluatingSources()))
{ {
@ -1011,7 +1008,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"link libraries for a static library"); "link libraries for a static library");
return std::string(); return std::string();
} }
return gtgt->GetLinkerLanguage(context->Config); return target->GetLinkerLanguage(context->Config);
} }
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
@ -1110,20 +1107,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
} }
#undef POPULATE_INTERFACE_PROPERTY_NAME #undef POPULATE_INTERFACE_PROPERTY_NAME
cmTarget const* headTarget = context->HeadTarget && isInterfaceProperty cmGeneratorTarget const* headTarget =
context->HeadTarget && isInterfaceProperty
? context->HeadTarget : target; ? context->HeadTarget : target;
if(isInterfaceProperty) if(isInterfaceProperty)
{ {
cmGeneratorTarget* gHeadTarget =
context->LG->GetGlobalGenerator()
->GetGeneratorTarget(headTarget);
if(cmLinkInterfaceLibraries const* iface = if(cmLinkInterfaceLibraries const* iface =
gtgt->GetLinkInterfaceLibraries(context->Config, gHeadTarget, true)) target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
{ {
linkedTargetsContent = linkedTargetsContent =
getLinkedTargetsContent(iface->Libraries, gtgt, getLinkedTargetsContent(iface->Libraries, target,
gHeadTarget, headTarget,
context, &dagChecker, context, &dagChecker,
interfacePropertyName); interfacePropertyName);
} }
@ -1131,11 +1126,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
else if(!interfacePropertyName.empty()) else if(!interfacePropertyName.empty())
{ {
if(cmLinkImplementationLibraries const* impl = if(cmLinkImplementationLibraries const* impl =
gtgt->GetLinkImplementationLibraries(context->Config)) target->GetLinkImplementationLibraries(context->Config))
{ {
linkedTargetsContent = linkedTargetsContent =
getLinkedTargetsContent(impl->Libraries, gtgt, getLinkedTargetsContent(impl->Libraries, target,
gtgt, target,
context, &dagChecker, context, &dagChecker,
interfacePropertyName); interfacePropertyName);
} }
@ -1148,40 +1143,40 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{ {
return linkedTargetsContent; return linkedTargetsContent;
} }
if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
return gtgt->GetLinkInterfaceDependentBoolProperty( return target->GetLinkInterfaceDependentBoolProperty(
propertyName, propertyName,
context->Config) ? "1" : "0"; context->Config) ? "1" : "0";
} }
if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, if (target->IsLinkInterfaceDependentStringProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
const char *propContent = const char *propContent =
gtgt->GetLinkInterfaceDependentStringProperty( target->GetLinkInterfaceDependentStringProperty(
propertyName, propertyName,
context->Config); context->Config);
return propContent ? propContent : ""; return propContent ? propContent : "";
} }
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
const char *propContent = const char *propContent =
gtgt->GetLinkInterfaceDependentNumberMinProperty( target->GetLinkInterfaceDependentNumberMinProperty(
propertyName, propertyName,
context->Config); context->Config);
return propContent ? propContent : ""; return propContent ? propContent : "";
} }
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
const char *propContent = const char *propContent =
gtgt->GetLinkInterfaceDependentNumberMaxProperty( target->GetLinkInterfaceDependentNumberMaxProperty(
propertyName, propertyName,
context->Config); context->Config);
return propContent ? propContent : ""; return propContent ? propContent : "";
@ -1193,22 +1188,22 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (!target->IsImported() if (!target->IsImported()
&& dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
{ {
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
const char *propContent = const char *propContent =
gtgt->GetLinkInterfaceDependentNumberMinProperty( target->GetLinkInterfaceDependentNumberMinProperty(
propertyName, propertyName,
context->Config); context->Config);
return propContent ? propContent : ""; return propContent ? propContent : "";
} }
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config)) context->Config))
{ {
context->HadContextSensitiveCondition = true; context->HadContextSensitiveCondition = true;
const char *propContent = const char *propContent =
gtgt->GetLinkInterfaceDependentNumberMaxProperty( target->GetLinkInterfaceDependentNumberMaxProperty(
propertyName, propertyName,
context->Config); context->Config);
return propContent ? propContent : ""; return propContent ? propContent : "";
@ -1216,11 +1211,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
if(!interfacePropertyName.empty()) if(!interfacePropertyName.empty())
{ {
cmGeneratorTarget* gHeadTarget =
context->LG->GetGlobalGenerator()->GetGeneratorTarget(headTarget);
std::string result = this->EvaluateDependentExpression(prop, std::string result = this->EvaluateDependentExpression(prop,
context->LG, context, context->LG, context,
gHeadTarget, gtgt, &dagChecker); headTarget, target, &dagChecker);
if (!linkedTargetsContent.empty()) if (!linkedTargetsContent.empty())
{ {
result += (result.empty() ? "" : ";") + linkedTargetsContent; result += (result.empty() ? "" : ";") + linkedTargetsContent;
@ -1341,7 +1334,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *content, const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *dagChecker) const cmGeneratorExpressionDAGChecker *dagChecker) const
{ {
cmTarget const* target = context->HeadTarget; cmGeneratorTarget const* target = context->HeadTarget;
if (!target) if (!target)
{ {
reportError(context, content->GetOriginalExpression(), reportError(context, content->GetOriginalExpression(),
@ -1361,7 +1354,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{ {
std::string error; std::string error;
std::string lang; std::string lang;
if (!context->LG->GetMakefile()->CompileFeatureKnown(context->HeadTarget, if (!context->LG->GetMakefile()->CompileFeatureKnown(
context->HeadTarget->Target,
*it, lang, &error)) *it, lang, &error))
{ {
reportError(context, content->GetOriginalExpression(), error); reportError(context, content->GetOriginalExpression(), error);
@ -1407,7 +1401,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
// All features known for the language are always available. // All features known for the language are always available.
continue; continue;
} }
if (!context->LG->GetMakefile()->HaveStandardAvailable(target, if (!context->LG->GetMakefile()->HaveStandardAvailable(target->Target,
lit->first, *it)) lit->first, *it))
{ {
if (evalLL) if (evalLL)
@ -1418,7 +1412,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
l = standardDefault; l = standardDefault;
} }
assert(l); assert(l);
context->MaxLanguageStandard[target][lit->first] = l; context->MaxLanguageStandard[target->Target][lit->first] = l;
} }
else else
{ {
@ -1442,13 +1436,13 @@ static const char* targetPolicyWhitelist[] = {
#undef TARGET_POLICY_STRING #undef TARGET_POLICY_STRING
}; };
cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt, cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
const char *policy) const char *policy)
{ {
#define RETURN_POLICY(POLICY) \ #define RETURN_POLICY(POLICY) \
if (strcmp(policy, #POLICY) == 0) \ if (strcmp(policy, #POLICY) == 0) \
{ \ { \
return tgt->GetPolicyStatus ## POLICY (); \ return tgt->Target->GetPolicyStatus ## POLICY (); \
} \ } \
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY) CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
@ -1503,7 +1497,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
const char *policy = targetPolicyWhitelist[i]; const char *policy = targetPolicyWhitelist[i];
if (parameters.front() == policy) if (parameters.front() == policy)
{ {
cmMakefile *mf = context->HeadTarget->GetMakefile(); cmMakefile *mf = context->HeadTarget->Target->GetMakefile();
switch(statusForTarget(context->HeadTarget, policy)) switch(statusForTarget(context->HeadTarget, policy))
{ {
case cmPolicies::WARN: case cmPolicies::WARN: