diff options
Diffstat (limited to 'Source/cmGeneratorExpression.h')
-rw-r--r-- | Source/cmGeneratorExpression.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index cface0d70..9fd53c67e 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -153,4 +153,89 @@ private: bool EvaluateForBuildsystem; }; +class cmGeneratorExpressionInterpreter +{ + CM_DISABLE_COPY(cmGeneratorExpressionInterpreter) + +public: + cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, + cmGeneratorTarget* generatorTarget, + const std::string& config, + const std::string& target, + const std::string& lang) + : LocalGenerator(localGenerator) + , GeneratorTarget(generatorTarget) + , Config(config) + , Target(target) + , Language(lang) + { + } + cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, + cmGeneratorTarget* generatorTarget, + const std::string& config) + : cmGeneratorExpressionInterpreter(localGenerator, generatorTarget, config, + std::string(), std::string()) + { + } + + const char* Evaluate(const char* expression) + { + return this->EvaluateExpression(expression); + } + const char* Evaluate(const std::string& expression) + { + return this->Evaluate(expression.c_str()); + } + const char* Evaluate(const char* expression, const std::string& property); + const char* Evaluate(const std::string& expression, + const std::string& property) + { + return this->Evaluate(expression.c_str(), property); + } + +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 char* 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; + std::string Language; +}; + #endif |