@@ -32,6 +32,8 @@ import struct PackageGraph.ModulesGraph
3232import struct PackageGraph. ResolvedModule
3333import struct PackageGraph. ResolvedPackage
3434
35+ import struct SPMBuildCore. BuildParameters
36+
3537import enum SwiftBuild. ProjectModel
3638
3739typealias GUID = SwiftBuild . ProjectModel . GUID
@@ -179,6 +181,9 @@ public final class PackagePIFBuilder {
179181 /// The file system to read from.
180182 let fileSystem : FileSystem
181183
184+ /// The build parameters
185+ let buildParameters : BuildParameters
186+
182187 /// Whether to suppress warnings from compilers, linkers, and other build tools for package dependencies.
183188 private var suppressWarningsForPackageDependencies : Bool {
184189 UserDefaults . standard. bool ( forKey: " SuppressWarningsForPackageDependencies " , defaultValue: true )
@@ -203,7 +208,8 @@ public final class PackagePIFBuilder {
203208 addLocalRpaths: Bool = true ,
204209 packageDisplayVersion: String ? ,
205210 fileSystem: FileSystem ,
206- observabilityScope: ObservabilityScope
211+ observabilityScope: ObservabilityScope ,
212+ buildParameters: BuildParameters ,
207213 ) {
208214 self . package = resolvedPackage
209215 self . packageManifest = packageManifest
@@ -215,6 +221,7 @@ public final class PackagePIFBuilder {
215221 self . fileSystem = fileSystem
216222 self . observabilityScope = observabilityScope
217223 self . addLocalRpaths = addLocalRpaths
224+ self . buildParameters = buildParameters
218225 }
219226
220227 public init (
@@ -227,7 +234,8 @@ public final class PackagePIFBuilder {
227234 addLocalRpaths: Bool = true ,
228235 packageDisplayVersion: String ? ,
229236 fileSystem: FileSystem ,
230- observabilityScope: ObservabilityScope
237+ observabilityScope: ObservabilityScope ,
238+ buildParameters: BuildParameters ,
231239 ) {
232240 self . package = resolvedPackage
233241 self . packageManifest = packageManifest
@@ -239,6 +247,7 @@ public final class PackagePIFBuilder {
239247 self . packageDisplayVersion = packageDisplayVersion
240248 self . fileSystem = fileSystem
241249 self . observabilityScope = observabilityScope
250+ self . buildParameters = buildParameters
242251 }
243252
244253 /// Build an empty PIF project.
@@ -438,7 +447,7 @@ public final class PackagePIFBuilder {
438447 //
439448
440449 self . log ( . debug, " Processing \( package . products. count) products: " )
441-
450+
442451 // For each of the **products** in the package we create a corresponding `PIFTarget` of the appropriate type.
443452 for product in self . package . products {
444453 switch product. type {
@@ -461,7 +470,7 @@ public final class PackagePIFBuilder {
461470 }
462471
463472 case . executable, . test, . snippet:
464- try projectBuilder. makeMainModuleProduct ( product)
473+ try projectBuilder. makeMainModuleProduct ( product, buildParameters : self . buildParameters )
465474
466475 case . plugin:
467476 try projectBuilder. makePluginProduct ( product)
@@ -561,8 +570,8 @@ public final class PackagePIFBuilder {
561570 // We currently deliberately do not support Swift ObjC interface headers.
562571 settings [ . SWIFT_INSTALL_OBJC_HEADER] = " NO "
563572 settings [ . SWIFT_OBJC_INTERFACE_HEADER_NAME] = " "
564-
565- // rdar://47937899 (Don't try to link frameworks to object files)
573+
574+ // rdar://47937899 (Don't try to link frameworks to object files)
566575 // - looks like this defaults to OTHER_LDFLAGS (via xcspec) which can result in linking frameworks to mh_objects which is unwanted.
567576 settings [ . OTHER_LDRFLAGS] = [ ]
568577
@@ -622,6 +631,7 @@ public final class PackagePIFBuilder {
622631 debugSettings [ . ENABLE_TESTABILITY] = " YES "
623632 debugSettings [ . SWIFT_ACTIVE_COMPILATION_CONDITIONS, default: [ ] ] . append ( contentsOf: [ " DEBUG " ] )
624633 debugSettings [ . GCC_PREPROCESSOR_DEFINITIONS, default: [ " $(inherited) " ] ] . append ( contentsOf: [ " DEBUG=1 " ] )
634+ debugSettings [ . SWIFT_INDEX_STORE_ENABLE] = " YES "
625635 builder. project. addBuildConfig { id in BuildConfig ( id: id, name: " Debug " , settings: debugSettings) }
626636
627637 // Add the build settings that are specific to release builds, and set those as the "Release" configuration.
0 commit comments