Skip to content

Commit 0d26325

Browse files
authored
Merge pull request swiftlang#2866 from compnerd/escape-from-the-confinement
PackageLoading: escape `\` when generating the modulemap
2 parents 9a97c7e + d51a31c commit 0d26325

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Sources/PackageLoading/ModuleMapGenerator.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010

1111
import TSCBasic
1212
import PackageModel
13+
import Foundation
1314

1415
public let moduleMapFilename = "module.modulemap"
1516

17+
extension AbsolutePath {
18+
fileprivate var moduleEscapedPathString: String {
19+
return self.pathString.replacingOccurrences(of: "\\", with: "\\\\")
20+
}
21+
}
22+
1623
/// A protocol for targets which might have a modulemap.
1724
protocol ModuleMapProtocol {
1825
var moduleMapPath: AbsolutePath { get }
@@ -152,9 +159,9 @@ public struct ModuleMapGenerator {
152159
stream <<< "module \(target.c99name) {\n"
153160
switch type {
154161
case .header(let header):
155-
stream <<< " umbrella header \"\(header.pathString)\"\n"
162+
stream <<< " umbrella header \"\(header.moduleEscapedPathString)\"\n"
156163
case .directory(let path):
157-
stream <<< " umbrella \"\(path.pathString)\"\n"
164+
stream <<< " umbrella \"\(path.moduleEscapedPathString)\"\n"
158165
}
159166
stream <<< " export *\n"
160167
stream <<< "}\n"

0 commit comments

Comments
 (0)