Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
}
return true
}

public func generatePIF(preserveStructure: Bool) async throws -> String {
throw StringError("PIF generation is not applicable to the native build system.")
}
}

public struct PluginConfiguration {
Expand Down
9 changes: 2 additions & 7 deletions Sources/Commands/PackageCommands/DumpCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,8 @@ struct DumpPIF: AsyncSwiftCommand {
var preserveStructure: Bool = false

func run(_ swiftCommandState: SwiftCommandState) async throws {
let graph = try await swiftCommandState.loadPackageGraph()
let pif = try PIFBuilder.generatePIF(
buildParameters: swiftCommandState.productsBuildParameters,
packageGraph: graph,
fileSystem: swiftCommandState.fileSystem,
observabilityScope: swiftCommandState.observabilityScope,
preservePIFModelStructure: preserveStructure)
let buildSystem = try await swiftCommandState.createBuildSystem()
let pif = try await buildSystem.generatePIF(preserveStructure: preserveStructure)
print(pif)
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/SPMBuildCore/BuildSystem/BuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public protocol BuildSystem: Cancellable {
func build(subset: BuildSubset, buildOutputs: [BuildOutput]) async throws -> BuildResult

var hasIntegratedAPIDigesterSupport: Bool { get }

func generatePIF(preserveStructure: Bool) async throws -> String
}

extension BuildSystem {
Expand Down
11 changes: 7 additions & 4 deletions Sources/SwiftBuildSupport/SwiftBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,16 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
}
}

public func writePIF(buildParameters: BuildParameters) async throws {
let pifBuilder = try await getPIFBuilder()
let pif = try await pifBuilder.generatePIF(
public func generatePIF(preserveStructure: Bool) async throws -> String {
return try await getPIFBuilder().generatePIF(
preservePIFModelStructure: preserveStructure,
printPIFManifestGraphviz: buildParameters.printPIFManifestGraphviz,
buildParameters: buildParameters,
buildParameters: buildParameters
)
}

public func writePIF(buildParameters: BuildParameters) async throws {
let pif = try await generatePIF(preserveStructure: false)
try self.fileSystem.writeIfChanged(path: buildParameters.pifManifest, string: pif)
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/XCBuildSupport/XcodeBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
try await packageGraphLoader()
}
}

public func generatePIF(preserveStructure: Bool) async throws -> String {
let graph = try await getPackageGraph()
return try PIFBuilder.generatePIF(
buildParameters: buildParameters,
packageGraph: graph,
fileSystem: fileSystem,
observabilityScope: observabilityScope,
preservePIFModelStructure: preserveStructure
)
}
}

struct XCBBuildParameters: Encodable {
Expand Down