Skip to content

Commit 7bd0ecd

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/SwiftBuildSupport/SwiftBuildSystem.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ 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(name: name, swiftToolchainPath: toolchainPath, resourceSearchPaths: packageManagerResourcesDirectory.map { [$0.pathString] } ?? [], cachePath: nil, inferiorProductsPath: nil, environment: nil) {
7273
case (.success(let session), let diagnostics):
7374
do {
7475
try await body(session, diagnostics)
@@ -265,7 +266,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
265266
)
266267

267268
do {
268-
try await withSession(service: service, name: self.buildParameters.pifManifest.pathString, packageManagerResourcesDirectory: self.packageManagerResourcesDirectory) { session, _ in
269+
let toolchainPath = self.buildParameters.toolchain.swiftCompilerPath
270+
.parentDirectory // remove swift
271+
.parentDirectory // remove bin
272+
.parentDirectory // remove usr
273+
try await withSession(service: service, name: self.buildParameters.pifManifest.pathString, toolchainPath: toolchainPath.pathString, packageManagerResourcesDirectory: self.packageManagerResourcesDirectory) { session, _ in
269274
self.outputStream.send("Building for \(self.buildParameters.configuration == .debug ? "debugging" : "production")...\n")
270275

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

0 commit comments

Comments
 (0)