diff options
author | Brad King <brad.king@kitware.com> | 2018-09-06 16:49:34 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-07 09:23:43 -0400 |
commit | 1b57f49586afc9e8663d5e146732b1cd0597e7ef (patch) | |
tree | 3754c4403d6b5cc3f5e6b2543f6e1f394dc92ea7 | |
parent | bea390e9bd68e1aa7d86b6aef7384f502c39068c (diff) | |
download | cmake-1b57f49586afc9e8663d5e146732b1cd0597e7ef.tar.gz |
genex: Simplify cmGeneratorExpressionInterpreter
All callers were constructing with a non-empty target name using the
target whose pointer was passed anyway. Drop this argument. Simplify
logic accordingly. Re-order constructor arguments to match the
cmCompiledGeneratorExpression::Evaluate arguments.
Also remove unnecessary getters.
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmGeneratorExpression.cxx | 15 | ||||
-rw-r--r-- | Source/cmGeneratorExpression.h | 55 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 9 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 3 |
9 files changed, 36 insertions, 87 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 14e7927f2f..c4cca072b9 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -354,8 +354,8 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( lg->GetTargetCompileFlags(gtgt, config, language, flags); // Add source file specific flags. - cmGeneratorExpressionInterpreter genexInterpreter(lg, gtgt, config, - gtgt->GetName(), language); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gtgt, + language); const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { @@ -381,8 +381,8 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines( cmMakefile* makefile = lg->GetMakefile(); const std::string& language = source->GetLanguage(); const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmGeneratorExpressionInterpreter genexInterpreter( - lg, target, config, target->GetName(), language); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target, + language); // Add the export symbol definition for shared library objects. if (const char* exportMacro = target->GetExportMacro()) { @@ -419,8 +419,8 @@ std::string cmExtraSublimeTextGenerator::ComputeIncludes( cmMakefile* makefile = lg->GetMakefile(); const std::string& language = source->GetLanguage(); const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmGeneratorExpressionInterpreter genexInterpreter( - lg, target, config, target->GetName(), language); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target, + language); // Add include directories for this source file const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 6823cd53db..6d83a3f71c 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" #include "cmGeneratorExpressionParser.h" +#include "cmGeneratorTarget.h" #include "cmSystemTools.h" cmGeneratorExpression::cmGeneratorExpression( @@ -389,14 +390,16 @@ void cmCompiledGeneratorExpression::GetMaxLanguageStandard( const std::string& cmGeneratorExpressionInterpreter::Evaluate( const char* expression, const std::string& property) { - if (this->Target.empty()) { - return this->EvaluateExpression(expression); - } + this->CompiledGeneratorExpression = + this->GeneratorExpression.Parse(expression); // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS cmGeneratorExpressionDAGChecker dagChecker( - this->Target, property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, - nullptr, nullptr); + this->HeadTarget->GetName(), + property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr, + nullptr); - return this->EvaluateExpression(expression, &dagChecker); + return this->CompiledGeneratorExpression->Evaluate( + this->LocalGenerator, this->Config, false, this->HeadTarget, &dagChecker, + this->Language); } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 2b7df91823..8176d5c073 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -160,24 +160,15 @@ class cmGeneratorExpressionInterpreter public: cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, - cmGeneratorTarget* generatorTarget, - const std::string& config, - const std::string& target, - const std::string& lang) + std::string const& config, + cmGeneratorTarget const* headTarget, + std::string const& lang = std::string()) : LocalGenerator(localGenerator) - , GeneratorTarget(generatorTarget) , Config(config) - , Target(target) + , HeadTarget(headTarget) , Language(lang) { } - cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, - cmGeneratorTarget* generatorTarget, - const std::string& config) - : cmGeneratorExpressionInterpreter(localGenerator, generatorTarget, config, - std::string(), std::string()) - { - } const std::string& Evaluate(const char* expression, const std::string& property); @@ -188,47 +179,11 @@ public: } protected: - cmGeneratorExpression& GetGeneratorExpression() - { - return this->GeneratorExpression; - } - - cmCompiledGeneratorExpression& GetCompiledGeneratorExpression() - { - return *(this->CompiledGeneratorExpression); - } - - cmLocalGenerator* GetLocalGenerator() { return this->LocalGenerator; } - - cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; } - - const std::string& GetTargetName() const { return this->Target; } - const std::string& GetLanguage() const { return this->Language; } - - const std::string& EvaluateExpression( - const char* expression, - cmGeneratorExpressionDAGChecker* dagChecker = nullptr) - { - this->CompiledGeneratorExpression = - this->GeneratorExpression.Parse(expression); - - if (dagChecker == nullptr) { - return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, false, this->GeneratorTarget); - } - - return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, false, this->GeneratorTarget, - dagChecker, this->Language); - } - -private: cmGeneratorExpression GeneratorExpression; std::unique_ptr<cmCompiledGeneratorExpression> CompiledGeneratorExpression; cmLocalGenerator* LocalGenerator = nullptr; - cmGeneratorTarget* GeneratorTarget = nullptr; std::string Config; - std::string Target; + cmGeneratorTarget const* HeadTarget = nullptr; std::string Language; }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7456d3caa3..e353a37700 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -751,11 +751,10 @@ class XCodeGeneratorExpressionInterpreter public: XCodeGeneratorExpressionInterpreter(cmSourceFile* sourceFile, cmLocalGenerator* localGenerator, - cmGeneratorTarget* generatorTarget, + cmGeneratorTarget* headTarget, const std::string& lang) - : cmGeneratorExpressionInterpreter(localGenerator, generatorTarget, - "NO-PER-CONFIG-SUPPORT-IN-XCODE", - generatorTarget->GetName(), lang) + : cmGeneratorExpressionInterpreter( + localGenerator, "NO-PER-CONFIG-SUPPORT-IN-XCODE", headTarget, lang) , SourceFile(sourceFile) { } @@ -767,8 +766,7 @@ public: { const std::string& processed = this->cmGeneratorExpressionInterpreter::Evaluate(expression, property); - if (this->GetCompiledGeneratorExpression() - .GetHadContextSensitiveCondition()) { + if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) { std::ostringstream e; /* clang-format off */ e << @@ -777,7 +775,7 @@ public: "specified for source:\n" " " << this->SourceFile->GetFullPath() << "\n"; /* clang-format on */ - this->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); } return processed; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 13bd214abb..c05b0858ea 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1497,8 +1497,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( lang = sourceLang; } - cmGeneratorExpressionInterpreter genexInterpreter(lg, gt, *i, - gt->GetName(), lang); + cmGeneratorExpressionInterpreter genexInterpreter(lg, *i, gt, lang); bool needfc = false; if (!objectName.empty()) { diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e8cf255e67..c8dc392a83 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -434,8 +434,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string config = this->LocalGenerator->GetConfigName(); std::string configUpper = cmSystemTools::UpperCase(config); cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, config, - this->GeneratorTarget->GetName(), lang); + this->LocalGenerator, config, this->GeneratorTarget, lang); // Add Fortran format flags. if (lang == "Fortran") { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1cfaac543f..ebcc50185f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -136,9 +136,8 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( // Add source file specific flags. cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, - this->LocalGenerator->GetConfigName(), this->GeneratorTarget->GetName(), - language); + this->LocalGenerator, this->LocalGenerator->GetConfigName(), + this->GeneratorTarget, language); const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { @@ -188,8 +187,7 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source, std::set<std::string> defines; const std::string config = this->LocalGenerator->GetConfigName(); cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, config, - this->GeneratorTarget->GetName(), language); + this->LocalGenerator, config, this->GeneratorTarget, language); const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) { @@ -217,8 +215,7 @@ std::string cmNinjaTargetGenerator::ComputeIncludes( std::vector<std::string> includes; const std::string config = this->LocalGenerator->GetConfigName(); cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, config, - this->GeneratorTarget->GetName(), language); + this->LocalGenerator, config, this->GeneratorTarget, language); const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index af4b466386..231cacb0ce 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -722,8 +722,8 @@ static void PopulateFileGroupData( ? languageDataMap.at(kInterfaceSourcesLanguageDataKey) : languageDataMap.at(fileData.Language); cmLocalGenerator* lg = target->GetLocalGenerator(); - cmGeneratorExpressionInterpreter genexInterpreter( - lg, target, config, target->GetName(), fileData.Language); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target, + fileData.Language); std::string compileFlags = ld.Flags; const std::string COMPILE_FLAGS("COMPILE_FLAGS"); @@ -817,7 +817,7 @@ static Json::Value DumpSourceFilesList( auto targetProp = target->Target->GetProperty("INTERFACE_SOURCES"); if (targetProp != nullptr) { cmGeneratorExpressionInterpreter genexInterpreter( - target->GetLocalGenerator(), target, config, target->GetName(), ""); + target->GetLocalGenerator(), config, target); auto evaluatedSources = cmsys::SystemTools::SplitString( genexInterpreter.Evaluate(targetProp, "INTERFACE_SOURCES"), ';'); @@ -977,8 +977,7 @@ static void CreateInterfaceSourcesEntry( LanguageData& ld = languageDataMap[kInterfaceSourcesLanguageDataKey]; ld.Language = ""; - cmGeneratorExpressionInterpreter genexInterpreter(lg, target, config, - target->GetName(), ""); + cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target); std::vector<std::string> propertyValue; GetTargetProperty(genexInterpreter, target, "INTERFACE_INCLUDE_DIRECTORIES", propertyValue); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9e743354ad..53a2a59b1d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2117,8 +2117,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( flagtable = gg->GetCSharpFlagTable(); } cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, config, - this->GeneratorTarget->GetName(), lang); + this->LocalGenerator, config, this->GeneratorTarget, lang); cmVS10GeneratorOptions clOptions( this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler, flagtable, this); |