Skip to content

Commit 14c2bdc

Browse files
committed
Build: make some of the private API more public
This extends the visibility of some of the private implementation to the package level to allow use for testing without `@testable` imports.
1 parent b959a66 commit 14c2bdc

8 files changed

+22
-12
lines changed

Sources/Build/BuildDescription/ClangModuleBuildDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public final class ClangModuleBuildDescription {
128128
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
129129

130130
/// Create a new target description with target and build parameters.
131-
init(
131+
package init(
132132
package: ResolvedPackage,
133133
target: ResolvedModule,
134134
toolsVersion: ToolsVersion,

Sources/Build/BuildDescription/ModuleBuildDescription.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public enum ModuleBuildDescription: SPMBuildCore.ModuleBuildDescription {
122122
}
123123
}
124124

125-
var destination: BuildParameters.Destination {
125+
package var destination: BuildParameters.Destination {
126126
switch self {
127127
case .swift(let buildDescription):
128128
buildDescription.destination
@@ -162,6 +162,11 @@ extension ModuleBuildDescription: Identifiable {
162162
public struct ID: Hashable {
163163
let moduleID: ResolvedModule.ID
164164
let destination: BuildParameters.Destination
165+
166+
package init(moduleID: ResolvedModule.ID, destination: BuildParameters.Destination) {
167+
self.moduleID = moduleID
168+
self.destination = destination
169+
}
165170
}
166171

167172
public var id: ID {

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
5050

5151
/// The dynamic libraries this product needs to link with.
5252
// Computed during build planning.
53-
var dylibs: [ProductBuildDescription] = []
53+
package var dylibs: [ProductBuildDescription] = []
5454

5555
/// Any additional flags to be added. These flags are expected to be computed during build planning.
5656
var additionalFlags: [String] = []
@@ -65,7 +65,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
6565
var libraryBinaryPaths: Set<AbsolutePath> = []
6666

6767
/// Paths to tools shipped in binary dependencies
68-
var availableTools: [String: AbsolutePath] = [:]
68+
package var availableTools: [String: AbsolutePath] = [:]
6969

7070
/// Path to the temporary directory for this product.
7171
var tempsPath: AbsolutePath {
@@ -85,7 +85,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
8585
private let observabilityScope: ObservabilityScope
8686

8787
/// Create a build description for a product.
88-
init(
88+
package init(
8989
package: ResolvedPackage,
9090
product: ResolvedProduct,
9191
toolsVersion: ToolsVersion,
@@ -422,6 +422,11 @@ extension ProductBuildDescription: Identifiable {
422422
public struct ID: Hashable {
423423
let productID: ResolvedProduct.ID
424424
let destination: BuildParameters.Destination
425+
426+
package init(productID: ResolvedProduct.ID, destination: BuildParameters.Destination) {
427+
self.productID = productID
428+
self.destination = destination
429+
}
425430
}
426431

427432
public var id: ID {

Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public final class SwiftModuleBuildDescription {
169169
var libraryBinaryPaths: Set<AbsolutePath> = []
170170

171171
/// Any addition flags to be added. These flags are expected to be computed during build planning.
172-
var additionalFlags: [String] = []
172+
package var additionalFlags: [String] = []
173173

174174
/// Describes the purpose of a test target, including any special roles such as containing a list of discovered
175175
/// tests or serving as the manifest target which contains the main entry point.
@@ -808,7 +808,7 @@ public final class SwiftModuleBuildDescription {
808808
self.target.type == .library
809809
}
810810

811-
func writeOutputFileMap(to path: AbsolutePath) throws {
811+
package func writeOutputFileMap(to path: AbsolutePath) throws {
812812
let masterDepsPath = self.tempsPath.appending("master.swiftdeps")
813813

814814
var content =

Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import struct PackageGraph.ResolvedModule
2020
import struct PackageGraph.ResolvedProduct
2121

2222
extension LLBuildManifestBuilder {
23-
func createProductCommand(_ buildProduct: ProductBuildDescription) throws {
23+
package func createProductCommand(_ buildProduct: ProductBuildDescription) throws {
2424
let cmdName = try buildProduct.commandName
2525

2626
// Add dependency on Info.plist generation on Darwin platforms.

Sources/Build/BuildManifest/LLBuildManifestBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class LLBuildManifestBuilder {
6565
public internal(set) var manifest: LLBuildManifest = .init()
6666

6767
/// Mapping from Swift compiler path to Swift get version files.
68-
var swiftGetVersionFiles = [AbsolutePath: AbsolutePath]()
68+
package var swiftGetVersionFiles = [AbsolutePath: AbsolutePath]()
6969

7070
/// Create a new builder with a build plan.
7171
public init(

Sources/Build/BuildOperation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
577577
}
578578

579579
/// Compute the llbuild target name using the given subset.
580-
func computeLLBuildTargetName(for subset: BuildSubset) async throws -> String {
580+
package func computeLLBuildTargetName(for subset: BuildSubset) async throws -> String {
581581
func inferTestDestination(
582582
testModule: ResolvedModule,
583583
graph: ModulesGraph
@@ -1023,7 +1023,7 @@ extension BuildDescription {
10231023
}
10241024

10251025
extension BuildSubset {
1026-
func recursiveDependencies(for graph: ModulesGraph, observabilityScope: ObservabilityScope) throws -> [ResolvedModule]? {
1026+
package func recursiveDependencies(for graph: ModulesGraph, observabilityScope: ObservabilityScope) throws -> [ResolvedModule]? {
10271027
switch self {
10281028
case .allIncludingTests:
10291029
return Array(graph.reachableModules)

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ extension BuildPlan {
785785
///
786786
/// Note that warnings emitted by the the plugin itself will be returned in the `BuildToolPluginInvocationResult`
787787
/// structures for later showing to the user, and not added directly to the diagnostics engine.
788-
static func invokeBuildToolPlugins(
788+
package static func invokeBuildToolPlugins(
789789
for module: ResolvedModule,
790790
destination: BuildParameters.Destination,
791791
configuration: PluginConfiguration,

0 commit comments

Comments
 (0)