Commit 4651dbcf authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: expand variables in arguments before the commands get them

parent 2b9140f6
......@@ -48,8 +48,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
for (unsigned int j = 0; j < args.size(); ++j)
{
std::string copy = args[j];
m_Makefile->ExpandVariablesInString(copy);
std::string const& copy = args[j];
if(copy == "SOURCE")
{
......@@ -124,7 +123,6 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
this->SetError("Wrong syntax. Empty TARGET.");
return false;
}
m_Makefile->AddCustomCommand(source.c_str(),
command.c_str(),
command_args,
......
......@@ -17,9 +17,8 @@
#include "cmAddCustomTargetCommand.h"
// cmAddCustomTargetCommand
bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& argsIn)
bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
{
std::vector<std::string> args = argsIn;
bool all = false;
if(args.size() < 2 )
......@@ -27,11 +26,10 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& argsI
this->SetError("called with incorrect number of arguments");
return false;
}
m_Makefile->ExpandVariablesInString(args[0]);
// all target option
std::string arguments;
std::vector<std::string>::iterator s = args.begin();
std::vector<std::string>::const_iterator s = args.begin();
++s; // move past args[0] as it is already to be used
if (args.size() >= 3)
{
......@@ -44,12 +42,11 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& argsI
std::string command;
if(s != args.end())
{
command = m_Makefile->ExpandVariablesInString(*s);
command = *s;
++s;
}
for (;s != args.end(); ++s)
{
m_Makefile->ExpandVariablesInString(*s);
arguments += cmSystemTools::EscapeSpaces(s->c_str());
arguments += " ";
}
......
......@@ -27,9 +27,7 @@ bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args)
for(std::vector<std::string>::const_iterator i = args.begin();
i != args.end(); ++i)
{
std::string str = *i;
m_Makefile->ExpandVariablesInString(str);
m_Makefile->AddDefineFlag(str.c_str());
m_Makefile->AddDefineFlag(i->c_str());
}
return true;
}
......
......@@ -27,7 +27,6 @@ bool cmAddDependenciesCommand::InitialPass(std::vector<std::string> const& args)
}
std::string target_name = args[0];
m_Makefile->ExpandVariablesInString(target_name);
cmTargets &tgts = m_Makefile->GetTargets();
if (tgts.find(target_name) != tgts.end())
......@@ -37,21 +36,11 @@ bool cmAddDependenciesCommand::InitialPass(std::vector<std::string> const& args)
std::string depend_target;
for (; s != args.end(); ++s)
{
depend_target = *s;
m_Makefile->ExpandVariablesInString(depend_target);
tgts[target_name].AddUtility(depend_target.c_str());
tgts[target_name].AddUtility(s->c_str());
}
}
else
{
std::cerr << "existing targets are:";
for(cmTargets::iterator i = tgts.begin();
i != tgts.end(); ++i)
{
std::cerr << i->first << std::endl;
}
std::string error = "Adding dependency to non-existent target: ";
error += target_name;
this->SetError(error.c_str());
......
......@@ -29,7 +29,6 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
std::vector<std::string>::const_iterator s = args.begin();
std::string exename = *s;
m_Makefile->ExpandVariablesInString(exename);
++s;
bool use_win32 = false;
......@@ -41,12 +40,6 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
}
std::vector<std::string> srclists(s, args.end());
for(std::vector<std::string>::iterator j = srclists.begin();
j != srclists.end(); ++j)
{
m_Makefile->ExpandVariablesInString(*j);
}
m_Makefile->AddExecutable(exename.c_str(), srclists, use_win32);
return true;
......
......@@ -33,7 +33,6 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
std::vector<std::string>::const_iterator s = args.begin();
std::string libname = *s;
m_Makefile->ExpandVariablesInString(libname);
++s;
......@@ -43,7 +42,6 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
if(s != args.end())
{
std::string libType = *s;
m_Makefile->ExpandVariablesInString(libType);
if(libType == "STATIC")
{
++s;
......@@ -64,9 +62,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
std::vector<std::string> srclists;
while (s != args.end())
{
std::string copy = *s;
m_Makefile->ExpandVariablesInString(copy);
srclists.push_back(copy);
srclists.push_back(*s);
++s;
}
......
......@@ -38,9 +38,7 @@ bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args)
for (std::vector<std::string>::const_iterator j = args.begin();
j != args.end(); ++j)
{
temp = *j;
m_Makefile->ExpandVariablesInString(temp);
m_Args.push_back(temp);
m_Args.push_back(*j);
}
return true;
......
......@@ -33,7 +33,6 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
}
std::string makecommand;
std::string makeprogram = args[1];
m_Makefile->ExpandVariablesInString(makeprogram);
if(makeprogram.find("msdev") != std::string::npos ||
makeprogram.find("MSDEV") != std::string::npos )
{
......
......@@ -19,21 +19,14 @@
#include "cmTarget.h"
// cmCableClassSetCommand
bool cmCableClassSetCommand::InitialPass(std::vector<std::string> const& argsIn)
bool cmCableClassSetCommand::InitialPass(std::vector<std::string> const& args)
{
if(argsIn.size() < 2)
if(args.size() < 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args = argsIn;
// First, we want to expand all CMAKE variables in all arguments.
for(std::vector<std::string>::iterator a = args.begin();
a != args.end(); ++a)
{
m_Makefile->ExpandVariablesInString(*a);
}
// The first argument is the name of the set.
std::vector<std::string>::const_iterator arg = args.begin();
m_ClassSetName = *arg++;
......
......@@ -122,22 +122,14 @@ cmCableWrapTclCommand::~cmCableWrapTclCommand()
// cmCableWrapTclCommand
bool cmCableWrapTclCommand::InitialPass(std::vector<std::string> const& argsIn)
bool cmCableWrapTclCommand::InitialPass(std::vector<std::string> const& args)
{
if(argsIn.size() < 2)
if(args.size() < 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args = argsIn;
// First, we want to expand all CMAKE variables in all arguments.
for(std::vector<std::string>::iterator a = args.begin();
a != args.end(); ++a)
{
m_Makefile->ExpandVariablesInString(*a);
}
// Prepare to iterate through the arguments.
std::vector<std::string>::const_iterator arg = args.begin();
......
......@@ -70,9 +70,7 @@ void cmConfigureFileCommand::FinalPass()
void cmConfigureFileCommand::ConfigureFile()
{
m_Makefile->ExpandVariablesInString(m_InputFile);
m_Makefile->AddCMakeDependFile(m_InputFile.c_str());
m_Makefile->ExpandVariablesInString(m_OuputFile);
cmSystemTools::ConvertToUnixSlashes(m_OuputFile);
std::string::size_type pos = m_OuputFile.rfind('/');
if(pos != std::string::npos)
......
......@@ -51,9 +51,7 @@ bool cmElseCommand::InitialPass(std::vector<std::string> const& args)
if (args.size() == 2 && (args[0] == "EXISTS"))
{
std::string tmp = args[1];
m_Makefile->ExpandVariablesInString(tmp);
if(cmSystemTools::FileExists(tmp.c_str()))
if(cmSystemTools::FileExists(args[1].c_str()))
{
f = new cmIfFunctionBlocker();
}
......
......@@ -24,7 +24,6 @@ bool cmEndIfCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments");
return false;
}
// remove any function blockers for this define
m_Makefile->RemoveFunctionBlocker("ENDIF",args);
......
......@@ -18,19 +18,16 @@
#include "cmSystemTools.h"
// cmExecProgramCommand
bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args)
{
std::vector<std::string> args = argsIn;
if(args.size() < 1 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::string output;
m_Makefile->ExpandVariablesInString(args[0]);
if(args.size() == 2)
{
m_Makefile->ExpandVariablesInString(args[1]);
cmSystemTools::MakeDirectory(args[1].c_str());
std::string command;
command = "cd ";
......
......@@ -65,11 +65,8 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string> const& argsIn)
// add any user specified paths
for (unsigned int j = 2; j < args.size(); j++)
{
// expand variables
std::string exp = args[j];
m_Makefile->ExpandVariablesInString(exp);
// Glob the entry in case of wildcards.
cmSystemTools::GlobDirs(exp.c_str(), path);
cmSystemTools::GlobDirs(args[j].c_str(), path);
}
// add the standard path
......
......@@ -63,14 +63,12 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
}
else
{
m_Makefile->ExpandVariablesInString(args[j]);
if(doingNames)
{
names.push_back(args[j]);
}
else
{
cmSystemTools::ExpandRegistryValues(args[j]);
// Glob the entry in case of wildcards.
cmSystemTools::GlobDirs(args[j].c_str(), path);
}
......@@ -87,7 +85,6 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
{
// expand variables
std::string exp = args[j];
m_Makefile->ExpandVariablesInString(exp);
cmSystemTools::ExpandRegistryValues(exp);
// Glob the entry in case of wildcards.
......
......@@ -68,7 +68,6 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
{
// expand variables
std::string exp = args[j];
m_Makefile->ExpandVariablesInString(exp);
cmSystemTools::ExpandRegistryValues(exp);
// Glob the entry in case of wildcards.
......
......@@ -86,7 +86,6 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
}
else
{
m_Makefile->ExpandVariablesInString(args[j]);
if(doingNames)
{
names.push_back(args[j]);
......@@ -110,7 +109,6 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
{
// expand variables
std::string exp = args[j];
m_Makefile->ExpandVariablesInString(exp);
cmSystemTools::ExpandRegistryValues(exp);
// Glob the entry in case of wildcards.
......
......@@ -39,7 +39,6 @@ bool cmGetFilenameComponentCommand::InitialPass(std::vector<std::string> const&
std::string result;
std::string filename = args[1];
m_Makefile->ExpandVariablesInString(filename);
if (args[2] == "PATH")
{
......
......@@ -76,7 +76,6 @@ bool cmIfCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments");
return false;
}
// create a function blocker
cmIfFunctionBlocker *f = NULL;
......@@ -112,9 +111,7 @@ bool cmIfCommand::InitialPass(std::vector<std::string> const& args)
if (args.size() == 2 && (args[0] == "EXISTS"))
{
std::string tmp = args[1];
m_Makefile->ExpandVariablesInString(tmp);
if(!cmSystemTools::FileExists(tmp.c_str()))
if(!cmSystemTools::FileExists(args[1].c_str()))
{
f = new cmIfFunctionBlocker();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment