mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 18:09:42 -05:00
Ninja: Fix depfile binding with spaces in path
In build statements we use a single `DEP_FILE = ...` binding that is shared between `depfile = $DEP_FILE` and `command = ... $DEP_FILE ...` bindings in the corresponding rule. In cases that the command's shell argument needs quoting, add a separate `depfile = ...` binding to the build statement to express the depfile path without quoting. Otherwise `ninja` tries to open a file path that contains literal quotes. Fixes: #26287
This commit is contained in:
@@ -2495,16 +2495,22 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
|
||||
this->Generator->Configs[config].ExtraFiles.push_back(std::move(output));
|
||||
}
|
||||
|
||||
void cmNinjaTargetGenerator::AddDepfileBinding(
|
||||
cmNinjaVars& vars, std::string const& depfile) const
|
||||
void cmNinjaTargetGenerator::AddDepfileBinding(cmNinjaVars& vars,
|
||||
std::string depfile) const
|
||||
{
|
||||
vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
depfile, cmOutputConverter::SHELL);
|
||||
std::string depfileForShell =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(depfile,
|
||||
cmOutputConverter::SHELL);
|
||||
if (depfile != depfileForShell) {
|
||||
vars["depfile"] = std::move(depfile);
|
||||
}
|
||||
vars["DEP_FILE"] = std::move(depfileForShell);
|
||||
}
|
||||
|
||||
void cmNinjaTargetGenerator::RemoveDepfileBinding(cmNinjaVars& vars) const
|
||||
{
|
||||
vars.erase("DEP_FILE");
|
||||
vars.erase("depfile");
|
||||
}
|
||||
|
||||
void cmNinjaTargetGenerator::addPoolNinjaVariable(
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
std::string GetTargetName() const;
|
||||
|
||||
void AddDepfileBinding(cmNinjaVars& vars, std::string const& depfile) const;
|
||||
void AddDepfileBinding(cmNinjaVars& vars, std::string depfile) const;
|
||||
void RemoveDepfileBinding(cmNinjaVars& vars) const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user