Ninja: Shell encode paths used in "cd" commands

This commit is contained in:
Peter Collingbourne 2012-02-19 02:46:37 +00:00
parent cea03e632b
commit 43b1d8bad0
2 changed files with 11 additions and 8 deletions

View File

@ -325,12 +325,12 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc,
{ {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
if (ccg.GetNumberOfCommands() > 0) { if (ccg.GetNumberOfCommands() > 0) {
const char* wd = cc->GetWorkingDirectory();
if (!wd)
wd = this->GetMakefile()->GetStartOutputDirectory();
std::ostringstream cdCmd; std::ostringstream cdCmd;
cdCmd << "cd "; cdCmd << "cd " << this->ConvertToOutputFormat(wd, SHELL);
if (const char* wd = cc->GetWorkingDirectory())
cdCmd << wd;
else
cdCmd << this->GetMakefile()->GetStartOutputDirectory();
cmdLines.push_back(cdCmd.str()); cmdLines.push_back(cdCmd.str());
} }
for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {

View File

@ -377,9 +377,12 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
// the link commands. // the link commands.
if (!preLinkCmdLines.empty()) if (!preLinkCmdLines.empty()) {
preLinkCmdLines.push_back(std::string("cd ") + std::string path = this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetMakefile()->GetHomeOutputDirectory()); this->GetMakefile()->GetHomeOutputDirectory(),
cmLocalGenerator::SHELL);
preLinkCmdLines.push_back("cd " + path);
}
vars["PRE_LINK"] = vars["PRE_LINK"] =
this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines); this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines);