Ninja: Fix escaping of paths with spaces for Swift tooling

If a path inside a project contains spaces, the generated Ninja
definitions previously contained superfluous quotes.

Fixes: #26404
This commit is contained in:
Winfried Auner
2024-10-28 11:37:05 +01:00
committed by Brad King
parent 7e0d3b1ca9
commit 75e4cd8d18
4 changed files with 12 additions and 7 deletions
+8 -7
View File
@@ -1289,11 +1289,9 @@ void cmNinjaTargetGenerator::GenerateSwiftOutputFileMap(
if (cmValue name = target->GetProperty("Swift_DEPENDENCIES_FILE")) { if (cmValue name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
return *name; return *name;
} }
return this->GetLocalGenerator()->ConvertToOutputFormat( return this->ConvertToNinjaPath(cmStrCat(target->GetSupportDirectory(),
this->ConvertToNinjaPath(cmStrCat(target->GetSupportDirectory(), '/', '/', config, '/',
config, '/', target->GetName(), target->GetName(), ".swiftdeps"));
".swiftdeps")),
cmOutputConverter::SHELL);
}(); }();
std::string mapFilePath = std::string mapFilePath =
@@ -1311,7 +1309,7 @@ void cmNinjaTargetGenerator::GenerateSwiftOutputFileMap(
// Add flag // Add flag
this->LocalGenerator->AppendFlags(flags, "-output-file-map"); this->LocalGenerator->AppendFlags(flags, "-output-file-map");
this->LocalGenerator->AppendFlagEscape( this->LocalGenerator->AppendFlags(
flags, flags,
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(mapFilePath), cmOutputConverter::SHELL)); ConvertToNinjaPath(mapFilePath), cmOutputConverter::SHELL));
@@ -2014,7 +2012,10 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
std::string const emitModuleFlag = "-emit-module"; std::string const emitModuleFlag = "-emit-module";
std::string const modulePathFlag = "-emit-module-path"; std::string const modulePathFlag = "-emit-module-path";
this->LocalGenerator->AppendFlags( this->LocalGenerator->AppendFlags(
vars["FLAGS"], { emitModuleFlag, modulePathFlag, moduleFilepath }); vars["FLAGS"],
{ emitModuleFlag, modulePathFlag,
this->LocalGenerator->ConvertToOutputFormat(
moduleFilepath, cmOutputConverter::SHELL) });
objBuild.Outputs.push_back(moduleFilepath); objBuild.Outputs.push_back(moduleFilepath);
} }
this->LocalGenerator->AppendFlags(vars["FLAGS"], this->LocalGenerator->AppendFlags(vars["FLAGS"],
+2
View File
@@ -32,6 +32,8 @@ add_subdirectory(SubC)
add_subdirectory(SubD) add_subdirectory(SubD)
add_subdirectory(SubE) add_subdirectory(SubE)
add_subdirectory("Sub Space")
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
add_executable(SwiftOnly main.swift) add_executable(SwiftOnly main.swift)
+1
View File
@@ -0,0 +1 @@
add_library(SubSpace SubSpace.swift)
+1
View File
@@ -0,0 +1 @@
public func space() { print("space") }