Ninja,Makefile: Fix <LANG>_COMPILER_LAUNCHER shell command syntax

The first entry in the compiler launcher command argument list is
the command itself and should be converted to the shell's native
command syntax (e.g. backslashes on Windows).

Without this, the `RunCMake.CompilerLauncher` test fails on Windows
when there are *no* spaces in the path to `cmake.exe`.
This commit is contained in:
Brad King
2019-05-22 09:30:38 -04:00
parent f01e18eb46
commit 8ee6584a99
2 changed files with 13 additions and 4 deletions

View File

@@ -788,8 +788,12 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
if (!compileCommands.empty() && !compilerLauncher.empty()) {
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(compilerLauncher, args, true);
for (std::string& i : args) {
i = this->LocalGenerator->EscapeForShell(i);
if (!args.empty()) {
args[0] = this->LocalGenerator->ConvertToOutputFormat(
args[0], cmOutputConverter::SHELL);
for (std::string& i : cmMakeRange(args.begin() + 1, args.end())) {
i = this->LocalGenerator->EscapeForShell(i);
}
}
compileCommands.front().insert(0, cmJoin(args, " ") + " ");
}

View File

@@ -25,6 +25,7 @@
#include "cmNinjaNormalTargetGenerator.h"
#include "cmNinjaUtilityTargetGenerator.h"
#include "cmOutputConverter.h"
#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
@@ -763,8 +764,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
if (!compileCmds.empty() && !compilerLauncher.empty()) {
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(compilerLauncher, args, true);
for (std::string& i : args) {
i = this->LocalGenerator->EscapeForShell(i);
if (!args.empty()) {
args[0] = this->LocalGenerator->ConvertToOutputFormat(
args[0], cmOutputConverter::SHELL);
for (std::string& i : cmMakeRange(args.begin() + 1, args.end())) {
i = this->LocalGenerator->EscapeForShell(i);
}
}
compileCmds.front().insert(0, cmJoin(args, " ") + " ");
}