@@ -117,20 +117,21 @@ public actor SwiftPMBuildSystem {
117
117
private var testFilesDidChangeCallbacks : [ ( ) async -> Void ] = [ ]
118
118
119
119
private let workspacePath : TSCAbsolutePath
120
+
121
+ /// The build setup that allows the user to pass extra compiler flags.
122
+ private let buildSetup : BuildSetup
123
+
120
124
/// The directory containing `Package.swift`.
121
125
@_spi ( Testing)
122
126
public var projectRoot : TSCAbsolutePath
127
+
123
128
private var modulesGraph : ModulesGraph
124
129
private let workspace : Workspace
125
130
@_spi ( Testing) public let toolsBuildParameters : BuildParameters
126
131
@_spi ( Testing) public let destinationBuildParameters : BuildParameters
127
132
private let fileSystem : FileSystem
128
133
private let toolchain : SKCore . Toolchain
129
134
130
- private let swiftBuildSupportsPrepareForIndexingTask = SwiftExtensions . ThreadSafeBox < Task < Bool , Never > ? > (
131
- initialValue: nil
132
- )
133
-
134
135
private var fileToTargets : [ DocumentURI : [ SwiftBuildTarget ] ] = [ : ]
135
136
private var sourceDirToTargets : [ DocumentURI : [ SwiftBuildTarget ] ] = [ : ]
136
137
@@ -185,6 +186,7 @@ public actor SwiftPMBuildSystem {
185
186
reloadPackageStatusCallback: @escaping ( ReloadPackageStatus ) async -> Void = { _ in }
186
187
) async throws {
187
188
self . workspacePath = workspacePath
189
+ self . buildSetup = buildSetup
188
190
self . fileSystem = fileSystem
189
191
guard let toolchain = await preferredToolchain ( toolchainRegistry) else {
190
192
throw Error . cannotDetermineHostToolchain
@@ -580,30 +582,14 @@ extension SwiftPMBuildSystem: SKCore.BuildSystem {
580
582
" --disable-index-store " ,
581
583
" --target " , target. targetID,
582
584
]
583
- if self . toolsBuildParameters. configuration != self . destinationBuildParameters. configuration {
584
- logger. fault (
585
- """
586
- Preparation is assuming that tools and destination are built using the same configuration, \
587
- got tools: \( String ( describing: self . toolsBuildParameters. configuration) , privacy: . public) , \
588
- destination: \( String ( describing: self . destinationBuildParameters. configuration) , privacy: . public)
589
- """
590
- )
591
- }
592
- arguments += [ " -c " , self . destinationBuildParameters. configuration. rawValue]
593
- if self . toolsBuildParameters. flags != self . destinationBuildParameters. flags {
594
- logger. fault (
595
- """
596
- Preparation is assuming that tools and destination are built using the same build flags, \
597
- got tools: \( String ( describing: self . toolsBuildParameters. flags) ) , \
598
- destination: \( String ( describing: self . destinationBuildParameters. configuration) )
599
- """
600
- )
601
- }
602
- arguments += self . destinationBuildParameters. flags. cCompilerFlags. flatMap { [ " -Xcc " , $0] }
603
- arguments += self . destinationBuildParameters. flags. cxxCompilerFlags. flatMap { [ " -Xcxx " , $0] }
604
- arguments += self . destinationBuildParameters. flags. swiftCompilerFlags. flatMap { [ " -Xswiftc " , $0] }
605
- arguments += self . destinationBuildParameters. flags. linkerFlags. flatMap { [ " -Xlinker " , $0] }
606
- arguments += self . destinationBuildParameters. flags. xcbuildFlags? . flatMap { [ " -Xxcbuild " , $0] } ?? [ ]
585
+ if let configuration = buildSetup. configuration {
586
+ arguments += [ " -c " , configuration. rawValue]
587
+ }
588
+ arguments += buildSetup. flags. cCompilerFlags. flatMap { [ " -Xcc " , $0] }
589
+ arguments += buildSetup. flags. cxxCompilerFlags. flatMap { [ " -Xcxx " , $0] }
590
+ arguments += buildSetup. flags. swiftCompilerFlags. flatMap { [ " -Xswiftc " , $0] }
591
+ arguments += buildSetup. flags. linkerFlags. flatMap { [ " -Xlinker " , $0] }
592
+ arguments += buildSetup. flags. xcbuildFlags? . flatMap { [ " -Xxcbuild " , $0] } ?? [ ]
607
593
if experimentalFeatures. contains ( . swiftpmPrepareForIndexing) {
608
594
arguments. append ( " --experimental-prepare-for-indexing " )
609
595
}
0 commit comments