From 6d27a3dbfbfb8852d8b8ff5c6fc7432eebc604e5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 10 Oct 2015 18:27:10 +0200 Subject: Genex: Port implementation to cmGeneratorTarget. --- Source/cmGeneratorExpressionContext.cxx | 4 +- Source/cmGeneratorExpressionContext.h | 8 ++-- Source/cmGeneratorExpressionNode.cxx | 82 +++++++++++++++------------------ 3 files changed, 45 insertions(+), 49 deletions(-) diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx index 4daf4e9..5c9462f 100644 --- a/Source/cmGeneratorExpressionContext.cxx +++ b/Source/cmGeneratorExpressionContext.cxx @@ -24,8 +24,8 @@ cmGeneratorExpressionContext::cmGeneratorExpressionContext( LG(lg), Config(config), Language(language), - HeadTarget(headTarget ? headTarget->Target : 0), - CurrentTarget(currentTarget ? currentTarget->Target : 0), + HeadTarget(headTarget), + CurrentTarget(currentTarget), Quiet(quiet), HadError(false), HadContextSensitiveCondition(false), diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h index bbf0fcf..934e2e7 100644 --- a/Source/cmGeneratorExpressionContext.h +++ b/Source/cmGeneratorExpressionContext.h @@ -43,9 +43,11 @@ struct cmGeneratorExpressionContext cmLocalGenerator *LG; std::string Config; std::string Language; - cmTarget const* HeadTarget; // The target whose property is being evaluated. - cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears - // directly or indirectly in the property. + // The target whose property is being evaluated. + cmGeneratorTarget const* HeadTarget; + // The dependent of HeadTarget which appears + // directly or indirectly in the property. + cmGeneratorTarget const* CurrentTarget; bool Quiet; bool HadError; bool HadContextSensitiveCondition; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index fe83b08..dcb1c5c 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -705,7 +705,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode const char* loc = 0; const char* imp = 0; std::string suffix; - if (context->CurrentTarget->GetMappedConfig(context->Config, + if (context->CurrentTarget->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) @@ -893,7 +893,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$"); - cmTarget const* target = context->HeadTarget; + cmGeneratorTarget const* target = context->HeadTarget; std::string propertyName = *parameters.begin(); if (parameters.size() == 1) @@ -945,15 +945,15 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { if(context->LG->GetMakefile()->IsAlias(targetName)) { - if(cmTarget* tgt = - context->LG->GetMakefile()->FindTargetToUse(targetName)) + if(cmGeneratorTarget* tgt = + context->LG->FindGeneratorTargetToUse(targetName)) { return tgt->GetName(); } } return ""; } - target = context->LG->GetMakefile()->FindTargetToUse(targetName); + target = context->LG->FindGeneratorTargetToUse(targetName); if (!target) { @@ -964,7 +964,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } - context->AllTargets.insert(target); + context->AllTargets.insert(target->Target); } if (target == context->HeadTarget) @@ -977,7 +977,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if (propertyName == "SOURCES") { - context->SourceSensitiveTargets.insert(target); + context->SourceSensitiveTargets.insert(target->Target); } if (propertyName.empty()) @@ -997,12 +997,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); - cmGeneratorTarget* gtgt = - context->LG->GetGlobalGenerator()->GetGeneratorTarget(target); - if (propertyName == "LINKER_LANGUAGE") { - if (target->LinkLanguagePropagatesToDependents() && + if (target->Target->LinkLanguagePropagatesToDependents() && dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries() || dagCheckerParent->EvaluatingSources())) { @@ -1011,7 +1008,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return gtgt->GetLinkerLanguage(context->Config); + return target->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1110,20 +1107,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } #undef POPULATE_INTERFACE_PROPERTY_NAME - cmTarget const* headTarget = context->HeadTarget && isInterfaceProperty + cmGeneratorTarget const* headTarget = + context->HeadTarget && isInterfaceProperty ? context->HeadTarget : target; if(isInterfaceProperty) { - cmGeneratorTarget* gHeadTarget = - context->LG->GetGlobalGenerator() - ->GetGeneratorTarget(headTarget); if(cmLinkInterfaceLibraries const* iface = - gtgt->GetLinkInterfaceLibraries(context->Config, gHeadTarget, true)) + target->GetLinkInterfaceLibraries(context->Config, headTarget, true)) { linkedTargetsContent = - getLinkedTargetsContent(iface->Libraries, gtgt, - gHeadTarget, + getLinkedTargetsContent(iface->Libraries, target, + headTarget, context, &dagChecker, interfacePropertyName); } @@ -1131,11 +1126,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode else if(!interfacePropertyName.empty()) { if(cmLinkImplementationLibraries const* impl = - gtgt->GetLinkImplementationLibraries(context->Config)) + target->GetLinkImplementationLibraries(context->Config)) { linkedTargetsContent = - getLinkedTargetsContent(impl->Libraries, gtgt, - gtgt, + getLinkedTargetsContent(impl->Libraries, target, + target, context, &dagChecker, interfacePropertyName); } @@ -1148,40 +1143,40 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + if (target->IsLinkInterfaceDependentBoolProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; - return gtgt->GetLinkInterfaceDependentBoolProperty( + return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + if (target->IsLinkInterfaceDependentStringProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentStringProperty( + target->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMinProperty( + target->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMaxProperty( + target->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1193,22 +1188,22 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMinProperty( + target->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; } - if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = - gtgt->GetLinkInterfaceDependentNumberMaxProperty( + target->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1216,11 +1211,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if(!interfacePropertyName.empty()) { - cmGeneratorTarget* gHeadTarget = - context->LG->GetGlobalGenerator()->GetGeneratorTarget(headTarget); std::string result = this->EvaluateDependentExpression(prop, context->LG, context, - gHeadTarget, gtgt, &dagChecker); + headTarget, target, &dagChecker); if (!linkedTargetsContent.empty()) { result += (result.empty() ? "" : ";") + linkedTargetsContent; @@ -1341,7 +1334,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - cmTarget const* target = context->HeadTarget; + cmGeneratorTarget const* target = context->HeadTarget; if (!target) { reportError(context, content->GetOriginalExpression(), @@ -1361,7 +1354,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode { std::string error; std::string lang; - if (!context->LG->GetMakefile()->CompileFeatureKnown(context->HeadTarget, + if (!context->LG->GetMakefile()->CompileFeatureKnown( + context->HeadTarget->Target, *it, lang, &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. continue; } - if (!context->LG->GetMakefile()->HaveStandardAvailable(target, + if (!context->LG->GetMakefile()->HaveStandardAvailable(target->Target, lit->first, *it)) { if (evalLL) @@ -1418,7 +1412,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode l = standardDefault; } assert(l); - context->MaxLanguageStandard[target][lit->first] = l; + context->MaxLanguageStandard[target->Target][lit->first] = l; } else { @@ -1442,13 +1436,13 @@ static const char* targetPolicyWhitelist[] = { #undef TARGET_POLICY_STRING }; -cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt, +cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt, const char *policy) { #define RETURN_POLICY(POLICY) \ if (strcmp(policy, #POLICY) == 0) \ { \ - return tgt->GetPolicyStatus ## POLICY (); \ + return tgt->Target->GetPolicyStatus ## POLICY (); \ } \ CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY) @@ -1503,7 +1497,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode const char *policy = targetPolicyWhitelist[i]; if (parameters.front() == policy) { - cmMakefile *mf = context->HeadTarget->GetMakefile(); + cmMakefile *mf = context->HeadTarget->Target->GetMakefile(); switch(statusForTarget(context->HeadTarget, policy)) { case cmPolicies::WARN: -- cgit v0.12 From c4ae157865291d73113f81d4c9a9c2dd86598efc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 10 Oct 2015 18:41:51 +0200 Subject: Genex: Port some access API to cmGeneratorTarget. --- Source/cmExportTryCompileFileGenerator.cxx | 11 ++++++----- Source/cmGeneratorExpression.cxx | 8 ++++---- Source/cmGeneratorExpression.h | 19 +++++++++---------- Source/cmGeneratorExpressionContext.h | 9 ++++----- Source/cmGeneratorExpressionNode.cxx | 10 +++++----- Source/cmGeneratorTarget.cxx | 12 ++++++------ Source/cmGlobalGenerator.cxx | 4 ++-- Source/cmGlobalGenerator.h | 6 +++--- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index f8dbe31..fe5717a 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -84,13 +84,14 @@ std::string cmExportTryCompileFileGenerator::FindTargets( false, &gDummyHead, gtgt, &dagChecker); - const std::set &allTargets = cge->GetAllTargetsSeen(); - for(std::set::const_iterator li = allTargets.begin(); - li != allTargets.end(); ++li) + const std::set &allTargets = + cge->GetAllTargetsSeen(); + for(std::set::const_iterator li = + allTargets.begin(); li != allTargets.end(); ++li) { - if(emitted.insert(*li).second) + if(emitted.insert((*li)->Target).second) { - this->Exports.push_back(*li); + this->Exports.push_back((*li)->Target); } } return result; diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index d9f67f2..6796a01 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -11,10 +11,9 @@ ============================================================================*/ #include "cmGeneratorExpression.h" -#include "cmMakefile.h" -#include "cmTarget.h" #include "assert.h" #include "cmAlgorithms.h" +#include "cmSystemTools.h" #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" @@ -463,10 +462,11 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input) //---------------------------------------------------------------------------- void -cmCompiledGeneratorExpression::GetMaxLanguageStandard(cmTarget const* tgt, +cmCompiledGeneratorExpression::GetMaxLanguageStandard( + const cmGeneratorTarget* tgt, std::map& mapping) { - typedef std::map > MapType; MapType::const_iterator it = this->MaxLanguageStandard.find(tgt); if (it != this->MaxLanguageStandard.end()) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index d64d6ba..efd381b 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -19,7 +19,6 @@ #include #include -class cmTarget; class cmGeneratorTarget; class cmLocalGenerator; class cmListFileBacktrace; @@ -92,13 +91,13 @@ public: std::string const& language = std::string()) const; /** Get set of targets found during evaluations. */ - std::set const& GetTargets() const + std::set const& GetTargets() const { return this->DependTargets; } std::set const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } - std::set const& GetAllTargetsSeen() const + std::set const& GetAllTargetsSeen() const { return this->AllTargetsSeen; } ~cmCompiledGeneratorExpression(); @@ -120,7 +119,7 @@ public: { return this->HadHeadSensitiveCondition; } - std::set GetSourceSensitiveTargets() const + std::set GetSourceSensitiveTargets() const { return this->SourceSensitiveTargets; } @@ -130,7 +129,7 @@ public: this->EvaluateForBuildsystem = eval; } - void GetMaxLanguageStandard(cmTarget const* tgt, + void GetMaxLanguageStandard(cmGeneratorTarget const* tgt, std::map& mapping); private: @@ -150,15 +149,15 @@ private: const std::string Input; bool NeedsEvaluation; - mutable std::set DependTargets; - mutable std::set AllTargetsSeen; + mutable std::set DependTargets; + mutable std::set AllTargetsSeen; mutable std::set SeenTargetProperties; - mutable std::map > - MaxLanguageStandard; + mutable std::map > MaxLanguageStandard; mutable std::string Output; mutable bool HadContextSensitiveCondition; mutable bool HadHeadSensitiveCondition; - mutable std::set SourceSensitiveTargets; + mutable std::set SourceSensitiveTargets; bool EvaluateForBuildsystem; }; diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h index 934e2e7..e802138 100644 --- a/Source/cmGeneratorExpressionContext.h +++ b/Source/cmGeneratorExpressionContext.h @@ -18,7 +18,6 @@ #include #include -class cmTarget; class cmGeneratorTarget; class cmLocalGenerator; @@ -34,11 +33,11 @@ struct cmGeneratorExpressionContext cmListFileBacktrace Backtrace; - std::set DependTargets; - std::set AllTargets; + std::set DependTargets; + std::set AllTargets; std::set SeenTargetProperties; - std::set SourceSensitiveTargets; - std::map > + std::set SourceSensitiveTargets; + std::map > MaxLanguageStandard; cmLocalGenerator *LG; std::string Config; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index dcb1c5c..8521a15 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -964,7 +964,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } - context->AllTargets.insert(target->Target); + context->AllTargets.insert(target); } if (target == context->HeadTarget) @@ -977,7 +977,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if (propertyName == "SOURCES") { - context->SourceSensitiveTargets.insert(target->Target); + context->SourceSensitiveTargets.insert(target); } if (propertyName.empty()) @@ -1412,7 +1412,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode l = standardDefault; } assert(l); - context->MaxLanguageStandard[target->Target][lit->first] = l; + context->MaxLanguageStandard[target][lit->first] = l; } else { @@ -1756,8 +1756,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "be used while evaluating link libraries"); return std::string(); } - context->DependTargets.insert(target->Target); - context->AllTargets.insert(target->Target); + context->DependTargets.insert(target); + context->AllTargets.insert(target); std::string result = TargetFilesystemArtifactResultCreator::Create( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6bebc2b..ca91f53 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2173,9 +2173,9 @@ cmTargetTraceDependencies si != sources.end(); ++si) { cmSourceFile* sf = *si; - const std::set tgts = + const std::set tgts = this->GlobalGenerator->GetFilenameTargetDepends(sf); - if (tgts.find(this->Target) != tgts.end()) + if (tgts.find(this->GeneratorTarget) != tgts.end()) { std::ostringstream e; e << "Evaluation output file\n \"" << sf->GetFullPath() @@ -2353,7 +2353,7 @@ cmTargetTraceDependencies cmGeneratorExpression ge(cc.GetBacktrace()); // Add target-level dependencies referenced by generator expressions. - std::set targets; + std::set targets; for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); cit != cc.GetCommandLines().end(); ++cit) @@ -2379,12 +2379,12 @@ cmTargetTraceDependencies const cmsys::auto_ptr cge = ge.Parse(*cli); cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true); - std::set geTargets = cge->GetTargets(); + std::set geTargets = cge->GetTargets(); targets.insert(geTargets.begin(), geTargets.end()); } } - for(std::set::iterator ti = targets.begin(); + for(std::set::iterator ti = targets.begin(); ti != targets.end(); ++ti) { this->Target->AddUtility((*ti)->GetName()); @@ -5412,7 +5412,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( this->LinkImplicitNullProperties.insert(*it); } } - cge->GetMaxLanguageStandard(this->Target, + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e8be2d6..3afcb42 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3029,13 +3029,13 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) { //---------------------------------------------------------------------------- void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf, - std::set tgts) + std::set tgts) { this->FilenameTargetDepends[sf] = tgts; } //---------------------------------------------------------------------------- -std::set const& +std::set const& cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { return this->FilenameTargetDepends[sf]; } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fc81708..6887409 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -354,8 +354,8 @@ public: void CreateEvaluationSourceFiles(std::string const& config) const; void SetFilenameTargetDepends(cmSourceFile* sf, - std::set tgts); - std::set const& + std::set tgts); + const std::set& GetFilenameTargetDepends(cmSourceFile* sf) const; #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -508,7 +508,7 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; - mutable std::map > + mutable std::map > FilenameTargetDepends; #if defined(CMAKE_BUILD_WITH_CMAKE) -- cgit v0.12