Skip to content

[6.0] Restore visibility of APIs that have been made package #7570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream

extension ProgressAnimation {
/// A ninja-like progress animation that adapts to the provided output stream.
package static func ninja(
@_spi(SwiftPMInternal)
public static func ninja(
stream: WritableByteStream,
verbose: Bool
) -> any ProgressAnimationProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import protocol TSCBasic.WritableByteStream

extension ProgressAnimation {
/// A percent-based progress animation that adapts to the provided output stream.
package static func percent(
@_spi(SwiftPMInternal)
public static func percent(
stream: WritableByteStream,
verbose: Bool,
header: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import class TSCBasic.LocalFileOutputByteStream
import protocol TSCBasic.WritableByteStream
import protocol TSCUtility.ProgressAnimationProtocol

package typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol
@_spi(SwiftPMInternal)
public typealias ProgressAnimationProtocol = TSCUtility.ProgressAnimationProtocol

/// Namespace to nest public progress animations under.
package enum ProgressAnimation {
@_spi(SwiftPMInternal)
public enum ProgressAnimation {
/// Dynamically create a progress animation based on the current stream
/// capabilities and desired verbosity.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,27 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
}
}

@_spi(SwiftPMInternal)
extension ProgressAnimationProtocol {
package func throttled<C: Clock>(
@_spi(SwiftPMInternal)
public func throttled<C: Clock>(
now: @escaping () -> C.Instant,
interval: C.Duration,
clock: C.Type = C.self
) -> some ProgressAnimationProtocol {
ThrottledProgressAnimation(self, now: now, interval: interval, clock: clock)
}

package func throttled<C: Clock>(
@_spi(SwiftPMInternal)
public func throttled<C: Clock>(
clock: C,
interval: C.Duration
) -> some ProgressAnimationProtocol {
self.throttled(now: { clock.now }, interval: interval, clock: C.self)
}

package func throttled(
@_spi(SwiftPMInternal)
public func throttled(
interval: ContinuousClock.Duration
) -> some ProgressAnimationProtocol {
self.throttled(clock: ContinuousClock(), interval: interval)
Expand Down
30 changes: 15 additions & 15 deletions Sources/Build/BuildDescription/ClangTargetBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ import struct SPMBuildCore.PrebuildCommandResult
import enum TSCBasic.ProcessEnv

/// Target description for a Clang target i.e. C language family target.
package final class ClangTargetBuildDescription {
public final class ClangTargetBuildDescription {
/// The package this target belongs to.
package let package: ResolvedPackage
public let package: ResolvedPackage

/// The target described by this target.
package let target: ResolvedTarget
public let target: ResolvedTarget

/// The underlying clang target.
package let clangTarget: ClangTarget
public let clangTarget: ClangTarget

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

/// The build parameters.
let buildParameters: BuildParameters
Expand All @@ -47,7 +47,7 @@ package final class ClangTargetBuildDescription {
}

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

Expand All @@ -65,7 +65,7 @@ package final class ClangTargetBuildDescription {
}

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

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

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

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

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

/// If this target is a test target.
package var isTestTarget: Bool {
public var isTestTarget: Bool {
target.type == .test
}

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

/// Create a new target description with target and build parameters.
init(
Expand Down Expand Up @@ -188,7 +188,7 @@ package final class ClangTargetBuildDescription {
}

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

package func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
public func emitCommandLine(for filePath: AbsolutePath) throws -> [String] {
let standards = [
(clangTarget.cxxLanguageStandard, SupportedLanguageExtension.cppExtensions),
(clangTarget.cLanguageStandard, SupportedLanguageExtension.cExtensions),
Expand Down
12 changes: 6 additions & 6 deletions Sources/Build/BuildDescription/PluginDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ import protocol Basics.FileSystem
/// But because the package graph and build plan are not loaded for incremental
/// builds, this information is included in the BuildDescription, and the plugin
/// targets are compiled directly.
package final class PluginDescription: Codable {
public final class PluginDescription: Codable {
/// The identity of the package in which the plugin is defined.
package let package: PackageIdentity
public let package: PackageIdentity

/// The name of the plugin target in that package (this is also the name of
/// the plugin).
package let targetName: String
public let targetName: String

/// The names of any plugin products in that package that vend the plugin
/// to other packages.
package let productNames: [String]
public let productNames: [String]

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

/// Swift source files that comprise the plugin.
package let sources: Sources
public let sources: Sources

/// Initialize a new plugin target description. The target is expected to be
/// a `PluginTarget`.
Expand Down
18 changes: 9 additions & 9 deletions Sources/Build/BuildDescription/ProductBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ import SPMBuildCore
import struct TSCBasic.SortedArray

/// The build description for a product.
package final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription {
/// The reference to the product.
package let package: ResolvedPackage
public let package: ResolvedPackage

/// The reference to the product.
package let product: ResolvedProduct
public let product: ResolvedProduct

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

/// The build parameters.
package let buildParameters: BuildParameters
public let buildParameters: BuildParameters

/// All object files to link into this product.
///
// Computed during build planning.
package internal(set) var objects = SortedArray<AbsolutePath>()
public internal(set) var objects = SortedArray<AbsolutePath>()

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

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

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

extension SortedArray where Element == AbsolutePath {
package static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
public static func +=<S: Sequence>(lhs: inout SortedArray, rhs: S) where S.Iterator.Element == AbsolutePath {
lhs.insert(contentsOf: rhs)
}
}
Expand Down
37 changes: 19 additions & 18 deletions Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PackageGraph
import PackageLoading
import PackageModel

@_spi(SwiftPMInternal)
import SPMBuildCore

#if USE_IMPL_ONLY_IMPORTS
Expand All @@ -28,19 +29,19 @@ import DriverSupport
import struct TSCBasic.ByteString

/// Target description for a Swift target.
package final class SwiftTargetBuildDescription {
public final class SwiftTargetBuildDescription {
/// The package this target belongs to.
package let package: ResolvedPackage
public let package: ResolvedPackage

/// The target described by this target.
package let target: ResolvedTarget
public let target: ResolvedTarget

private let swiftTarget: SwiftTarget

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

/// The build parameters.
let buildParameters: BuildParameters
Expand Down Expand Up @@ -77,22 +78,22 @@ package final class SwiftTargetBuildDescription {
}

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

package var sourcesFileListPath: AbsolutePath {
public var sourcesFileListPath: AbsolutePath {
self.tempsPath.appending(component: "sources")
}

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

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

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

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

/// Paths to the binary libraries the target depends on.
var libraryBinaryPaths: Set<AbsolutePath> = []
Expand All @@ -148,7 +149,7 @@ package final class SwiftTargetBuildDescription {

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

Expand All @@ -163,10 +164,10 @@ package final class SwiftTargetBuildDescription {
case entryPoint(isSynthesized: Bool)
}

package let testTargetRole: TestTargetRole?
public let testTargetRole: TestTargetRole?

/// If this target is a test target.
package var isTestTarget: Bool {
public var isTestTarget: Bool {
self.testTargetRole != nil
}

Expand Down Expand Up @@ -228,13 +229,13 @@ package final class SwiftTargetBuildDescription {
private(set) var moduleMap: AbsolutePath?

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

/// The results of running any prebuild commands for this target.
package let prebuildCommandResults: [PrebuildCommandResult]
public let prebuildCommandResults: [PrebuildCommandResult]

/// Any macro products that this target requires to build.
package let requiredMacroProducts: [ResolvedProduct]
public let requiredMacroProducts: [ResolvedProduct]

/// ObservabilityScope with which to emit diagnostics
private let observabilityScope: ObservabilityScope
Expand Down Expand Up @@ -455,7 +456,7 @@ package final class SwiftTargetBuildDescription {
}

/// The arguments needed to compile this target.
package func compileArguments() throws -> [String] {
public func compileArguments() throws -> [String] {
var args = [String]()
args += try self.buildParameters.targetTripleArgs(for: self.target)
args += ["-swift-version", self.swiftVersion.rawValue]
Expand Down Expand Up @@ -631,7 +632,7 @@ package final class SwiftTargetBuildDescription {

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

Expand Down
Loading