@@ -59,13 +59,21 @@ func withService(
59
59
func withSession(
60
60
service: SWBBuildService ,
61
61
name: String ,
62
+ toolchainPath: Basics . AbsolutePath ,
62
63
packageManagerResourcesDirectory: Basics . AbsolutePath ? ,
63
64
body: @escaping (
64
65
_ session: SWBBuildServiceSession ,
65
66
_ diagnostics: [ SwiftBuild . SwiftBuildMessage . DiagnosticInfo ]
66
67
) async throws -> Void
67
68
) async throws {
68
- switch await service. createSession ( name: name, resourceSearchPaths: packageManagerResourcesDirectory. map { [ $0. pathString] } ?? [ ] , cachePath: nil , inferiorProductsPath: nil , environment: nil ) {
69
+ // SWIFT_EXEC and SWIFT_EXEC_MANIFEST may need to be overridden in debug scenarios in order to pick up Open Source toolchains
70
+ let sessionResult = if toolchainPath. components. contains ( where: { $0. hasSuffix ( " .xctoolchain " ) } ) {
71
+ await service. createSession ( name: name, developerPath: nil , resourceSearchPaths: packageManagerResourcesDirectory. map { [ $0. pathString] } ?? [ ] , cachePath: nil , inferiorProductsPath: nil , environment: nil )
72
+ } else {
73
+ await service. createSession ( name: name, swiftToolchainPath: toolchainPath. pathString, resourceSearchPaths: packageManagerResourcesDirectory. map { [ $0. pathString] } ?? [ ] , cachePath: nil , inferiorProductsPath: nil , environment: nil )
74
+ }
75
+
76
+ switch sessionResult {
69
77
case ( . success( let session) , let diagnostics) :
70
78
do {
71
79
try await body ( session, diagnostics)
@@ -260,7 +268,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
260
268
)
261
269
262
270
do {
263
- try await withSession ( service: service, name: self . buildParameters. pifManifest. pathString, packageManagerResourcesDirectory: self . packageManagerResourcesDirectory) { session, _ in
271
+ try await withSession ( service: service, name: self . buildParameters. pifManifest. pathString, toolchainPath : self . buildParameters . toolchain . toolchainDir , packageManagerResourcesDirectory: self . packageManagerResourcesDirectory) { session, _ in
264
272
self . outputStream. send ( " Building for \( self . buildParameters. configuration == . debug ? " debugging " : " production " ) ... \n " )
265
273
266
274
// Load the workspace, and set the system information to the default
0 commit comments