@@ -117,20 +117,21 @@ public actor SwiftPMBuildSystem {
117117 private var testFilesDidChangeCallbacks : [ ( ) async -> Void ] = [ ]
118118
119119 private let workspacePath : TSCAbsolutePath
120+
121+ /// The build setup that allows the user to pass extra compiler flags.
122+ private let buildSetup : BuildSetup
123+
120124 /// The directory containing `Package.swift`.
121125 @_spi ( Testing)
122126 public var projectRoot : TSCAbsolutePath
127+
123128 private var modulesGraph : ModulesGraph
124129 private let workspace : Workspace
125130 @_spi ( Testing) public let toolsBuildParameters : BuildParameters
126131 @_spi ( Testing) public let destinationBuildParameters : BuildParameters
127132 private let fileSystem : FileSystem
128133 private let toolchain : SKCore . Toolchain
129134
130- private let swiftBuildSupportsPrepareForIndexingTask = SwiftExtensions . ThreadSafeBox < Task < Bool , Never > ? > (
131- initialValue: nil
132- )
133-
134135 private var fileToTargets : [ DocumentURI : [ SwiftBuildTarget ] ] = [ : ]
135136 private var sourceDirToTargets : [ DocumentURI : [ SwiftBuildTarget ] ] = [ : ]
136137
@@ -185,6 +186,7 @@ public actor SwiftPMBuildSystem {
185186 reloadPackageStatusCallback: @escaping ( ReloadPackageStatus ) async -> Void = { _ in }
186187 ) async throws {
187188 self . workspacePath = workspacePath
189+ self . buildSetup = buildSetup
188190 self . fileSystem = fileSystem
189191 guard let toolchain = await preferredToolchain ( toolchainRegistry) else {
190192 throw Error . cannotDetermineHostToolchain
@@ -580,30 +582,14 @@ extension SwiftPMBuildSystem: SKCore.BuildSystem {
580582 " --disable-index-store " ,
581583 " --target " , target. targetID,
582584 ]
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] } ?? [ ]
607593 if experimentalFeatures. contains ( . swiftpmPrepareForIndexing) {
608594 arguments. append ( " --experimental-prepare-for-indexing " )
609595 }
0 commit comments