Skip to content

Commit 23f32be

Browse files
authored
Introduces the new PIF builder for SwiftBuild (#8405)
Introduces the new PIF builder for packages in `SwiftBuildSupport`. ### Motivation: This continues the work started by #8271, introducing now our new *PIF builder* for packages. As expected, this will happen in the new `SwiftBuildSupport` target, introduced to support the just released **Swift Build** project. ### Modifications: This 1st PR *only* includes the new code in the corresponding `SwiftBuildSupport/PIFPackageBuilder*.swift` source files. The code isn't actually being used (or unit tested) just yet. The code still uses the older `SWBProjectModel.PIF` API to build the PIF data model. In an upcoming PR, I will be migrating this over to the newer `SwiftBuild.ProjectModel` API, and then finally replacing the original code to actually use the PIF builder to send package build information to Swift Build. PS. I did run `SwiftFormat` in all new code, as indicated by the contributors guide. ### Result: This marks the start of our *package PIF builder* unification (i.e., between Xcode and SwiftPM). Tracked by rdar://147767772.
1 parent 8a27f1a commit 23f32be

10 files changed

+4136
-8
lines changed

Sources/PackageGraph/Resolution/ResolvedModule.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public struct ResolvedModule {
151151
self.underlying.sources
152152
}
153153

154-
let packageIdentity: PackageIdentity
154+
package let packageIdentity: PackageIdentity
155155

156156
/// The underlying module represented in this resolved module.
157157
public let underlying: Module

Sources/SwiftBuildSupport/BuildSystem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension BuildSubset {
1414
var pifTargetName: String {
1515
switch self {
1616
case .product(let name, _):
17-
PackagePIFProjectBuilder.targetName(for: name)
17+
_PackagePIFProjectBuilder.targetName(for: name)
1818
case .target(let name, _):
1919
name
2020
case .allExcludingTests:

Sources/SwiftBuildSupport/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_library(SwiftBuildSupport STATIC
10+
BuildSystem.swift
11+
PackagePIFBuilder.swift
12+
PackagePIFBuilder+Helpers.swift
13+
PackagePIFBuilder+Plugins.swift
14+
PackagePIFProjectBuilder.swift
15+
PackagePIFProjectBuilder+Modules.swift
16+
PackagePIFProjectBuilder+Products.swift
1017
PIF.swift
1118
PIFBuilder.swift
12-
BuildSystem.swift
1319
SwiftBuildSystem.swift)
1420
target_link_libraries(SwiftBuildSupport PUBLIC
1521
Build

Sources/SwiftBuildSupport/PIFBuilder.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public final class PIFBuilder {
120120
let sortedPackages = self.graph.packages
121121
.sorted { $0.manifest.displayName < $1.manifest.displayName } // TODO: use identity instead?
122122
var projects: [PIFProjectBuilder] = try sortedPackages.map { package in
123-
try PackagePIFProjectBuilder(
123+
try _PackagePIFProjectBuilder(
124124
package: package,
125125
parameters: self.parameters,
126126
fileSystem: self.fileSystem,
@@ -247,7 +247,7 @@ class PIFProjectBuilder {
247247
}
248248
}
249249

250-
final class PackagePIFProjectBuilder: PIFProjectBuilder {
250+
final class _PackagePIFProjectBuilder: PIFProjectBuilder {
251251
private let package: ResolvedPackage
252252
private let parameters: PIFBuilderParameters
253253
private let fileSystem: FileSystem
@@ -1074,7 +1074,7 @@ final class AggregatePIFProjectBuilder: PIFProjectBuilder {
10741074
allIncludingTestsTarget.addBuildConfiguration(name: "Debug")
10751075
allIncludingTestsTarget.addBuildConfiguration(name: "Release")
10761076

1077-
for case let project as PackagePIFProjectBuilder in projects where project.isRootPackage {
1077+
for case let project as _PackagePIFProjectBuilder in projects where project.isRootPackage {
10781078
for case let target as PIFTargetBuilder in project.targets {
10791079
if target.productType != .unitTest {
10801080
allExcludingTestsTarget.addDependency(
@@ -1555,7 +1555,7 @@ extension ResolvedProduct {
15551555
var pifTargetGUID: PIF.GUID { "PACKAGE-PRODUCT:\(name)" }
15561556

15571557
var mainTarget: ResolvedModule {
1558-
modules.first { $0.type == underlying.type.targetType }!
1558+
modules.first { $0.type == underlying.type._targetType }!
15591559
}
15601560

15611561
/// Returns the recursive dependencies, limited to the target's package, which satisfy the input build environment,
@@ -1612,7 +1612,7 @@ extension Module {
16121612
}
16131613

16141614
extension ProductType {
1615-
var targetType: Module.Kind {
1615+
var _targetType: Module.Kind {
16161616
switch self {
16171617
case .executable:
16181618
.executable

0 commit comments

Comments
 (0)