Skip to content

Commit e84c0ba

Browse files
authored
Some PIF delegate fixes for Swift Build (#8573)
### Motivation: Fixes a few issues introduced by #8441, where the PIF model transitioned from reference types to value types (i.e., the new SwiftBuild.ProjectModel API.) ### Modifications: Just a couple of changes in protocol PackagePIFBuilder.BuildDelegate, ensuring we can actually mutate the passed-in ProjectModel.Project value.
1 parent b092abe commit e84c0ba

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Sources/SwiftBuildSupport/PIFBuilder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelega
279279
[]
280280
}
281281

282-
func addCustomTargets(pifProject: SwiftBuild.ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct] {
282+
func addCustomTargets(pifProject: inout SwiftBuild.ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct] {
283283
return []
284284
}
285285

@@ -293,6 +293,7 @@ fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelega
293293

294294
func configureLibraryProduct(
295295
product: PackageModel.Product,
296+
project: inout ProjectModel.Project,
296297
target: WritableKeyPath<ProjectModel.Project, ProjectModel.Target>,
297298
additionalFiles: WritableKeyPath<ProjectModel.Group, ProjectModel.Group>
298299
) {

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public final class PackagePIFBuilder {
124124
func customSDKOptions(forPlatform: PackageModel.Platform) -> [String]
125125

126126
/// Create additional custom PIF targets after all targets have been built.
127-
func addCustomTargets(pifProject: ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct]
127+
func addCustomTargets(pifProject: inout ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct]
128128

129129
/// Should we suppresses the specific product dependency, updating the provided build settings if necessary?
130130
/// The specified product may be in the same package or a different one.
@@ -141,6 +141,7 @@ public final class PackagePIFBuilder {
141141
/// Provides additional configuration and files for the specified library product.
142142
func configureLibraryProduct(
143143
product: PackageModel.Product,
144+
project: inout ProjectModel.Project,
144145
target: WritableKeyPath<ProjectModel.Project, ProjectModel.Target>,
145146
additionalFiles: WritableKeyPath<ProjectModel.Group, ProjectModel.Group>
146147
)
@@ -474,7 +475,7 @@ public final class PackagePIFBuilder {
474475
}
475476
}
476477

477-
let customModulesAndProducts = try delegate.addCustomTargets(pifProject: projectBuilder.project)
478+
let customModulesAndProducts = try delegate.addCustomTargets(pifProject: &projectBuilder.project)
478479
projectBuilder.builtModulesAndProducts.append(contentsOf: customModulesAndProducts)
479480

480481
self._pifProject = projectBuilder.project

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ extension PackagePIFProjectBuilder {
703703
// Additional configuration and files for this library product.
704704
pifBuilder.delegate.configureLibraryProduct(
705705
product: product.underlying,
706+
project: &self.project,
706707
target: librayUmbrellaTargetKeyPath,
707708
additionalFiles: additionalFilesGroupKeyPath
708709
)

0 commit comments

Comments
 (0)