mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Merge topic 'genex-generate-file'
b983a58 file: Add GENERATE command to produce files at generate time
This commit is contained in:
@@ -167,6 +167,10 @@ bool cmFileCommand
|
||||
{
|
||||
return this->HandleTimestampCommand(args);
|
||||
}
|
||||
else if ( subCommand == "GENERATE" )
|
||||
{
|
||||
return this->HandleGenerateCommand(args);
|
||||
}
|
||||
|
||||
std::string e = "does not recognize sub-command "+subCommand;
|
||||
this->SetError(e.c_str());
|
||||
@@ -3249,6 +3253,80 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmFileCommand::AddEvaluationFile(const std::string &inputName,
|
||||
const std::string &outputExpr,
|
||||
const std::string &condition,
|
||||
bool inputIsContent
|
||||
)
|
||||
{
|
||||
cmListFileBacktrace lfbt;
|
||||
this->Makefile->GetBacktrace(lfbt);
|
||||
|
||||
cmGeneratorExpression outputGe(lfbt);
|
||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge
|
||||
= outputGe.Parse(outputExpr);
|
||||
|
||||
cmGeneratorExpression conditionGe(lfbt);
|
||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge
|
||||
= conditionGe.Parse(condition);
|
||||
|
||||
this->Makefile->GetLocalGenerator()
|
||||
->GetGlobalGenerator()->AddEvaluationFile(inputName,
|
||||
outputCge,
|
||||
this->Makefile,
|
||||
conditionCge,
|
||||
inputIsContent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmFileCommand::HandleGenerateCommand(
|
||||
std::vector<std::string> const& args)
|
||||
{
|
||||
if (args.size() < 5)
|
||||
{
|
||||
this->SetError("Incorrect arguments to GENERATE subcommand.");
|
||||
return false;
|
||||
}
|
||||
if (args[1] != "OUTPUT")
|
||||
{
|
||||
this->SetError("Incorrect arguments to GENERATE subcommand.");
|
||||
return false;
|
||||
}
|
||||
std::string condition;
|
||||
if (args.size() > 5)
|
||||
{
|
||||
if (args[5] != "CONDITION")
|
||||
{
|
||||
this->SetError("Incorrect arguments to GENERATE subcommand.");
|
||||
return false;
|
||||
}
|
||||
if (args.size() != 7)
|
||||
{
|
||||
this->SetError("Incorrect arguments to GENERATE subcommand.");
|
||||
return false;
|
||||
}
|
||||
condition = args[6];
|
||||
if (condition.empty())
|
||||
{
|
||||
this->SetError("CONDITION of sub-command GENERATE must not be empty if "
|
||||
"specified.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
std::string output = args[2];
|
||||
const bool inputIsContent = args[3] != "INPUT";
|
||||
if (inputIsContent && args[3] != "CONTENT")
|
||||
{
|
||||
this->SetError("Incorrect arguments to GENERATE subcommand.");
|
||||
return false;
|
||||
}
|
||||
std::string input = args[4];
|
||||
|
||||
this->AddEvaluationFile(input, output, condition, inputIsContent);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmFileCommand::HandleTimestampCommand(
|
||||
std::vector<std::string> const& args)
|
||||
|
||||
Reference in New Issue
Block a user