ENH: changed FOREACH to use variables instead of string replacement
This commit is contained in:
parent
1823e78d5c
commit
f5dbca4971
|
@ -33,6 +33,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
|
||||||
mf.ExpandArguments(lff.m_Arguments, expandedArguments);
|
mf.ExpandArguments(lff.m_Arguments, expandedArguments);
|
||||||
if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0]))
|
if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0]))
|
||||||
{
|
{
|
||||||
|
// store the old value
|
||||||
|
const char *oldDef = mf.GetDefinition(m_Args[0].c_str());
|
||||||
m_Executing = true;
|
m_Executing = true;
|
||||||
std::string variable = "${";
|
std::string variable = "${";
|
||||||
variable += m_Args[0];
|
variable += m_Args[0];
|
||||||
|
@ -44,29 +46,16 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
|
||||||
cmListFileArgument arg;
|
cmListFileArgument arg;
|
||||||
for( ; j != m_Args.end(); ++j)
|
for( ; j != m_Args.end(); ++j)
|
||||||
{
|
{
|
||||||
|
// set the variable to the loop value
|
||||||
|
mf.AddDefinition(m_Args[0].c_str(),j->c_str());
|
||||||
// Invoke all the functions that were collected in the block.
|
// Invoke all the functions that were collected in the block.
|
||||||
for(unsigned int c = 0; c < m_Functions.size(); ++c)
|
for(unsigned int c = 0; c < m_Functions.size(); ++c)
|
||||||
{
|
{
|
||||||
// Replace the loop variable and then invoke the command.
|
mf.ExecuteCommand(m_Functions[c]);
|
||||||
cmListFileFunction newLFF;
|
|
||||||
newLFF.m_Name = m_Functions[c].m_Name;
|
|
||||||
newLFF.m_FilePath = m_Functions[c].m_FilePath;
|
|
||||||
newLFF.m_Line = m_Functions[c].m_Line;
|
|
||||||
for (std::vector<cmListFileArgument>::const_iterator k =
|
|
||||||
m_Functions[c].m_Arguments.begin();
|
|
||||||
k != m_Functions[c].m_Arguments.end(); ++k)
|
|
||||||
{
|
|
||||||
tmps = k->Value;
|
|
||||||
cmSystemTools::ReplaceString(tmps, variable.c_str(), j->c_str());
|
|
||||||
arg.Value = tmps;
|
|
||||||
arg.Quoted = k->Quoted;
|
|
||||||
arg.FilePath = k->FilePath;
|
|
||||||
arg.Line = k->Line;
|
|
||||||
newLFF.m_Arguments.push_back(arg);
|
|
||||||
}
|
|
||||||
mf.ExecuteCommand(newLFF);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// restore the variable to its prior value
|
||||||
|
mf.AddDefinition(m_Args[0].c_str(),oldDef);
|
||||||
mf.RemoveFunctionBlocker(lff);
|
mf.RemoveFunctionBlocker(lff);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue