Skip to content

Commit b1c6736

Browse files
authored
[6.0] Restore visibility of APIs that have been made package (#7570)
- Explanation: We would still very much like to reduce the visibility of various APIs/modules in SwiftPM to make it easier to make changes/refactor/maintain in general. But given how long these have all been public for, we are reverting these changes for now and instead make posts on the forums asking for feedback for the APIs we'd like to hide. Depending on the API it may be that there's another way to retrieve similar information, or that we need to provide a separate (ideally stable) API for it. - Scope: `package` APIs has been made externally accessible again. - Main Branch PRs: #7568 - Risk: Very Low - Reviewed By: @bnbarham - Testing: Not a functional change.
1 parent d05b594 commit b1c6736

File tree

125 files changed

+1164
-1221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1164
-1221
lines changed

Sources/Basics/ProgressAnimation/NinjaProgressAnimation.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream
1515

1616
extension ProgressAnimation {
1717
/// A ninja-like progress animation that adapts to the provided output stream.
18-
package static func ninja(
18+
@_spi(SwiftPMInternal)
19+
public static func ninja(
1920
stream: WritableByteStream,
2021
verbose: Bool
2122
) -> any ProgressAnimationProtocol {

Sources/Basics/ProgressAnimation/PercentProgressAnimation.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream
1515

1616
extension ProgressAnimation {
1717
/// A percent-based progress animation that adapts to the provided output stream.
18-
package static func percent(
18+
@_spi(SwiftPMInternal)
19+
public static func percent(
1920
stream: WritableByteStream,
2021
verbose: Bool,
2122
header: String

Sources/Basics/ProgressAnimation/ProgressAnimationProtocol.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import class TSCBasic.LocalFileOutputByteStream
1515
import protocol TSCBasic.WritableByteStream
1616
import protocol TSCUtility.ProgressAnimationProtocol
1717

18-
package typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
18+
@_spi(SwiftPMInternal)
19+
public typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
1920

2021
/// Namespace to nest public progress animations under.
21-
package enum ProgressAnimation {
22+
@_spi(SwiftPMInternal)
23+
public enum ProgressAnimation {
2224
/// Dynamically create a progress animation based on the current stream
2325
/// capabilities and desired verbosity.
2426
///

Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,27 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
5656
}
5757
}
5858

59+
@_spi(SwiftPMInternal)
5960
extension ProgressAnimationProtocol {
60-
package func throttled<C: Clock>(
61+
@_spi(SwiftPMInternal)
62+
public func throttled<C: Clock>(
6163
now: @escaping () -> C.Instant,
6264
interval: C.Duration,
6365
clock: C.Type = C.self
6466
) -> some ProgressAnimationProtocol {
6567
ThrottledProgressAnimation(self, now: now, interval: interval, clock: clock)
6668
}
6769

68-
package func throttled<C: Clock>(
70+
@_spi(SwiftPMInternal)
71+
public func throttled<C: Clock>(
6972
clock: C,
7073
interval: C.Duration
7174
) -> some ProgressAnimationProtocol {
7275
self.throttled(now: { clock.now }, interval: interval, clock: C.self)
7376
}
7477

75-
package func throttled(
78+
@_spi(SwiftPMInternal)
79+
public func throttled(
7680
interval: ContinuousClock.Duration
7781
) -> some ProgressAnimationProtocol {
7882
self.throttled(clock: ContinuousClock(), interval: interval)

Sources/Build/BuildDescription/ClangTargetBuildDescription.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ import struct SPMBuildCore.PrebuildCommandResult
2323
import enum TSCBasic.ProcessEnv
2424

2525
/// Target description for a Clang target i.e. C language family target.
26-
package final class ClangTargetBuildDescription {
26+
public final class ClangTargetBuildDescription {
2727
/// The package this target belongs to.
28-
package let package: ResolvedPackage
28+
public let package: ResolvedPackage
2929

3030
/// The target described by this target.
31-
package let target: ResolvedTarget
31+
public let target: ResolvedTarget
3232

3333
/// The underlying clang target.
34-
package let clangTarget: ClangTarget
34+
public let clangTarget: ClangTarget
3535

3636
/// The tools version of the package that declared the target. This can
3737
/// can be used to conditionalize semantically significant changes in how
3838
/// a target is built.
39-
package let toolsVersion: ToolsVersion
39+
public let toolsVersion: ToolsVersion
4040

4141
/// The build parameters.
4242
let buildParameters: BuildParameters
@@ -47,7 +47,7 @@ package final class ClangTargetBuildDescription {
4747
}
4848

4949
/// The list of all resource files in the target, including the derived ones.
50-
package var resources: [Resource] {
50+
public var resources: [Resource] {
5151
self.target.underlying.resources + self.pluginDerivedResources
5252
}
5353

@@ -65,7 +65,7 @@ package final class ClangTargetBuildDescription {
6565
}
6666

6767
/// The modulemap file for this target, if any.
68-
package private(set) var moduleMap: AbsolutePath?
68+
public private(set) var moduleMap: AbsolutePath?
6969

7070
/// Path to the temporary directory for this target.
7171
var tempsPath: AbsolutePath
@@ -82,13 +82,13 @@ package final class ClangTargetBuildDescription {
8282
private var pluginDerivedResources: [Resource]
8383

8484
/// Path to the resource accessor header file, if generated.
85-
package private(set) var resourceAccessorHeaderFile: AbsolutePath?
85+
public private(set) var resourceAccessorHeaderFile: AbsolutePath?
8686

8787
/// Path to the resource Info.plist file, if generated.
88-
package private(set) var resourceBundleInfoPlistPath: AbsolutePath?
88+
public private(set) var resourceBundleInfoPlistPath: AbsolutePath?
8989

9090
/// The objects in this target.
91-
package var objects: [AbsolutePath] {
91+
public var objects: [AbsolutePath] {
9292
get throws {
9393
try compilePaths().map(\.object)
9494
}
@@ -104,12 +104,12 @@ package final class ClangTargetBuildDescription {
104104
private let fileSystem: FileSystem
105105

106106
/// If this target is a test target.
107-
package var isTestTarget: Bool {
107+
public var isTestTarget: Bool {
108108
target.type == .test
109109
}
110110

111111
/// The results of applying any build tool plugins to this target.
112-
package let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
112+
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
113113

114114
/// Create a new target description with target and build parameters.
115115
init(
@@ -188,7 +188,7 @@ package final class ClangTargetBuildDescription {
188188
}
189189

190190
/// An array of tuples containing filename, source, object and dependency path for each of the source in this target.
191-
package func compilePaths()
191+
public func compilePaths()
192192
throws -> [(filename: RelativePath, source: AbsolutePath, object: AbsolutePath, deps: AbsolutePath)]
193193
{
194194
let sources = [
@@ -212,7 +212,7 @@ package final class ClangTargetBuildDescription {
212212
/// NOTE: The parameter to specify whether to get C++ semantics is currently optional, but this is only for revlock
213213
/// avoidance with clients. Callers should always specify what they want based either the user's indication or on a
214214
/// default value (possibly based on the filename suffix).
215-
package func basicArguments(
215+
public func basicArguments(
216216
isCXX isCXXOverride: Bool? = .none,
217217
isC: Bool = false
218218
) throws -> [String] {
@@ -323,7 +323,7 @@ package final class ClangTargetBuildDescription {
323323
return args
324324
}
325325

326-
package func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
326+
public func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
327327
let standards = [
328328
(clangTarget.cxxLanguageStandard, SupportedLanguageExtension.cppExtensions),
329329
(clangTarget.cLanguageStandard, SupportedLanguageExtension.cExtensions),

Sources/Build/BuildDescription/PluginDescription.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ import protocol Basics.FileSystem
2121
/// But because the package graph and build plan are not loaded for incremental
2222
/// builds, this information is included in the BuildDescription, and the plugin
2323
/// targets are compiled directly.
24-
package final class PluginDescription: Codable {
24+
public final class PluginDescription: Codable {
2525
/// The identity of the package in which the plugin is defined.
26-
package let package: PackageIdentity
26+
public let package: PackageIdentity
2727

2828
/// The name of the plugin target in that package (this is also the name of
2929
/// the plugin).
30-
package let targetName: String
30+
public let targetName: String
3131

3232
/// The names of any plugin products in that package that vend the plugin
3333
/// to other packages.
34-
package let productNames: [String]
34+
public let productNames: [String]
3535

3636
/// The tools version of the package that declared the target. This affects
3737
/// the API that is available in the PackagePlugin module.
38-
package let toolsVersion: ToolsVersion
38+
public let toolsVersion: ToolsVersion
3939

4040
/// Swift source files that comprise the plugin.
41-
package let sources: Sources
41+
public let sources: Sources
4242

4343
/// Initialize a new plugin target description. The target is expected to be
4444
/// a `PluginTarget`.

Sources/Build/BuildDescription/ProductBuildDescription.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ import SPMBuildCore
2222
import struct TSCBasic.SortedArray
2323

2424
/// The build description for a product.
25-
package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
25+
public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
2626
/// The reference to the product.
27-
package let package: ResolvedPackage
27+
public let package: ResolvedPackage
2828

2929
/// The reference to the product.
30-
package let product: ResolvedProduct
30+
public let product: ResolvedProduct
3131

3232
/// The tools version of the package that declared the product. This can
3333
/// can be used to conditionalize semantically significant changes in how
3434
/// a target is built.
35-
package let toolsVersion: ToolsVersion
35+
public let toolsVersion: ToolsVersion
3636

3737
/// The build parameters.
38-
package let buildParameters: BuildParameters
38+
public let buildParameters: BuildParameters
3939

4040
/// All object files to link into this product.
4141
///
4242
// Computed during build planning.
43-
package internal(set) var objects = SortedArray<AbsolutePath>()
43+
public internal(set) var objects = SortedArray<AbsolutePath>()
4444

4545
/// The dynamic libraries this product needs to link with.
4646
// Computed during build planning.
@@ -129,7 +129,7 @@ package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescriptio
129129
}
130130

131131
/// The arguments to the librarian to create a static library.
132-
package func archiveArguments() throws -> [String] {
132+
public func archiveArguments() throws -> [String] {
133133
let librarian = self.buildParameters.toolchain.librarianPath.pathString
134134
let triple = self.buildParameters.triple
135135
if triple.isWindows(), librarian.hasSuffix("link") || librarian.hasSuffix("link.exe") {
@@ -142,7 +142,7 @@ package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescriptio
142142
}
143143

144144
/// The arguments to link and create this product.
145-
package func linkArguments() throws -> [String] {
145+
public func linkArguments() throws -> [String] {
146146
var args = [buildParameters.toolchain.swiftCompilerPath.pathString]
147147
args += self.buildParameters.sanitizers.linkSwiftFlags()
148148
args += self.additionalFlags
@@ -397,7 +397,7 @@ package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescriptio
397397
}
398398

399399
extension SortedArray where Element == AbsolutePath {
400-
package static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
400+
public static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
401401
lhs.insert(contentsOf: rhs)
402402
}
403403
}

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

+19-18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import PackageGraph
1717
import PackageLoading
1818
import PackageModel
1919

20+
@_spi(SwiftPMInternal)
2021
import SPMBuildCore
2122

2223
#if USE_IMPL_ONLY_IMPORTS
@@ -28,19 +29,19 @@ import DriverSupport
2829
import struct TSCBasic.ByteString
2930

3031
/// Target description for a Swift target.
31-
package final class SwiftTargetBuildDescription {
32+
public final class SwiftTargetBuildDescription {
3233
/// The package this target belongs to.
33-
package let package: ResolvedPackage
34+
public let package: ResolvedPackage
3435

3536
/// The target described by this target.
36-
package let target: ResolvedTarget
37+
public let target: ResolvedTarget
3738

3839
private let swiftTarget: SwiftTarget
3940

4041
/// The tools version of the package that declared the target. This can
4142
/// can be used to conditionalize semantically significant changes in how
4243
/// a target is built.
43-
package let toolsVersion: ToolsVersion
44+
public let toolsVersion: ToolsVersion
4445

4546
/// The build parameters.
4647
let buildParameters: BuildParameters
@@ -77,22 +78,22 @@ package final class SwiftTargetBuildDescription {
7778
}
7879

7980
/// The list of all source files in the target, including the derived ones.
80-
package var sources: [AbsolutePath] {
81+
public var sources: [AbsolutePath] {
8182
self.target.sources.paths + self.derivedSources.paths + self.pluginDerivedSources.paths
8283
}
8384

84-
package var sourcesFileListPath: AbsolutePath {
85+
public var sourcesFileListPath: AbsolutePath {
8586
self.tempsPath.appending(component: "sources")
8687
}
8788

8889
/// The list of all resource files in the target, including the derived ones.
89-
package var resources: [Resource] {
90+
public var resources: [Resource] {
9091
self.target.underlying.resources + self.pluginDerivedResources
9192
}
9293

9394
/// The objects in this target, containing either machine code or bitcode
9495
/// depending on the build parameters used.
95-
package var objects: [AbsolutePath] {
96+
public var objects: [AbsolutePath] {
9697
get throws {
9798
let relativeSources = self.target.sources.relativePaths
9899
+ self.derivedSources.relativePaths
@@ -112,7 +113,7 @@ package final class SwiftTargetBuildDescription {
112113
}
113114

114115
/// The path to the swiftmodule file after compilation.
115-
public var moduleOutputPath: AbsolutePath { // note: needs to be `public` because of sourcekit-lsp
116+
public var moduleOutputPath: AbsolutePath { // note: needs to be public because of sourcekit-lsp
116117
// If we're an executable and we're not allowing test targets to link against us, we hide the module.
117118
let triple = buildParameters.triple
118119
let allowLinkingAgainstExecutables = (triple.isDarwin() || triple.isLinux() || triple.isWindows()) && self.toolsVersion >= .v5_5
@@ -133,7 +134,7 @@ package final class SwiftTargetBuildDescription {
133134
}
134135

135136
/// Path to the resource Info.plist file, if generated.
136-
package private(set) var resourceBundleInfoPlistPath: AbsolutePath?
137+
public private(set) var resourceBundleInfoPlistPath: AbsolutePath?
137138

138139
/// Paths to the binary libraries the target depends on.
139140
var libraryBinaryPaths: Set<AbsolutePath> = []
@@ -143,7 +144,7 @@ package final class SwiftTargetBuildDescription {
143144

144145
/// Describes the purpose of a test target, including any special roles such as containing a list of discovered
145146
/// tests or serving as the manifest target which contains the main entry point.
146-
package enum TestTargetRole {
147+
public enum TestTargetRole {
147148
/// An ordinary test target, defined explicitly in a package, containing test code.
148149
case `default`
149150

@@ -158,10 +159,10 @@ package final class SwiftTargetBuildDescription {
158159
case entryPoint(isSynthesized: Bool)
159160
}
160161

161-
package let testTargetRole: TestTargetRole?
162+
public let testTargetRole: TestTargetRole?
162163

163164
/// If this target is a test target.
164-
package var isTestTarget: Bool {
165+
public var isTestTarget: Bool {
165166
self.testTargetRole != nil
166167
}
167168

@@ -223,13 +224,13 @@ package final class SwiftTargetBuildDescription {
223224
private(set) var moduleMap: AbsolutePath?
224225

225226
/// The results of applying any build tool plugins to this target.
226-
package let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
227+
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
227228

228229
/// The results of running any prebuild commands for this target.
229-
package let prebuildCommandResults: [PrebuildCommandResult]
230+
public let prebuildCommandResults: [PrebuildCommandResult]
230231

231232
/// Any macro products that this target requires to build.
232-
package let requiredMacroProducts: [ResolvedProduct]
233+
public let requiredMacroProducts: [ResolvedProduct]
233234

234235
/// ObservabilityScope with which to emit diagnostics
235236
private let observabilityScope: ObservabilityScope
@@ -450,7 +451,7 @@ package final class SwiftTargetBuildDescription {
450451
}
451452

452453
/// The arguments needed to compile this target.
453-
package func compileArguments() throws -> [String] {
454+
public func compileArguments() throws -> [String] {
454455
var args = [String]()
455456
args += try self.buildParameters.targetTripleArgs(for: self.target)
456457

@@ -625,7 +626,7 @@ package final class SwiftTargetBuildDescription {
625626

626627
/// When `scanInvocation` argument is set to `true`, omit the side-effect producing arguments
627628
/// such as emitting a module or supplementary outputs.
628-
package func emitCommandLine(scanInvocation: Bool = false) throws -> [String] {
629+
public func emitCommandLine(scanInvocation: Bool = false) throws -> [String] {
629630
var result: [String] = []
630631
result.append(self.buildParameters.toolchain.swiftCompilerPath.pathString)
631632

0 commit comments

Comments
 (0)