@@ -588,10 +588,13 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
588
588
settings [ " ARCHS " ] = architectures. joined ( separator: " " )
589
589
}
590
590
591
- // support for --enable-parseable-module-interfaces
592
- if buildParameters. driverParameters. enableParseableModuleInterfaces {
593
- settings [ " SWIFT_EMIT_MODULE_INTERFACE " ] = " YES "
591
+ func reportConflict( _ a: String , _ b: String ) throws -> String {
592
+ throw StringError ( " Build parameters constructed conflicting settings overrides ' \( a) ' and ' \( b) ' " )
594
593
}
594
+ try settings. merge ( Self . constructDebuggingSettingsOverrides ( from: buildParameters. debuggingParameters) , uniquingKeysWith: reportConflict)
595
+ try settings. merge ( Self . constructDriverSettingsOverrides ( from: buildParameters. driverParameters) , uniquingKeysWith: reportConflict)
596
+ try settings. merge ( Self . constructLinkerSettingsOverrides ( from: buildParameters. linkingParameters) , uniquingKeysWith: reportConflict)
597
+ try settings. merge ( Self . constructTestingSettingsOverrides ( from: buildParameters. testingParameters) , uniquingKeysWith: reportConflict)
595
598
596
599
// Generate the build parameters.
597
600
var params = SwiftBuild . SWBBuildParameters ( )
@@ -606,6 +609,82 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
606
609
return params
607
610
}
608
611
612
+ private static func constructDebuggingSettingsOverrides( from parameters: BuildParameters . Debugging ) -> [ String : String ] {
613
+ var settings : [ String : String ] = [ : ]
614
+ // TODO: debugInfoFormat: https://github.com/swiftlang/swift-build/issues/560
615
+ // TODO: shouldEnableDebuggingEntitlement: Enable/Disable get-task-allow
616
+ // TODO: omitFramePointer: https://github.com/swiftlang/swift-build/issues/561
617
+ return settings
618
+ }
619
+
620
+ private static func constructDriverSettingsOverrides( from parameters: BuildParameters . Driver ) -> [ String : String ] {
621
+ var settings : [ String : String ] = [ : ]
622
+ switch parameters. explicitTargetDependencyImportCheckingMode {
623
+ case . none:
624
+ break
625
+ case . warn:
626
+ settings [ " DIAGNOSE_MISSING_TARGET_DEPENDENCIES " ] = " YES "
627
+ case . error:
628
+ settings [ " DIAGNOSE_MISSING_TARGET_DEPENDENCIES " ] = " YES_ERROR "
629
+ }
630
+
631
+ if parameters. enableParseableModuleInterfaces {
632
+ settings [ " SWIFT_EMIT_MODULE_INTERFACE " ] = " YES "
633
+ }
634
+
635
+ if parameters. useExplicitModuleBuild {
636
+ settings [ " CLANG_ENABLE_EXPLICIT_MODULES " ] = " YES "
637
+ settings [ " SWIFT_ENABLE_EXPLICIT_MODULES " ] = " YES "
638
+ }
639
+
640
+ return settings
641
+ }
642
+
643
+ private static func constructLinkerSettingsOverrides( from parameters: BuildParameters . Linking ) -> [ String : String ] {
644
+ var settings : [ String : String ] = [ : ]
645
+
646
+ if parameters. linkerDeadStrip {
647
+ settings [ " DEAD_CODE_STRIPPING " ] = " YES "
648
+ }
649
+
650
+ switch parameters. linkTimeOptimizationMode {
651
+ case . full:
652
+ settings [ " LLVM_LTO " ] = " YES "
653
+ settings [ " SWIFT_LTO " ] = " YES "
654
+ case . thin:
655
+ settings [ " LLVM_LTO " ] = " YES_THIN "
656
+ settings [ " SWIFT_LTO " ] = " YES_THIN "
657
+ case nil :
658
+ break
659
+ }
660
+
661
+ // TODO: shouldDisableLocalRpath
662
+ // TODO: shouldLinkStaticSwiftStdlib
663
+
664
+ return settings
665
+ }
666
+
667
+ private static func constructTestingSettingsOverrides( from parameters: BuildParameters . Testing ) -> [ String : String ] {
668
+ var settings : [ String : String ] = [ : ]
669
+ // TODO: enableCodeCoverage
670
+ // explicitlyEnabledTestability
671
+
672
+ switch parameters. explicitlyEnabledTestability {
673
+ case true :
674
+ settings [ " ENABLE_TESTABILITY " ] = " YES "
675
+ case false :
676
+ settings [ " ENABLE_TESTABILITY " ] = " NO "
677
+ default :
678
+ break
679
+ }
680
+
681
+ // TODO: experimentalTestOutput
682
+ // TODO: explicitlyEnabledDiscovery
683
+ // TODO: explicitlySpecifiedPath
684
+
685
+ return settings
686
+ }
687
+
609
688
private func getPIFBuilder( ) async throws -> PIFBuilder {
610
689
try await pifBuilder. memoize {
611
690
let graph = try await getPackageGraph ( )
0 commit comments