mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-29 18:51:05 -05:00
cmMakefile: Extract custom command validation method
This commit is contained in:
+19
-8
@@ -821,6 +821,22 @@ void cmMakefile::ConfigureFinalPass()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::ValidateCustomCommand(
|
||||||
|
const cmCustomCommandLines& commandLines) const
|
||||||
|
{
|
||||||
|
// TODO: More strict?
|
||||||
|
for (cmCustomCommandLine const& cl : commandLines) {
|
||||||
|
if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
|
||||||
|
this->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void cmMakefile::AddCustomCommandToTarget(
|
void cmMakefile::AddCustomCommandToTarget(
|
||||||
const std::string& target, const std::vector<std::string>& byproducts,
|
const std::string& target, const std::vector<std::string>& byproducts,
|
||||||
const std::vector<std::string>& depends,
|
const std::vector<std::string>& depends,
|
||||||
@@ -959,14 +975,9 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate custom commands. TODO: More strict?
|
// Validate custom commands.
|
||||||
for (cmCustomCommandLine const& cl : commandLines) {
|
if (!this->ValidateCustomCommand(commandLines)) {
|
||||||
if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
|
return nullptr;
|
||||||
std::ostringstream e;
|
|
||||||
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
|
|
||||||
this->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always create the output sources and mark them generated.
|
// Always create the output sources and mark them generated.
|
||||||
|
|||||||
@@ -1067,6 +1067,8 @@ private:
|
|||||||
bool atOnly, const char* filename,
|
bool atOnly, const char* filename,
|
||||||
long line, bool replaceAt) const;
|
long line, bool replaceAt) const;
|
||||||
|
|
||||||
|
bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const;
|
||||||
|
|
||||||
void CreateGeneratedSources(const std::vector<std::string>& outputs);
|
void CreateGeneratedSources(const std::vector<std::string>& outputs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user