ENH: Abstract parsing of arguments so that I can use it in other places
This commit is contained in:
parent
9a0ca088a1
commit
028f5aa2c7
|
@ -293,20 +293,9 @@ bool cmSystemTools::IsOff(const char* val)
|
||||||
v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
|
v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSystemTools::RunSingleCommand(
|
std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
|
||||||
const char* command,
|
|
||||||
std::string* output,
|
|
||||||
int *retVal,
|
|
||||||
const char* dir,
|
|
||||||
bool verbose,
|
|
||||||
int timeout)
|
|
||||||
{
|
{
|
||||||
if(s_DisableRunCommandOutput)
|
std::vector<cmStdString> args;
|
||||||
{
|
|
||||||
verbose = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> args;
|
|
||||||
std::string arg;
|
std::string arg;
|
||||||
|
|
||||||
bool win_path = false;
|
bool win_path = false;
|
||||||
|
@ -365,19 +354,37 @@ bool cmSystemTools::RunSingleCommand(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmSystemTools::RunSingleCommand(
|
||||||
|
const char* command,
|
||||||
|
std::string* output,
|
||||||
|
int *retVal,
|
||||||
|
const char* dir,
|
||||||
|
bool verbose,
|
||||||
|
int timeout)
|
||||||
|
{
|
||||||
|
if(s_DisableRunCommandOutput)
|
||||||
|
{
|
||||||
|
verbose = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
|
||||||
|
|
||||||
|
if(args.size() < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<const char*> argv;
|
std::vector<const char*> argv;
|
||||||
for(std::vector<std::string>::const_iterator a = args.begin();
|
for(std::vector<cmStdString>::const_iterator a = args.begin();
|
||||||
a != args.end(); ++a)
|
a != args.end(); ++a)
|
||||||
{
|
{
|
||||||
argv.push_back(a->c_str());
|
argv.push_back(a->c_str());
|
||||||
}
|
}
|
||||||
argv.push_back(0);
|
argv.push_back(0);
|
||||||
|
|
||||||
if(argv.size() < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( output )
|
if ( output )
|
||||||
{
|
{
|
||||||
*output = "";
|
*output = "";
|
||||||
|
|
|
@ -179,6 +179,11 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool RunSingleCommand(const char* command, std::string* output = 0,
|
static bool RunSingleCommand(const char* command, std::string* output = 0,
|
||||||
int* retVal = 0, const char* dir = 0, bool verbose = true, int timeout = 0);
|
int* retVal = 0, const char* dir = 0, bool verbose = true, int timeout = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse arguments out of a single string command
|
||||||
|
*/
|
||||||
|
static std::vector<cmStdString> ParseArguments(const char* command);
|
||||||
|
|
||||||
static void EnableMessages() { s_DisableMessages = false; }
|
static void EnableMessages() { s_DisableMessages = false; }
|
||||||
static void DisableMessages() { s_DisableMessages = true; }
|
static void DisableMessages() { s_DisableMessages = true; }
|
||||||
|
|
Loading…
Reference in New Issue