Skip to content

Commit 99f53dc

Browse files
committed
Initialize Swift Build with a toolchain-based developer directory
1 parent c8d439a commit 99f53dc

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Sources/SwiftBuildSupport/SwiftBuildSystem.swift

+20-2
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,22 @@ func withService(
6262
func withSession(
6363
service: SWBBuildService,
6464
name: String,
65+
toolchainPath: String,
6566
packageManagerResourcesDirectory: Basics.AbsolutePath?,
6667
body: @escaping (
6768
_ session: SWBBuildServiceSession,
6869
_ diagnostics: [SwiftBuild.SwiftBuildMessage.DiagnosticInfo]
6970
) async throws -> Void
7071
) async throws {
71-
switch await service.createSession(name: name, resourceSearchPaths: packageManagerResourcesDirectory.map { [$0.pathString] } ?? [], cachePath: nil, inferiorProductsPath: nil, environment: nil) {
72+
switch await service.createSession(
73+
name: name,
74+
swiftToolchainPath: toolchainPath,
75+
resourceSearchPaths: packageManagerResourcesDirectory.map {
76+
[$0.pathString]
77+
} ?? [],
78+
cachePath: nil, inferiorProductsPath: nil,
79+
environment: nil
80+
) {
7281
case (.success(let session), let diagnostics):
7382
do {
7483
try await body(session, diagnostics)
@@ -265,7 +274,16 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
265274
)
266275

267276
do {
268-
try await withSession(service: service, name: self.buildParameters.pifManifest.pathString, packageManagerResourcesDirectory: self.packageManagerResourcesDirectory) { session, _ in
277+
let toolchainPath = self.buildParameters.toolchain.swiftCompilerPath
278+
.parentDirectory // remove swift
279+
.parentDirectory // remove bin
280+
.parentDirectory // remove usr
281+
try await withSession(
282+
service: service,
283+
name: self.buildParameters.pifManifest.pathString,
284+
toolchainPath: toolchainPath.pathString,
285+
packageManagerResourcesDirectory: self.packageManagerResourcesDirectory
286+
) { session, _ in
269287
self.outputStream.send("Building for \(self.buildParameters.configuration == .debug ? "debugging" : "production")...\n")
270288

271289
// Load the workspace, and set the system information to the default

0 commit comments

Comments
 (0)