cmCompiledGeneratorExpression::Evaluate(): return const std::string&

This commit is contained in:
Vitaly Stakhovsky
2018-08-09 14:50:17 -04:00
parent ad4452d1bd
commit c530e2f74f
8 changed files with 41 additions and 40 deletions
+5 -6
View File
@@ -38,7 +38,7 @@ cmGeneratorExpression::~cmGeneratorExpression()
{ {
} }
const char* cmCompiledGeneratorExpression::Evaluate( const std::string& cmCompiledGeneratorExpression::Evaluate(
cmLocalGenerator* lg, const std::string& config, bool quiet, cmLocalGenerator* lg, const std::string& config, bool quiet,
const cmGeneratorTarget* headTarget, const cmGeneratorTarget* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorExpressionDAGChecker* dagChecker,
@@ -48,7 +48,7 @@ const char* cmCompiledGeneratorExpression::Evaluate(
language); language);
} }
const char* cmCompiledGeneratorExpression::Evaluate( const std::string& cmCompiledGeneratorExpression::Evaluate(
cmLocalGenerator* lg, const std::string& config, bool quiet, cmLocalGenerator* lg, const std::string& config, bool quiet,
const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget, const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorExpressionDAGChecker* dagChecker,
@@ -61,12 +61,12 @@ const char* cmCompiledGeneratorExpression::Evaluate(
return this->EvaluateWithContext(context, dagChecker); return this->EvaluateWithContext(context, dagChecker);
} }
const char* cmCompiledGeneratorExpression::EvaluateWithContext( const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
cmGeneratorExpressionContext& context, cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const cmGeneratorExpressionDAGChecker* dagChecker) const
{ {
if (!this->NeedsEvaluation) { if (!this->NeedsEvaluation) {
return this->Input.c_str(); return this->Input;
} }
this->Output.clear(); this->Output.clear();
@@ -97,8 +97,7 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext(
this->DependTargets = context.DependTargets; this->DependTargets = context.DependTargets;
this->AllTargetsSeen = context.AllTargets; this->AllTargetsSeen = context.AllTargets;
// TODO: Return a std::string from here instead? return this->Output;
return this->Output.c_str();
} }
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
+20 -16
View File
@@ -72,16 +72,17 @@ class cmCompiledGeneratorExpression
CM_DISABLE_COPY(cmCompiledGeneratorExpression) CM_DISABLE_COPY(cmCompiledGeneratorExpression)
public: public:
const char* Evaluate(cmLocalGenerator* lg, const std::string& config, const std::string& Evaluate(
bool quiet = false, cmLocalGenerator* lg, const std::string& config, bool quiet = false,
cmGeneratorTarget const* headTarget = nullptr, cmGeneratorTarget const* headTarget = nullptr,
cmGeneratorTarget const* currentTarget = nullptr, cmGeneratorTarget const* currentTarget = nullptr,
cmGeneratorExpressionDAGChecker* dagChecker = nullptr, cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
std::string const& language = std::string()) const; std::string const& language = std::string()) const;
const char* Evaluate(cmLocalGenerator* lg, const std::string& config, const std::string& Evaluate(
bool quiet, cmGeneratorTarget const* headTarget, cmLocalGenerator* lg, const std::string& config, bool quiet,
cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorTarget const* headTarget,
std::string const& language = std::string()) const; cmGeneratorExpressionDAGChecker* dagChecker,
std::string const& language = std::string()) const;
/** Get set of targets found during evaluations. */ /** Get set of targets found during evaluations. */
std::set<cmGeneratorTarget*> const& GetTargets() const std::set<cmGeneratorTarget*> const& GetTargets() const
@@ -126,7 +127,7 @@ public:
std::map<std::string, std::string>& mapping); std::map<std::string, std::string>& mapping);
private: private:
const char* EvaluateWithContext( const std::string& EvaluateWithContext(
cmGeneratorExpressionContext& context, cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const; cmGeneratorExpressionDAGChecker* dagChecker) const;
@@ -219,13 +220,16 @@ protected:
this->GeneratorExpression.Parse(expression); this->GeneratorExpression.Parse(expression);
if (dagChecker == nullptr) { if (dagChecker == nullptr) {
return this->CompiledGeneratorExpression->Evaluate( return this->CompiledGeneratorExpression
this->LocalGenerator, this->Config, false, this->GeneratorTarget); ->Evaluate(this->LocalGenerator, this->Config, false,
this->GeneratorTarget)
.c_str();
} }
return this->CompiledGeneratorExpression->Evaluate( return this->CompiledGeneratorExpression
this->LocalGenerator, this->Config, false, this->GeneratorTarget, ->Evaluate(this->LocalGenerator, this->Config, false,
dagChecker, this->Language); this->GeneratorTarget, dagChecker, this->Language)
.c_str();
} }
private: private:
@@ -55,7 +55,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
std::string outputFileName = this->OutputFileExpr->Evaluate( std::string outputFileName = this->OutputFileExpr->Evaluate(
lg, config, false, nullptr, nullptr, nullptr, lang); lg, config, false, nullptr, nullptr, nullptr, lang);
const std::string outputContent = inputExpression->Evaluate( const std::string& outputContent = inputExpression->Evaluate(
lg, config, false, nullptr, nullptr, nullptr, lang); lg, config, false, nullptr, nullptr, nullptr, lang);
if (cmSystemTools::FileIsFullPath(outputFileName)) { if (cmSystemTools::FileIsFullPath(outputFileName)) {
+1 -1
View File
@@ -5519,7 +5519,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
this->GetName(), "LINK_LIBRARIES", nullptr, nullptr); this->GetName(), "LINK_LIBRARIES", nullptr, nullptr);
cmGeneratorExpression ge(*btIt); cmGeneratorExpression ge(*btIt);
std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le); std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
std::string const evaluated = std::string const& evaluated =
cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker); cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
cmSystemTools::ExpandListArgument(evaluated, llibs); cmSystemTools::ExpandListArgument(evaluated, llibs);
if (cge->GetHadHeadSensitiveCondition()) { if (cge->GetHadHeadSensitiveCondition()) {
+1 -1
View File
@@ -679,7 +679,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::unique_ptr<cmCompiledGeneratorExpression> cge = std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue); ge.Parse(propertyValue);
if (cmSystemTools::IsOn( if (cmSystemTools::IsOn(
cge->Evaluate(target->GetLocalGenerator(), i))) { cge->Evaluate(target->GetLocalGenerator(), i).c_str())) {
activeConfigs.insert(i); activeConfigs.insert(i);
} }
} }
+3 -4
View File
@@ -797,9 +797,8 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
// Remove any config specific variables from the output. // Remove any config specific variables from the output.
cmGeneratorExpression ge; cmGeneratorExpression ge;
auto cge = ge.Parse(command.c_str()); auto cge = ge.Parse(command);
const char* processed = cge->Evaluate(lg, config); const std::string& processed = cge->Evaluate(lg, config);
result[kCTEST_COMMAND] = processed; result[kCTEST_COMMAND] = processed;
// Build up the list of properties that may have been specified // Build up the list of properties that may have been specified
@@ -810,7 +809,7 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
// Remove config variables from the value too. // Remove config variables from the value too.
auto cge_value = ge.Parse(prop.second.GetValue()); auto cge_value = ge.Parse(prop.second.GetValue());
const char* processed_value = cge_value->Evaluate(lg, config); const std::string& processed_value = cge_value->Evaluate(lg, config);
entry[kVALUE_KEY] = processed_value; entry[kVALUE_KEY] = processed_value;
properties.append(entry); properties.append(entry);
} }
+1 -1
View File
@@ -103,7 +103,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
} }
} else { } else {
// Use the command name given. // Use the command name given.
exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config); exe = ge.Parse(exe)->Evaluate(this->LG, config);
cmSystemTools::ConvertToUnixSlashes(exe); cmSystemTools::ConvertToUnixSlashes(exe);
} }
+9 -10
View File
@@ -1742,10 +1742,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)"); e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
} }
for (size_t i = 0; i != this->Configurations.size(); ++i) { for (size_t i = 0; i != this->Configurations.size(); ++i) {
if (0 == if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
strcmp( "1") {
cge->Evaluate(this->LocalGenerator, this->Configurations[i]),
"1")) {
e2.WritePlatformConfigTag("DeploymentContent", e2.WritePlatformConfigTag("DeploymentContent",
"'$(Configuration)|$(Platform)'=='" + "'$(Configuration)|$(Platform)'=='" +
this->Configurations[i] + "|" + this->Configurations[i] + "|" +
@@ -1793,14 +1791,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
ge.Parse(shaderEnableDebug); ge.Parse(shaderEnableDebug);
for (size_t i = 0; i != this->Configurations.size(); ++i) { for (size_t i = 0; i != this->Configurations.size(); ++i) {
const char* enableDebug = const std::string& enableDebug =
cge->Evaluate(this->LocalGenerator, this->Configurations[i]); cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
if (strlen(enableDebug) > 0) { if (!enableDebug.empty()) {
e2.WritePlatformConfigTag( e2.WritePlatformConfigTag(
"EnableDebuggingInformation", "EnableDebuggingInformation",
"'$(Configuration)|$(Platform)'=='" + this->Configurations[i] + "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
"|" + this->Platform + "'", "|" + this->Platform + "'",
cmSystemTools::IsOn(enableDebug) ? "true" : "false"); cmSystemTools::IsOn(enableDebug.c_str()) ? "true" : "false");
} }
} }
} }
@@ -1810,14 +1808,15 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
ge.Parse(shaderDisableOptimizations); ge.Parse(shaderDisableOptimizations);
for (size_t i = 0; i != this->Configurations.size(); ++i) { for (size_t i = 0; i != this->Configurations.size(); ++i) {
const char* disableOptimizations = const std::string& disableOptimizations =
cge->Evaluate(this->LocalGenerator, this->Configurations[i]); cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
if (strlen(disableOptimizations) > 0) { if (!disableOptimizations.empty()) {
e2.WritePlatformConfigTag( e2.WritePlatformConfigTag(
"DisableOptimizations", "DisableOptimizations",
"'$(Configuration)|$(Platform)'=='" + this->Configurations[i] + "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
"|" + this->Platform + "'", "|" + this->Platform + "'",
(cmSystemTools::IsOn(disableOptimizations) ? "true" : "false")); (cmSystemTools::IsOn(disableOptimizations.c_str()) ? "true"
: "false"));
} }
} }
} }