mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
cmCustomCommandGenerator: Avoid mutable state
Expand generator expressions of DEPENDS in the constructor instead of on-demand.
This commit is contained in:
@@ -24,7 +24,6 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
|||||||
, OldStyle(cc.GetEscapeOldStyle())
|
, OldStyle(cc.GetEscapeOldStyle())
|
||||||
, MakeVars(cc.GetEscapeAllowMakeVars())
|
, MakeVars(cc.GetEscapeAllowMakeVars())
|
||||||
, GE(new cmGeneratorExpression(cc.GetBacktrace()))
|
, GE(new cmGeneratorExpression(cc.GetBacktrace()))
|
||||||
, DependsDone(false)
|
|
||||||
{
|
{
|
||||||
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
|
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
|
||||||
for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin();
|
for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin();
|
||||||
@@ -44,6 +43,22 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
|||||||
}
|
}
|
||||||
this->CommandLines.push_back(argv);
|
this->CommandLines.push_back(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> depends = this->CC.GetDepends();
|
||||||
|
for (std::vector<std::string>::const_iterator i = depends.begin();
|
||||||
|
i != depends.end(); ++i) {
|
||||||
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
|
||||||
|
std::vector<std::string> result;
|
||||||
|
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
|
||||||
|
result);
|
||||||
|
for (std::vector<std::string>::iterator it = result.begin();
|
||||||
|
it != result.end(); ++it) {
|
||||||
|
if (cmSystemTools::FileIsFullPath(it->c_str())) {
|
||||||
|
*it = cmSystemTools::CollapseFullPath(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->Depends.insert(this->Depends.end(), result.begin(), result.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCustomCommandGenerator::~cmCustomCommandGenerator()
|
cmCustomCommandGenerator::~cmCustomCommandGenerator()
|
||||||
@@ -171,23 +186,5 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const
|
|||||||
|
|
||||||
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
|
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
|
||||||
{
|
{
|
||||||
if (!this->DependsDone) {
|
|
||||||
this->DependsDone = true;
|
|
||||||
std::vector<std::string> depends = this->CC.GetDepends();
|
|
||||||
for (std::vector<std::string>::const_iterator i = depends.begin();
|
|
||||||
i != depends.end(); ++i) {
|
|
||||||
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
|
|
||||||
std::vector<std::string> result;
|
|
||||||
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
|
|
||||||
result);
|
|
||||||
for (std::vector<std::string>::iterator it = result.begin();
|
|
||||||
it != result.end(); ++it) {
|
|
||||||
if (cmSystemTools::FileIsFullPath(it->c_str())) {
|
|
||||||
*it = cmSystemTools::CollapseFullPath(*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->Depends.insert(this->Depends.end(), result.begin(), result.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this->Depends;
|
return this->Depends;
|
||||||
}
|
}
|
||||||
|
@@ -21,9 +21,8 @@ class cmCustomCommandGenerator
|
|||||||
bool OldStyle;
|
bool OldStyle;
|
||||||
bool MakeVars;
|
bool MakeVars;
|
||||||
cmGeneratorExpression* GE;
|
cmGeneratorExpression* GE;
|
||||||
mutable bool DependsDone;
|
|
||||||
mutable std::vector<std::string> Depends;
|
|
||||||
cmCustomCommandLines CommandLines;
|
cmCustomCommandLines CommandLines;
|
||||||
|
std::vector<std::string> Depends;
|
||||||
|
|
||||||
const char* GetCrossCompilingEmulator(unsigned int c) const;
|
const char* GetCrossCompilingEmulator(unsigned int c) const;
|
||||||
const char* GetArgv0Location(unsigned int c) const;
|
const char* GetArgv0Location(unsigned int c) const;
|
||||||
|
Reference in New Issue
Block a user