Skip to content

Commit 9ec73bf

Browse files
authored
[6.2] Make sure we don't get backslashes in the Prebuilts Manifest (#9127)
Cherry pick of #9112 from main. We are running into cases where, if the Windows prebuilts build runs last, it's the one producing the prebuilts manifest. Since we're using RelativePath to for the library include paths, it's resulting in Windows paths being used and that fails on the other platforms. This change makes sure we always use forward slashes which will work on all platforms. We use strings for the manifest and correct the slashes before writing them in the generator. We then convert them back to RelativePaths on the client side.
1 parent b8f6162 commit 9ec73bf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Sources/Workspace/Workspace+Prebuilts.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension Workspace {
5454
public let name: String
5555
public var products: [String]
5656
public var cModules: [String]?
57-
public var includePath: [RelativePath]?
57+
public var includePath: [String]?
5858
public var artifacts: [Artifact]?
5959

6060
public var id: String { name }
@@ -81,7 +81,7 @@ extension Workspace {
8181
self.name = name
8282
self.products = products
8383
self.cModules = cModules
84-
self.includePath = includePath
84+
self.includePath = includePath?.map({ $0.pathString.replacingOccurrences(of: "\\", with: "/") })
8585
self.artifacts = artifacts
8686
}
8787
}
@@ -628,7 +628,7 @@ extension Workspace {
628628
path: path,
629629
checkoutPath: checkoutPath,
630630
products: library.products,
631-
includePath: library.includePath,
631+
includePath: try library.includePath?.map({ try RelativePath(validating: $0) }),
632632
cModules: library.cModules ?? []
633633
)
634634
addedPrebuilts.add(managedPrebuilt)

Sources/swift-build-prebuilts/BuildPrebuilts.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct Artifact: Codable {
3030
var checksum: String
3131
var libraryName: String?
3232
var products: [String]?
33-
var includePath: [RelativePath]?
33+
var includePath: [String]?
3434
var cModules: [String]? // deprecated, includePath is the way forward
3535
var swiftVersion: String?
3636
}
@@ -222,7 +222,7 @@ struct BuildPrebuilts: AsyncParsableCommand {
222222
checksum: checksum,
223223
libraryName: libraryName,
224224
products: package.products.map(\.name),
225-
includePath: cModules.map({ $0.includeDir.relative(to: repoDir ) }),
225+
includePath: cModules.map({ $0.includeDir.relative(to: repoDir ).pathString.replacingOccurrences(of: "\\", with: "/") }),
226226
swiftVersion: swiftVersion
227227
)
228228

0 commit comments

Comments
 (0)