@@ -413,7 +413,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
413
413
throw error
414
414
}
415
415
416
- let request = try self . makeBuildRequest ( configuredTargets: configuredTargets, derivedDataPath: derivedDataPath, genSymbolGraph: genSymbolGraph)
416
+ let request = try await self . makeBuildRequest ( session : session , configuredTargets: configuredTargets, derivedDataPath: derivedDataPath, genSymbolGraph: genSymbolGraph)
417
417
418
418
struct BuildState {
419
419
private var targetsByID : [ Int : SwiftBuild . SwiftBuildMessage . TargetStartedInfo ] = [ : ]
@@ -521,7 +521,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
521
521
case . taskComplete( let info) :
522
522
let startedInfo = try buildState. completed ( task: info)
523
523
if info. result != . success {
524
- self . observabilityScope. emit ( severity: . error, message: " \( startedInfo. ruleInfo) failed with a nonzero exit code " )
524
+ self . observabilityScope. emit ( severity: . error, message: " \( startedInfo. ruleInfo) failed with a nonzero exit code. Command line: \( startedInfo . commandLineDisplayString ?? " <no command line> " ) " )
525
525
}
526
526
let targetInfo = try buildState. target ( for: startedInfo)
527
527
self . delegate? . buildSystem ( self , didFinishCommand: BuildSystemCommand ( startedInfo, targetInfo: targetInfo) )
@@ -631,7 +631,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
631
631
)
632
632
}
633
633
634
- private func makeBuildParameters( genSymbolGraph: Bool ) throws -> SwiftBuild . SWBBuildParameters {
634
+ private func makeBuildParameters( session : SWBBuildServiceSession , genSymbolGraph: Bool ) async throws -> SwiftBuild . SWBBuildParameters {
635
635
// Generate the run destination parameters.
636
636
let runDestination = makeRunDestination ( )
637
637
@@ -642,11 +642,20 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
642
642
643
643
// Generate a table of any overriding build settings.
644
644
var settings : [ String : String ] = [ : ]
645
- // An error with determining the override should not be fatal here.
646
- settings [ " CC " ] = try ? buildParameters. toolchain. getClangCompiler ( ) . pathString
647
- // Always specify the path of the effective Swift compiler, which was determined in the same way as for the
648
- // native build system.
649
- settings [ " SWIFT_EXEC " ] = buildParameters. toolchain. swiftCompilerPath. pathString
645
+
646
+ // If the SwiftPM toolchain corresponds to a toolchain registered with the lower level build system, add it to the toolchain stack.
647
+ // Otherwise, apply overrides for each component of the SwiftPM toolchain.
648
+ if let toolchainID = try await session. lookupToolchain ( at: buildParameters. toolchain. toolchainDir. pathString) {
649
+ settings [ " TOOLCHAINS " ] = " \( toolchainID. rawValue) $(inherited) "
650
+ } else {
651
+ // FIXME: This list of overrides is incomplete.
652
+ // An error with determining the override should not be fatal here.
653
+ settings [ " CC " ] = try ? buildParameters. toolchain. getClangCompiler ( ) . pathString
654
+ // Always specify the path of the effective Swift compiler, which was determined in the same way as for the
655
+ // native build system.
656
+ settings [ " SWIFT_EXEC " ] = buildParameters. toolchain. swiftCompilerPath. pathString
657
+ }
658
+
650
659
// FIXME: workaround for old Xcode installations such as what is in CI
651
660
settings [ " LM_SKIP_METADATA_EXTRACTION " ] = " YES "
652
661
if genSymbolGraph {
@@ -705,6 +714,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
705
714
settings [ " ARCHS " ] = architectures. joined ( separator: " " )
706
715
}
707
716
717
+ // When building with the CLI for macOS, test bundles should generate entrypoints for compatibility with swiftpm-testing-helper.
718
+ if buildParameters. triple. isMacOSX {
719
+ settings [ " GENERATE_TEST_ENTRYPOINTS_FOR_BUNDLES " ] = " YES "
720
+ }
721
+
708
722
func reportConflict( _ a: String , _ b: String ) throws -> String {
709
723
throw StringError ( " Build parameters constructed conflicting settings overrides ' \( a) ' and ' \( b) ' " )
710
724
}
@@ -727,9 +741,9 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
727
741
return params
728
742
}
729
743
730
- public func makeBuildRequest( configuredTargets: [ SWBTargetGUID ] , derivedDataPath: Basics . AbsolutePath , genSymbolGraph: Bool ) throws -> SWBBuildRequest {
744
+ public func makeBuildRequest( session : SWBBuildServiceSession , configuredTargets: [ SWBTargetGUID ] , derivedDataPath: Basics . AbsolutePath , genSymbolGraph: Bool ) async throws -> SWBBuildRequest {
731
745
var request = SWBBuildRequest ( )
732
- request. parameters = try makeBuildParameters ( genSymbolGraph: genSymbolGraph)
746
+ request. parameters = try await makeBuildParameters ( session : session , genSymbolGraph: genSymbolGraph)
733
747
request. configuredTargets = configuredTargets. map { SWBConfiguredTarget ( guid: $0. rawValue, parameters: request. parameters) }
734
748
request. useParallelTargets = true
735
749
request. useImplicitDependencies = false
0 commit comments