From 4eba6bde1274b02f2dbfb72790103e90b913d3c5 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:45:26 -0400 Subject: [PATCH 01/35] Adopt MemberImportVisiblity - PackageDescription --- Package.swift | 1 + Sources/PackageDescription/PackageDependency.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Package.swift b/Package.swift index 15d291a3eba..592d7877d0a 100644 --- a/Package.swift +++ b/Package.swift @@ -153,6 +153,7 @@ let package = Package( name: "PackageDescription", exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .define("USE_IMPL_ONLY_IMPORTS"), .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), diff --git a/Sources/PackageDescription/PackageDependency.swift b/Sources/PackageDescription/PackageDependency.swift index 60dbe1f426d..594736e558c 100644 --- a/Sources/PackageDescription/PackageDependency.swift +++ b/Sources/PackageDescription/PackageDependency.swift @@ -10,6 +10,11 @@ // //===----------------------------------------------------------------------===// +#if USE_IMPL_ONLY_IMPORTS +@_implementationOnly import Foundation +#else +import Foundation +#endif extension Package { /// A package dependency of a Swift package. From ac025bcc755e0efe6c0374218cbba05305bf8474 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:48:23 -0400 Subject: [PATCH 02/35] Adopt MemberImportVisiblity - AppleProductTypes --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 592d7877d0a..e34b832edce 100644 --- a/Package.swift +++ b/Package.swift @@ -171,6 +171,7 @@ let package = Package( // messing with the manifest loader. dependencies: ["PackageDescription"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"], .when(platforms: [.macOS])), .unsafeFlags(["-Xfrontend", "-module-link-name", "-Xfrontend", "AppleProductTypes"]) From 5066e93182139ac9973bcf9a5ae344d69d4660b4 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:51:58 -0400 Subject: [PATCH 03/35] Adopt MemberImportVisiblity - PackagePlugin --- Package.swift | 1 + Sources/PackagePlugin/Utilities.swift | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Package.swift b/Package.swift index e34b832edce..e5a3bffbf57 100644 --- a/Package.swift +++ b/Package.swift @@ -184,6 +184,7 @@ let package = Package( name: "PackagePlugin", exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), ], diff --git a/Sources/PackagePlugin/Utilities.swift b/Sources/PackagePlugin/Utilities.swift index 9c4e4d0c35d..d84382d8139 100644 --- a/Sources/PackagePlugin/Utilities.swift +++ b/Sources/PackagePlugin/Utilities.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import Foundation + extension Package { /// The list of targets matching the given names. Throws an error if any of /// the targets cannot be found. From 9b6cd6851d1a606c6ae5f77b6bd48f9e46aaee9e Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:53:22 -0400 Subject: [PATCH 04/35] Adopt MemberImportVisiblity - SourceKitLSPAPI --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index e5a3bffbf57..5f117cc9de2 100644 --- a/Package.swift +++ b/Package.swift @@ -203,6 +203,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .enableExperimentalFeature("AccessLevelOnImport"), .unsafeFlags(["-static"]), ] From 8269986afac7dc2256d1d026fd69ca8e4765deb6 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:54:23 -0400 Subject: [PATCH 05/35] Adopt MemberImportVisiblity - _AsyncFileSystem --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 5f117cc9de2..fb28e662680 100644 --- a/Package.swift +++ b/Package.swift @@ -220,6 +220,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .enableExperimentalFeature("StrictConcurrency"), .enableExperimentalFeature("AccessLevelOnImport"), .enableExperimentalFeature("InternalImportsByDefault"), From decb07a6d82f5ea6c2dd958358bb00d86db300fb Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 20:58:47 -0400 Subject: [PATCH 06/35] Adopt MemberImportVisiblity - Basics --- Package.swift | 1 + Sources/Basics/AuthorizationProvider.swift | 1 + Sources/Basics/Collections/Dictionary+Extensions.swift | 2 ++ .../Basics/ProgressAnimation/ThrottledProgressAnimation.swift | 1 + Sources/Basics/SQLite.swift | 1 + Sources/Basics/Triple+Basics.swift | 1 + 6 files changed, 7 insertions(+) diff --git a/Package.swift b/Package.swift index fb28e662680..92d31724a9a 100644 --- a/Package.swift +++ b/Package.swift @@ -241,6 +241,7 @@ let package = Package( ], exclude: ["CMakeLists.txt", "Vendor/README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .enableExperimentalFeature("StrictConcurrency"), .enableExperimentalFeature("AccessLevelOnImport"), .unsafeFlags(["-static"]), diff --git a/Sources/Basics/AuthorizationProvider.swift b/Sources/Basics/AuthorizationProvider.swift index 5dcdbd3255d..85e7b1a7c51 100644 --- a/Sources/Basics/AuthorizationProvider.swift +++ b/Sources/Basics/AuthorizationProvider.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +import TSCBasic import struct Foundation.Data import struct Foundation.Date import struct Foundation.URL diff --git a/Sources/Basics/Collections/Dictionary+Extensions.swift b/Sources/Basics/Collections/Dictionary+Extensions.swift index f31e0b57104..f08ff1d15ee 100644 --- a/Sources/Basics/Collections/Dictionary+Extensions.swift +++ b/Sources/Basics/Collections/Dictionary+Extensions.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import TSCBasic + extension Dictionary { @inlinable @discardableResult diff --git a/Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift b/Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift index 30f006c873a..b5b3597f15c 100644 --- a/Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift +++ b/Sources/Basics/ProgressAnimation/ThrottledProgressAnimation.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import _Concurrency +import TSCUtility /// A progress animation wrapper that throttles updates to a given interval. final class ThrottledProgressAnimation: ProgressAnimationProtocol { diff --git a/Sources/Basics/SQLite.swift b/Sources/Basics/SQLite.swift index 803490b4865..cab2374f3c3 100644 --- a/Sources/Basics/SQLite.swift +++ b/Sources/Basics/SQLite.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +import TSCBasic import Foundation #if SWIFT_PACKAGE && (os(Windows) || os(Android)) diff --git a/Sources/Basics/Triple+Basics.swift b/Sources/Basics/Triple+Basics.swift index 8247465475f..9773457033b 100644 --- a/Sources/Basics/Triple+Basics.swift +++ b/Sources/Basics/Triple+Basics.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +import TSCUtility import enum TSCBasic.JSON extension Triple { From a0466070f7f1b3a0d577505441fafa679354e343 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:03:11 -0400 Subject: [PATCH 07/35] Adopt MemberImportVisiblity - LLBuildManifest --- Package.swift | 1 + Sources/LLBuildManifest/LLBuildManifest.swift | 50 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Package.swift b/Package.swift index 92d31724a9a..e526ff4e832 100644 --- a/Package.swift +++ b/Package.swift @@ -254,6 +254,7 @@ let package = Package( dependencies: ["Basics"], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/LLBuildManifest/LLBuildManifest.swift b/Sources/LLBuildManifest/LLBuildManifest.swift index cc0cd4b74e0..520db084769 100644 --- a/Sources/LLBuildManifest/LLBuildManifest.swift +++ b/Sources/LLBuildManifest/LLBuildManifest.swift @@ -12,6 +12,8 @@ import Basics import Foundation +import TSCBasic +import TSCUtility import class Basics.AsyncProcess @@ -59,7 +61,7 @@ public enum WriteAuxiliary { public static let name = "link-file-list" // FIXME: We should extend the `InProcessTool` support to allow us to specify these in a typed way, but today we have to flatten all the inputs into a generic `Node` array (rdar://109844243). - public static func computeInputs(objects: [AbsolutePath]) -> [Node] { + public static func computeInputs(objects: [Basics.AbsolutePath]) -> [Node] { return [.virtual(Self.name)] + objects.map { Node.file($0) } } @@ -88,7 +90,7 @@ public enum WriteAuxiliary { public struct SourcesFileList: AuxiliaryFileType { public static let name = "sources-file-list" - public static func computeInputs(sources: [AbsolutePath]) -> [Node] { + public static func computeInputs(sources: [Basics.AbsolutePath]) -> [Node] { return [.virtual(Self.name)] + sources.map { Node.file($0) } } @@ -114,7 +116,7 @@ public enum WriteAuxiliary { public struct SwiftGetVersion: AuxiliaryFileType { public static let name = "swift-get-version" - public static func computeInputs(swiftCompilerPath: AbsolutePath) -> [Node] { + public static func computeInputs(swiftCompilerPath: Basics.AbsolutePath) -> [Node] { return [.virtual(Self.name), .file(swiftCompilerPath)] } @@ -122,7 +124,7 @@ public enum WriteAuxiliary { guard let swiftCompilerPathString = inputs.first(where: { $0.kind == .file })?.name else { throw Error.unknownSwiftCompilerPath } - let swiftCompilerPath = try AbsolutePath(validating: swiftCompilerPathString) + let swiftCompilerPath = try Basics.AbsolutePath(validating: swiftCompilerPathString) return try AsyncProcess.checkNonZeroExit(args: swiftCompilerPath.pathString, "-version") } @@ -164,7 +166,7 @@ public enum WriteAuxiliary { public struct EmbeddedResources: AuxiliaryFileType { public static let name = "embedded-resources" - public static func computeInputs(resources: [AbsolutePath]) -> [Node] { + public static func computeInputs(resources: [Basics.AbsolutePath]) -> [Node] { return [.virtual(Self.name)] + resources.map { Node.file($0) } } @@ -178,7 +180,7 @@ public enum WriteAuxiliary { """ for input in inputs where input.kind == .file { - let resourcePath = try AbsolutePath(validating: input.name) + let resourcePath = try Basics.AbsolutePath(validating: input.name) let variableName = resourcePath.basename.spm_mangledToC99ExtendedIdentifier() let fileContent = try Data(contentsOf: URL(fileURLWithPath: resourcePath.pathString)).map { String($0) }.joined(separator: ",") @@ -267,7 +269,7 @@ public struct LLBuildManifest { addCommand(name: name, tool: tool) } - public mutating func addEntitlementPlistCommand(entitlement: String, outputPath: AbsolutePath) { + public mutating func addEntitlementPlistCommand(entitlement: String, outputPath: Basics.AbsolutePath) { let inputs = WriteAuxiliary.EntitlementPlist.computeInputs(entitlement: entitlement) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: outputPath) let name = outputPath.pathString @@ -275,8 +277,8 @@ public struct LLBuildManifest { } public mutating func addWriteLinkFileListCommand( - objects: [AbsolutePath], - linkFileListPath: AbsolutePath + objects: [Basics.AbsolutePath], + linkFileListPath: Basics.AbsolutePath ) { let inputs = WriteAuxiliary.LinkFileList.computeInputs(objects: objects) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: linkFileListPath) @@ -285,8 +287,8 @@ public struct LLBuildManifest { } public mutating func addWriteSourcesFileListCommand( - sources: [AbsolutePath], - sourcesFileListPath: AbsolutePath + sources: [Basics.AbsolutePath], + sourcesFileListPath: Basics.AbsolutePath ) { let inputs = WriteAuxiliary.SourcesFileList.computeInputs(sources: sources) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: sourcesFileListPath) @@ -295,8 +297,8 @@ public struct LLBuildManifest { } public mutating func addSwiftGetVersionCommand( - swiftCompilerPath: AbsolutePath, - swiftVersionFilePath: AbsolutePath + swiftCompilerPath: Basics.AbsolutePath, + swiftVersionFilePath: Basics.AbsolutePath ) { let inputs = WriteAuxiliary.SwiftGetVersion.computeInputs(swiftCompilerPath: swiftCompilerPath) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: swiftVersionFilePath, alwaysOutOfDate: true) @@ -304,7 +306,7 @@ public struct LLBuildManifest { addCommand(name: name, tool: tool) } - public mutating func addWriteInfoPlistCommand(principalClass: String, outputPath: AbsolutePath) { + public mutating func addWriteInfoPlistCommand(principalClass: String, outputPath: Basics.AbsolutePath) { let inputs = WriteAuxiliary.XCTestInfoPlist.computeInputs(principalClass: principalClass) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: outputPath) let name = outputPath.pathString @@ -312,8 +314,8 @@ public struct LLBuildManifest { } public mutating func addWriteEmbeddedResourcesCommand( - resources: [AbsolutePath], - outputPath: AbsolutePath + resources: [Basics.AbsolutePath], + outputPath: Basics.AbsolutePath ) { let inputs = WriteAuxiliary.EmbeddedResources.computeInputs(resources: resources) let tool = WriteAuxiliaryFile(inputs: inputs, outputFilePath: outputPath) @@ -393,19 +395,19 @@ public struct LLBuildManifest { name: String, inputs: [Node], outputs: [Node], - executable: AbsolutePath, + executable: Basics.AbsolutePath, moduleName: String, moduleAliases: [String: String]?, - moduleOutputPath: AbsolutePath, - importPath: AbsolutePath, - tempsPath: AbsolutePath, - objects: [AbsolutePath], + moduleOutputPath: Basics.AbsolutePath, + importPath: Basics.AbsolutePath, + tempsPath: Basics.AbsolutePath, + objects: [Basics.AbsolutePath], otherArguments: [String], - sources: [AbsolutePath], - fileList: AbsolutePath, + sources: [Basics.AbsolutePath], + fileList: Basics.AbsolutePath, isLibrary: Bool, wholeModuleOptimization: Bool, - outputFileMapPath: AbsolutePath, + outputFileMapPath: Basics.AbsolutePath, prepareForIndexing: Bool ) { let tool = SwiftCompilerTool( From 28bfbc62fbb314eabe033b79a51f788e42eafe70 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:09:40 -0400 Subject: [PATCH 08/35] Adopt MemberImportVisiblity - PackageRegistry --- Package.swift | 1 + Sources/PackageRegistry/ChecksumTOFU.swift | 1 + .../RegistryDownloadsManager.swift | 29 ++++++++++--------- .../PackageRegistry/SignatureValidation.swift | 3 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Package.swift b/Package.swift index e526ff4e832..432bd77c761 100644 --- a/Package.swift +++ b/Package.swift @@ -271,6 +271,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageRegistry/ChecksumTOFU.swift b/Sources/PackageRegistry/ChecksumTOFU.swift index 81eef2d4ec4..137d3326bc9 100644 --- a/Sources/PackageRegistry/ChecksumTOFU.swift +++ b/Sources/PackageRegistry/ChecksumTOFU.swift @@ -16,6 +16,7 @@ import Dispatch import Basics import PackageFingerprint import PackageModel +import Foundation import struct TSCUtility.Version diff --git a/Sources/PackageRegistry/RegistryDownloadsManager.swift b/Sources/PackageRegistry/RegistryDownloadsManager.swift index 307d9c0c0c2..cbe33d03aa3 100644 --- a/Sources/PackageRegistry/RegistryDownloadsManager.swift +++ b/Sources/PackageRegistry/RegistryDownloadsManager.swift @@ -16,6 +16,7 @@ import Dispatch import Foundation import PackageLoading import PackageModel +import TSCBasic import struct TSCUtility.Version @@ -23,8 +24,8 @@ public class RegistryDownloadsManager: AsyncCancellable { public typealias Delegate = RegistryDownloadsManagerDelegate private let fileSystem: FileSystem - private let path: AbsolutePath - private let cachePath: AbsolutePath? + private let path: Basics.AbsolutePath + private let cachePath: Basics.AbsolutePath? private let registryClient: RegistryClient private let delegate: Delegate? @@ -33,13 +34,13 @@ public class RegistryDownloadsManager: AsyncCancellable { let version: Version } - private var pendingLookups = [PackageLookup: Task]() + private var pendingLookups = [PackageLookup: Task]() private var pendingLookupsLock = NSLock() public init( fileSystem: FileSystem, - path: AbsolutePath, - cachePath: AbsolutePath?, + path: Basics.AbsolutePath, + cachePath: Basics.AbsolutePath?, registryClient: RegistryClient, delegate: Delegate? ) { @@ -55,9 +56,9 @@ public class RegistryDownloadsManager: AsyncCancellable { version: Version, observabilityScope: ObservabilityScope, delegateQueue: DispatchQueue - ) async throws -> AbsolutePath { - let packageRelativePath: RelativePath - let packagePath: AbsolutePath + ) async throws -> Basics.AbsolutePath { + let packageRelativePath: Basics.RelativePath + let packagePath: Basics.AbsolutePath packageRelativePath = try package.downloadPath(version: version) packagePath = self.path.appending(packageRelativePath) @@ -127,7 +128,7 @@ public class RegistryDownloadsManager: AsyncCancellable { observabilityScope: ObservabilityScope, delegateQueue: DispatchQueue, callbackQueue: DispatchQueue, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { callbackQueue.asyncResult(completion) { try await self.lookup( @@ -147,7 +148,7 @@ public class RegistryDownloadsManager: AsyncCancellable { private func downloadAndPopulateCache( package: PackageIdentity, version: Version, - packagePath: AbsolutePath, + packagePath: Basics.AbsolutePath, observabilityScope: ObservabilityScope, delegateQueue: DispatchQueue ) async throws -> FetchDetails { @@ -302,7 +303,7 @@ public class RegistryDownloadsManager: AsyncCancellable { } } - private func initializeCacheIfNeeded(cachePath: AbsolutePath) throws { + private func initializeCacheIfNeeded(cachePath: Basics.AbsolutePath) throws { if !self.fileSystem.exists(cachePath) { try self.fileSystem.createDirectory(cachePath, recursive: true) } @@ -345,7 +346,7 @@ extension RegistryDownloadsManager { } extension FileSystem { - func validPackageDirectory(_ path: AbsolutePath) throws -> Bool { + func validPackageDirectory(_ path: Basics.AbsolutePath) throws -> Bool { if !self.exists(path) { return false } @@ -354,14 +355,14 @@ extension FileSystem { } extension PackageIdentity { - internal func downloadPath() throws -> RelativePath { + internal func downloadPath() throws -> Basics.RelativePath { guard let registryIdentity = self.registry else { throw StringError("invalid package identifier \(self), expected registry scope and name") } return try RelativePath(validating: registryIdentity.scope.description).appending(component: registryIdentity.name.description) } - internal func downloadPath(version: Version) throws -> RelativePath { + internal func downloadPath(version: Version) throws -> Basics.RelativePath { try self.downloadPath().appending(component: version.description) } } diff --git a/Sources/PackageRegistry/SignatureValidation.swift b/Sources/PackageRegistry/SignatureValidation.swift index 8e1631dd53c..bf5169ff138 100644 --- a/Sources/PackageRegistry/SignatureValidation.swift +++ b/Sources/PackageRegistry/SignatureValidation.swift @@ -18,6 +18,7 @@ import Basics import PackageLoading import PackageModel import PackageSigning +import TSCBasic import struct TSCUtility.Version @@ -590,7 +591,7 @@ extension VerifierConfiguration { // Load trusted roots from configured directory if let trustedRootsDirectoryPath = configuration.trustedRootCertificatesPath { - let trustedRootsDirectory: AbsolutePath + let trustedRootsDirectory: Basics.AbsolutePath do { trustedRootsDirectory = try AbsolutePath(validating: trustedRootsDirectoryPath) } catch { From 562eb1cb46f5ef7ddae9d991797f8243a6f9c636 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:13:40 -0400 Subject: [PATCH 09/35] Adopt MemberImportVisiblity - SourceControl --- Package.swift | 1 + Sources/SourceControl/RepositoryManager.swift | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Package.swift b/Package.swift index 432bd77c761..5e85c9c5534 100644 --- a/Package.swift +++ b/Package.swift @@ -285,6 +285,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/SourceControl/RepositoryManager.swift b/Sources/SourceControl/RepositoryManager.swift index d408d044b62..ae5a6d26fa2 100644 --- a/Sources/SourceControl/RepositoryManager.swift +++ b/Sources/SourceControl/RepositoryManager.swift @@ -15,16 +15,17 @@ import _Concurrency import Dispatch import Foundation import PackageModel +import TSCBasic /// Manages a collection of bare repositories. public class RepositoryManager: Cancellable { public typealias Delegate = RepositoryManagerDelegate /// The path under which repositories are stored. - public let path: AbsolutePath + public let path: Basics.AbsolutePath /// The path to the directory where all cached git repositories are stored. - private let cachePath: AbsolutePath? + private let cachePath: Basics.AbsolutePath? // used in tests to disable skipping of local packages. private let cacheLocalPackages: Bool @@ -67,9 +68,9 @@ public class RepositoryManager: Cancellable { /// - delegate: The repository manager delegate. public init( fileSystem: FileSystem, - path: AbsolutePath, + path: Basics.AbsolutePath, provider: RepositoryProvider, - cachePath: AbsolutePath? = .none, + cachePath: Basics.AbsolutePath? = .none, cacheLocalPackages: Bool = false, maxConcurrentOperations: Int? = .none, initializationWarningHandler: (String) -> Void, @@ -306,7 +307,7 @@ public class RepositoryManager: Cancellable { private func fetchAndPopulateCache( package: PackageIdentity, handle: RepositoryHandle, - repositoryPath: AbsolutePath, + repositoryPath: Basics.AbsolutePath, updateStrategy: RepositoryUpdateStrategy, observabilityScope: ObservabilityScope, delegateQueue: DispatchQueue @@ -408,7 +409,7 @@ public class RepositoryManager: Cancellable { } /// Open a working copy checkout at a path - public func openWorkingCopy(at path: AbsolutePath) throws -> WorkingCheckout { + public func openWorkingCopy(at path: Basics.AbsolutePath) throws -> WorkingCheckout { try self.provider.openWorkingCopy(at: path) } @@ -430,7 +431,7 @@ public class RepositoryManager: Cancellable { /// Create a working copy of the repository from a handle. private func createWorkingCopy( _ handle: RepositoryHandle, - at destinationPath: AbsolutePath, + at destinationPath: Basics.AbsolutePath, editable: Bool ) throws -> WorkingCheckout { try self.provider.createWorkingCopy( @@ -448,12 +449,12 @@ public class RepositoryManager: Cancellable { } /// Returns true if the directory is valid git location. - public func isValidDirectory(_ directory: AbsolutePath) throws -> Bool { + public func isValidDirectory(_ directory: Basics.AbsolutePath) throws -> Bool { try self.provider.isValidDirectory(directory) } /// Returns true if the directory is valid git location for the specified repository - public func isValidDirectory(_ directory: AbsolutePath, for repository: RepositorySpecifier) throws -> Bool { + public func isValidDirectory(_ directory: Basics.AbsolutePath, for repository: RepositorySpecifier) throws -> Bool { try self.provider.isValidDirectory(directory, for: repository) } @@ -472,7 +473,7 @@ public class RepositoryManager: Cancellable { } /// Sets up the cache directories if they don't already exist. - private func initializeCacheIfNeeded(cachePath: AbsolutePath) throws { + private func initializeCacheIfNeeded(cachePath: Basics.AbsolutePath) throws { // Create the supplied cache directory. if !self.fileSystem.exists(cachePath) { try self.fileSystem.createDirectory(cachePath, recursive: true) @@ -526,10 +527,10 @@ extension RepositoryManager { /// /// This is intentionally hidden from the clients so that the manager is /// allowed to move repositories transparently. - fileprivate let subpath: RelativePath + fileprivate let subpath: Basics.RelativePath /// Create a handle. - fileprivate init(manager: RepositoryManager, repository: RepositorySpecifier, subpath: RelativePath) { + fileprivate init(manager: RepositoryManager, repository: RepositorySpecifier, subpath: Basics.RelativePath) { self.manager = manager self.repository = repository self.subpath = subpath @@ -547,7 +548,7 @@ extension RepositoryManager { /// expected to be non-existent when called. /// /// - editable: The clone is expected to be edited by user. - public func createWorkingCopy(at path: AbsolutePath, editable: Bool) throws -> WorkingCheckout { + public func createWorkingCopy(at path: Basics.AbsolutePath, editable: Bool) throws -> WorkingCheckout { return try self.manager.createWorkingCopy(self, at: path, editable: editable) } } @@ -596,7 +597,7 @@ extension RepositoryManager.RepositoryHandle: CustomStringConvertible { extension RepositorySpecifier { // relative path where the repository should be stored - internal func storagePath() throws -> RelativePath { + internal func storagePath() throws -> Basics.RelativePath { return try RelativePath(validating: self.fileSystemIdentifier) } From bda8eec2d11deb32912f7a810b5ec14a22bb2df1 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:14:41 -0400 Subject: [PATCH 10/35] Adopt MemberImportVisiblity - SPMLLBuild --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 5e85c9c5534..158038139db 100644 --- a/Package.swift +++ b/Package.swift @@ -296,6 +296,7 @@ let package = Package( dependencies: ["Basics"], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), From faa3b49c110495aa5eb64f13f67f734d926c35cc Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:33:22 -0400 Subject: [PATCH 11/35] Adopt MemberImportVisiblity - PackageModel --- Package.swift | 1 + .../ArtifactsArchiveMetadata.swift | 7 +- .../MinimumDeploymentTarget.swift | 12 +- Sources/PackageModel/Module/ClangModule.swift | 15 +-- Sources/PackageModel/Module/Module.swift | 1 + .../PackageModel/Module/PluginModule.swift | 2 + Sources/PackageModel/PackageIdentity.swift | 5 +- .../PackageModel/Snippets/Model/Snippet.swift | 1 + Sources/PackageModel/SwiftSDKs/SwiftSDK.swift | 113 +++++++++--------- Sources/PackageModel/UserToolchain.swift | 17 +-- 10 files changed, 93 insertions(+), 81 deletions(-) diff --git a/Package.swift b/Package.swift index 158038139db..a94aeab0536 100644 --- a/Package.swift +++ b/Package.swift @@ -309,6 +309,7 @@ let package = Package( dependencies: ["Basics"], exclude: ["CMakeLists.txt", "README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageModel/ArtifactsArchiveMetadata.swift b/Sources/PackageModel/ArtifactsArchiveMetadata.swift index b76333ae4a0..1c07c2ed035 100644 --- a/Sources/PackageModel/ArtifactsArchiveMetadata.swift +++ b/Sources/PackageModel/ArtifactsArchiveMetadata.swift @@ -12,6 +12,7 @@ import Basics import Foundation +import TSCBasic import struct TSCUtility.Version @@ -51,10 +52,10 @@ public struct ArtifactsArchiveMetadata: Equatable { } public struct Variant: Equatable { - public let path: RelativePath + public let path: Basics.RelativePath public let supportedTriples: [Triple]? - public init(path: RelativePath, supportedTriples: [Triple]?) { + public init(path: Basics.RelativePath, supportedTriples: [Triple]?) { self.path = path self.supportedTriples = supportedTriples } @@ -62,7 +63,7 @@ public struct ArtifactsArchiveMetadata: Equatable { } extension ArtifactsArchiveMetadata { - public static func parse(fileSystem: FileSystem, rootPath: AbsolutePath) throws -> ArtifactsArchiveMetadata { + public static func parse(fileSystem: FileSystem, rootPath: Basics.AbsolutePath) throws -> ArtifactsArchiveMetadata { let path = rootPath.appending("info.json") guard fileSystem.exists(path) else { throw StringError("ArtifactsArchive info.json not found at '\(rootPath)'") diff --git a/Sources/PackageModel/MinimumDeploymentTarget.swift b/Sources/PackageModel/MinimumDeploymentTarget.swift index 77f507f0345..d2510e323ce 100644 --- a/Sources/PackageModel/MinimumDeploymentTarget.swift +++ b/Sources/PackageModel/MinimumDeploymentTarget.swift @@ -11,12 +11,14 @@ //===----------------------------------------------------------------------===// import Basics +import Foundation +import TSCUtility import class Basics.AsyncProcess public struct MinimumDeploymentTarget { private struct MinimumDeploymentTargetKey: Hashable { - let binaryPath: AbsolutePath + let binaryPath: Basics.AbsolutePath let platform: PackageModel.Platform } @@ -28,7 +30,7 @@ public struct MinimumDeploymentTarget { private init() { } - public func computeMinimumDeploymentTarget(of binaryPath: AbsolutePath, platform: PackageModel.Platform) throws -> PlatformVersion { + public func computeMinimumDeploymentTarget(of binaryPath: Basics.AbsolutePath, platform: PackageModel.Platform) throws -> PlatformVersion { try self.minimumDeploymentTargets.memoize(MinimumDeploymentTargetKey(binaryPath: binaryPath, platform: platform)) { return try Self.computeMinimumDeploymentTarget(of: binaryPath, platform: platform) ?? platform.oldestSupportedVersion } @@ -40,7 +42,7 @@ public struct MinimumDeploymentTarget { } } - static func computeMinimumDeploymentTarget(of binaryPath: AbsolutePath, platform: PackageModel.Platform) throws -> PlatformVersion? { + static func computeMinimumDeploymentTarget(of binaryPath: Basics.AbsolutePath, platform: PackageModel.Platform) throws -> PlatformVersion? { guard let (_, platformName) = platform.sdkNameAndPlatform else { return nil } @@ -58,8 +60,8 @@ public struct MinimumDeploymentTarget { static func computeXCTestMinimumDeploymentTarget(with runResult: AsyncProcessResult, platform: PackageModel.Platform) throws -> PlatformVersion? { guard let output = try runResult.utf8Output().spm_chuzzle() else { return nil } - let sdkPath = try AbsolutePath(validating: output) - let xcTestPath = try AbsolutePath(validating: "Developer/Library/Frameworks/XCTest.framework/XCTest", relativeTo: sdkPath) + let sdkPath = try Basics.AbsolutePath(validating: output) + let xcTestPath = try Basics.AbsolutePath(validating: "Developer/Library/Frameworks/XCTest.framework/XCTest", relativeTo: sdkPath) return try computeMinimumDeploymentTarget(of: xcTestPath, platform: platform) } diff --git a/Sources/PackageModel/Module/ClangModule.swift b/Sources/PackageModel/Module/ClangModule.swift index f1506aeb15e..bf066a6ecea 100644 --- a/Sources/PackageModel/Module/ClangModule.swift +++ b/Sources/PackageModel/Module/ClangModule.swift @@ -12,6 +12,7 @@ import struct Basics.AbsolutePath import struct Basics.StringError +import TSCBasic @available(*, deprecated, renamed: "ClangModule") public typealias ClangTarget = ClangModule @@ -24,7 +25,7 @@ public final class ClangModule: Module { public static let defaultPublicHeadersComponent = "include" /// The path to include directory. - public let includeDir: AbsolutePath + public let includeDir: Basics.AbsolutePath /// The target's module map type, which determines whether this target vends a custom module map, a generated module map, or no module map at all. public let moduleMapType: ModuleMapType @@ -32,7 +33,7 @@ public final class ClangModule: Module { /// The headers present in the target. /// /// Note that this contains both public and non-public headers. - public let headers: [AbsolutePath] + public let headers: [Basics.AbsolutePath] /// True if this is a C++ target. public let isCXX: Bool @@ -48,15 +49,15 @@ public final class ClangModule: Module { potentialBundleName: String? = nil, cLanguageStandard: String?, cxxLanguageStandard: String?, - includeDir: AbsolutePath, + includeDir: Basics.AbsolutePath, moduleMapType: ModuleMapType, - headers: [AbsolutePath] = [], + headers: [Basics.AbsolutePath] = [], type: Kind, - path: AbsolutePath, + path: Basics.AbsolutePath, sources: Sources, resources: [Resource] = [], - ignored: [AbsolutePath] = [], - others: [AbsolutePath] = [], + ignored: [Basics.AbsolutePath] = [], + others: [Basics.AbsolutePath] = [], dependencies: [Module.Dependency] = [], buildSettings: BuildSettings.AssignmentTable = .init(), buildSettingsDescription: [TargetBuildSettingDescription.Setting] = [], diff --git a/Sources/PackageModel/Module/Module.swift b/Sources/PackageModel/Module/Module.swift index 023033344f2..786e99de9f3 100644 --- a/Sources/PackageModel/Module/Module.swift +++ b/Sources/PackageModel/Module/Module.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Basics +import TSCUtility @available(*, deprecated, renamed: "Module") public typealias Target = Module diff --git a/Sources/PackageModel/Module/PluginModule.swift b/Sources/PackageModel/Module/PluginModule.swift index 374d7be036b..94c5d8eed1c 100644 --- a/Sources/PackageModel/Module/PluginModule.swift +++ b/Sources/PackageModel/Module/PluginModule.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import Basics + @available(*, deprecated, renamed: "PluginModule") public typealias PluginTarget = PluginModule diff --git a/Sources/PackageModel/PackageIdentity.swift b/Sources/PackageModel/PackageIdentity.swift index eee8b9538a4..bbc1b248694 100644 --- a/Sources/PackageModel/PackageIdentity.swift +++ b/Sources/PackageModel/PackageIdentity.swift @@ -12,6 +12,7 @@ import Basics import Foundation +import TSCBasic /// The canonical identifier for a package, based on its source location. public struct PackageIdentity: CustomStringConvertible, Sendable { @@ -39,7 +40,7 @@ public struct PackageIdentity: CustomStringConvertible, Sendable { /// Creates a package identity from a file path. /// - Parameter path: An absolute path to the package. - public init(path: AbsolutePath) { + public init(path: Basics.AbsolutePath) { self.description = PackageIdentityParser(path.pathString).description } @@ -310,7 +311,7 @@ struct PackageIdentityParser { } /// Compute the default name of a package given its path. - public static func computeDefaultName(fromPath path: AbsolutePath) -> String { + public static func computeDefaultName(fromPath path: Basics.AbsolutePath) -> String { Self.computeDefaultName(fromLocation: path.pathString) } diff --git a/Sources/PackageModel/Snippets/Model/Snippet.swift b/Sources/PackageModel/Snippets/Model/Snippet.swift index d44e8753d31..a74e3d92650 100644 --- a/Sources/PackageModel/Snippets/Model/Snippet.swift +++ b/Sources/PackageModel/Snippets/Model/Snippet.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Basics +import Foundation public struct Snippet { public var path: AbsolutePath diff --git a/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift b/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift index 066d29c1147..aacfad57428 100644 --- a/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift +++ b/Sources/PackageModel/SwiftSDKs/SwiftSDK.swift @@ -12,6 +12,7 @@ import Basics import Foundation +import TSCBasic import class Basics.AsyncProcess @@ -20,7 +21,7 @@ import struct TSCUtility.Version /// Errors related to Swift SDKs. public enum SwiftSDKError: Swift.Error { /// A bundle archive should contain at least one directory with the `.artifactbundle` extension. - case invalidBundleArchive(AbsolutePath) + case invalidBundleArchive(Basics.AbsolutePath) /// A passed argument is neither a valid file system path nor a URL. case invalidPathOrURL(String) @@ -41,10 +42,10 @@ public enum SwiftSDKError: Swift.Error { case invalidBundleName(String) /// No valid Swift SDKs were decoded from a metadata file. - case noSwiftSDKDecoded(AbsolutePath) + case noSwiftSDKDecoded(Basics.AbsolutePath) /// Path used for storing Swift SDK configuration data is not a directory. - case pathIsNotDirectory(AbsolutePath) + case pathIsNotDirectory(Basics.AbsolutePath) /// Swift SDK metadata couldn't be serialized with the latest serialization schema, potentially because it /// was deserialized from an earlier incompatible schema version or initialized manually with properties @@ -63,7 +64,7 @@ public enum SwiftSDKError: Swift.Error { #if os(macOS) /// Quarantine attribute should be removed by the `xattr` command from an installed bundle. - case quarantineAttributePresent(bundlePath: AbsolutePath) + case quarantineAttributePresent(bundlePath: Basics.AbsolutePath) #endif } @@ -191,7 +192,7 @@ public struct SwiftSDK: Equatable { /// Root directory path of the SDK used to compile for the target triple. @available(*, deprecated, message: "use `pathsConfiguration.sdkRootPath` instead") - public var sdk: AbsolutePath? { + public var sdk: Basics.AbsolutePath? { get { sdkRootDir } @@ -202,7 +203,7 @@ public struct SwiftSDK: Equatable { /// Root directory path of the SDK used to compile for the target triple. @available(*, deprecated, message: "use `pathsConfiguration.sdkRootPath` instead") - public var sdkRootDir: AbsolutePath? { + public var sdkRootDir: Basics.AbsolutePath? { get { pathsConfiguration.sdkRootPath } @@ -213,13 +214,13 @@ public struct SwiftSDK: Equatable { /// Path to a directory containing the toolchain (compilers/linker) to be used for the compilation. @available(*, deprecated, message: "use `toolset.rootPaths` instead") - public var binDir: AbsolutePath { + public var binDir: Basics.AbsolutePath { toolchainBinDir } /// Path to a directory containing the toolchain (compilers/linker) to be used for the compilation. @available(*, deprecated, message: "use `toolset.rootPaths` instead") - public var toolchainBinDir: AbsolutePath { + public var toolchainBinDir: Basics.AbsolutePath { toolset.rootPaths[0] } @@ -260,12 +261,12 @@ public struct SwiftSDK: Equatable { public struct PathsConfiguration: Equatable { public init( - sdkRootPath: AbsolutePath?, - swiftResourcesPath: AbsolutePath? = nil, - swiftStaticResourcesPath: AbsolutePath? = nil, - includeSearchPaths: [AbsolutePath]? = nil, - librarySearchPaths: [AbsolutePath]? = nil, - toolsetPaths: [AbsolutePath]? = nil + sdkRootPath: Basics.AbsolutePath?, + swiftResourcesPath: Basics.AbsolutePath? = nil, + swiftStaticResourcesPath: Basics.AbsolutePath? = nil, + includeSearchPaths: [Basics.AbsolutePath]? = nil, + librarySearchPaths: [Basics.AbsolutePath]? = nil, + toolsetPaths: [Basics.AbsolutePath]? = nil ) { self.sdkRootPath = sdkRootPath self.swiftResourcesPath = swiftResourcesPath @@ -276,22 +277,22 @@ public struct SwiftSDK: Equatable { } /// Root directory path of the SDK used to compile for the target triple. - public var sdkRootPath: AbsolutePath? + public var sdkRootPath: Basics.AbsolutePath? /// Path containing Swift resources for dynamic linking. - public var swiftResourcesPath: AbsolutePath? + public var swiftResourcesPath: Basics.AbsolutePath? /// Path containing Swift resources for static linking. - public var swiftStaticResourcesPath: AbsolutePath? + public var swiftStaticResourcesPath: Basics.AbsolutePath? /// Array of paths containing headers. - public var includeSearchPaths: [AbsolutePath]? + public var includeSearchPaths: [Basics.AbsolutePath]? /// Array of paths containing libraries. - public var librarySearchPaths: [AbsolutePath]? + public var librarySearchPaths: [Basics.AbsolutePath]? /// Array of paths containing toolset files. - public var toolsetPaths: [AbsolutePath]? + public var toolsetPaths: [Basics.AbsolutePath]? /// Initialize paths configuration from values deserialized using v3 schema. /// - Parameters: @@ -299,7 +300,7 @@ public struct SwiftSDK: Equatable { /// - swiftSDKDirectory: directory used for converting relative paths in `properties` to absolute paths. fileprivate init( _ properties: SerializedDestinationV3.TripleProperties, - swiftSDKDirectory: AbsolutePath? = nil + swiftSDKDirectory: Basics.AbsolutePath? = nil ) throws { if let swiftSDKDirectory { self.init( @@ -346,7 +347,7 @@ public struct SwiftSDK: Equatable { /// - Parameters: /// - properties: properties of a Swift SDK for the given triple. /// - swiftSDKDirectory: directory used for converting relative paths in `properties` to absolute paths. - fileprivate init(_ properties: SwiftSDKMetadataV4.TripleProperties, swiftSDKDirectory: AbsolutePath? = nil) throws { + fileprivate init(_ properties: SwiftSDKMetadataV4.TripleProperties, swiftSDKDirectory: Basics.AbsolutePath? = nil) throws { if let swiftSDKDirectory { self.init( sdkRootPath: try AbsolutePath(validating: properties.sdkRootPath, relativeTo: swiftSDKDirectory), @@ -422,8 +423,8 @@ public struct SwiftSDK: Equatable { @available(*, deprecated, message: "use `init(targetTriple:sdkRootDir:toolset:)` instead") public init( target: Triple? = nil, - sdk: AbsolutePath?, - binDir: AbsolutePath, + sdk: Basics.AbsolutePath?, + binDir: Basics.AbsolutePath, extraCCFlags: [String] = [], extraSwiftCFlags: [String] = [], extraCPPFlags: [String] = [] @@ -445,8 +446,8 @@ public struct SwiftSDK: Equatable { public init( hostTriple: Triple? = nil, targetTriple: Triple? = nil, - sdkRootDir: AbsolutePath?, - toolchainBinDir: AbsolutePath, + sdkRootDir: Basics.AbsolutePath?, + toolchainBinDir: Basics.AbsolutePath, extraFlags: BuildFlags = BuildFlags() ) { self.init( @@ -501,7 +502,7 @@ public struct SwiftSDK: Equatable { /// Returns the bin directory for the host. private static func hostBinDir( fileSystem: FileSystem - ) throws -> AbsolutePath { + ) throws -> Basics.AbsolutePath { guard let cwd = fileSystem.currentWorkingDirectory else { return try AbsolutePath(validating: CommandLine.arguments[0]).parentDirectory } @@ -511,8 +512,8 @@ public struct SwiftSDK: Equatable { /// The Swift SDK describing the host platform. @available(*, deprecated, renamed: "hostSwiftSDK") public static func hostDestination( - _ binDir: AbsolutePath? = nil, - originalWorkingDirectory: AbsolutePath? = nil, + _ binDir: Basics.AbsolutePath? = nil, + originalWorkingDirectory: Basics.AbsolutePath? = nil, environment: Environment ) throws -> SwiftSDK { try self.hostSwiftSDK(binDir, environment: environment) @@ -520,10 +521,10 @@ public struct SwiftSDK: Equatable { /// The Swift SDK for the host platform. public static func hostSwiftSDK( - _ binDir: AbsolutePath? = nil, + _ binDir: Basics.AbsolutePath? = nil, environment: Environment = .current, observabilityScope: ObservabilityScope? = nil, - fileSystem: any FileSystem = localFileSystem + fileSystem: any FileSystem = Basics.localFileSystem ) throws -> SwiftSDK { try self.systemSwiftSDK( binDir, @@ -538,10 +539,10 @@ public struct SwiftSDK: Equatable { /// Equivalent to `hostSwiftSDK`, except on macOS, where passing a non-nil `darwinPlatformOverride` /// will result in the SDK for the corresponding Darwin platform. private static func systemSwiftSDK( - _ binDir: AbsolutePath? = nil, + _ binDir: Basics.AbsolutePath? = nil, environment: Environment = .current, observabilityScope: ObservabilityScope? = nil, - fileSystem: any FileSystem = localFileSystem, + fileSystem: any FileSystem = Basics.localFileSystem, darwinPlatformOverride: DarwinPlatform? = nil ) throws -> SwiftSDK { // Select the correct binDir. @@ -549,10 +550,10 @@ public struct SwiftSDK: Equatable { print("SWIFTPM_CUSTOM_BINDIR was deprecated in favor of SWIFTPM_CUSTOM_BIN_DIR") } let customBinDir = (environment["SWIFTPM_CUSTOM_BIN_DIR"] ?? environment["SWIFTPM_CUSTOM_BINDIR"]) - .flatMap { try? AbsolutePath(validating: $0) } + .flatMap { try? Basics.AbsolutePath(validating: $0) } let binDir = try customBinDir ?? binDir ?? SwiftSDK.hostBinDir(fileSystem: fileSystem) - let sdkPath: AbsolutePath? + let sdkPath: Basics.AbsolutePath? #if os(macOS) let darwinPlatform = darwinPlatformOverride ?? .macOS // Get the SDK. @@ -618,17 +619,17 @@ public struct SwiftSDK: Equatable { /// - SeeAlso: ``sdkPlatformPaths(for:environment:)`` public struct PlatformPaths { /// Paths of directories containing auxiliary platform frameworks. - public var frameworks: [AbsolutePath] + public var frameworks: [Basics.AbsolutePath] /// Paths of directories containing auxiliary platform libraries. - public var libraries: [AbsolutePath] + public var libraries: [Basics.AbsolutePath] } /// Returns `macosx` sdk platform framework path. @available(*, deprecated, message: "use sdkPlatformPaths(for:) instead") public static func sdkPlatformFrameworkPaths( environment: Environment = .current - ) throws -> (fwk: AbsolutePath, lib: AbsolutePath) { + ) throws -> (fwk: Basics.AbsolutePath, lib: Basics.AbsolutePath) { let paths = try sdkPlatformPaths(for: .macOS, environment: environment) guard let frameworkPath = paths.frameworks.first else { throw StringError("could not determine SDK platform framework path") @@ -659,15 +660,15 @@ public struct SwiftSDK: Equatable { } // For testing frameworks. - let frameworksPath = try AbsolutePath(validating: platformPath).appending( + let frameworksPath = try Basics.AbsolutePath(validating: platformPath).appending( components: "Developer", "Library", "Frameworks" ) - let privateFrameworksPath = try AbsolutePath(validating: platformPath).appending( + let privateFrameworksPath = try Basics.AbsolutePath(validating: platformPath).appending( components: "Developer", "Library", "PrivateFrameworks" ) // For testing libraries. - let librariesPath = try AbsolutePath(validating: platformPath).appending( + let librariesPath = try Basics.AbsolutePath(validating: platformPath).appending( components: "Developer", "usr", "lib" ) @@ -711,11 +712,11 @@ public struct SwiftSDK: Equatable { public static func deriveTargetSwiftSDK( hostSwiftSDK: SwiftSDK, hostTriple: Triple, - customToolsets: [AbsolutePath] = [], - customCompileDestination: AbsolutePath? = nil, + customToolsets: [Basics.AbsolutePath] = [], + customCompileDestination: Basics.AbsolutePath? = nil, customCompileTriple: Triple? = nil, - customCompileToolchain: AbsolutePath? = nil, - customCompileSDK: AbsolutePath? = nil, + customCompileToolchain: Basics.AbsolutePath? = nil, + customCompileSDK: Basics.AbsolutePath? = nil, swiftSDKSelector: String? = nil, architectures: [String] = [], store: SwiftSDKBundleStore, @@ -833,7 +834,7 @@ public struct SwiftSDK: Equatable { /// Note: Use this operation if you want new root path to take priority over existing paths. /// /// - Parameter toolsetRootPath: new path to add to Swift SDK's toolset. - public mutating func prepend(toolsetRootPath path: AbsolutePath) { + public mutating func prepend(toolsetRootPath path: Basics.AbsolutePath) { self.toolset.rootPaths.insert(path, at: 0) } @@ -843,7 +844,7 @@ public struct SwiftSDK: Equatable { /// have a lower priority vs. existing paths. /// /// - Parameter toolsetRootPath: new path to add to Swift SDK's toolset. - public mutating func append(toolsetRootPath: AbsolutePath) { + public mutating func append(toolsetRootPath: Basics.AbsolutePath) { self.toolset.rootPaths.append(toolsetRootPath) } } @@ -851,7 +852,7 @@ public struct SwiftSDK: Equatable { extension SwiftSDK { /// Load a ``SwiftSDK`` description from a JSON representation from disk. public static func decode( - fromFile path: AbsolutePath, + fromFile path: Basics.AbsolutePath, fileSystem: FileSystem, observabilityScope: ObservabilityScope ) throws -> [SwiftSDK] { @@ -874,7 +875,7 @@ extension SwiftSDK { /// Load a ``SwiftSDK`` description from a semantically versioned JSON representation from disk. private static func decode( semanticVersion: SemanticVersionInfo, - fromFile path: AbsolutePath, + fromFile path: Basics.AbsolutePath, fileSystem: FileSystem, decoder: JSONDecoder, observabilityScope: ObservabilityScope @@ -946,7 +947,7 @@ extension SwiftSDK { targetTriple: Triple, properties: SwiftSDKMetadataV4.TripleProperties, toolset: Toolset = .init(), - swiftSDKDirectory: AbsolutePath? = nil + swiftSDKDirectory: Basics.AbsolutePath? = nil ) throws { self.init( targetTriple: targetTriple, @@ -965,7 +966,7 @@ extension SwiftSDK { targetTriple: Triple, properties: SerializedDestinationV3.TripleProperties, toolset: Toolset = .init(), - swiftSDKDirectory: AbsolutePath? = nil + swiftSDKDirectory: Basics.AbsolutePath? = nil ) throws { self.init( targetTriple: targetTriple, @@ -977,7 +978,7 @@ extension SwiftSDK { /// Load a ``SwiftSDK`` description from a legacy JSON representation from disk. private init( legacy version: VersionInfo, - fromFile path: AbsolutePath, + fromFile path: Basics.AbsolutePath, fileSystem: FileSystem, decoder: JSONDecoder ) throws { @@ -1089,8 +1090,8 @@ private struct SemanticVersionInfo: Decodable { /// Represents v1 schema of `destination.json` files used for cross-compilation. private struct SerializedDestinationV1: Codable { let target: String? - let sdk: AbsolutePath? - let binDir: AbsolutePath + let sdk: Basics.AbsolutePath? + let binDir: Basics.AbsolutePath let extraCCFlags: [String] let extraSwiftCFlags: [String] let extraCPPFlags: [String] @@ -1169,13 +1170,13 @@ struct SwiftSDKMetadataV4: Decodable { let targetTriples: [String: TripleProperties] } -extension Optional where Wrapped == AbsolutePath { +extension Optional where Wrapped == Basics.AbsolutePath { fileprivate var configurationString: String { self?.pathString ?? "not set" } } -extension Optional where Wrapped == [AbsolutePath] { +extension Optional where Wrapped == [Basics.AbsolutePath] { fileprivate var configurationString: String { self?.map(\.pathString).description ?? "not set" } diff --git a/Sources/PackageModel/UserToolchain.swift b/Sources/PackageModel/UserToolchain.swift index 5a38f747171..7b97b2d8c64 100644 --- a/Sources/PackageModel/UserToolchain.swift +++ b/Sources/PackageModel/UserToolchain.swift @@ -12,6 +12,7 @@ import Basics import Foundation +import TSCUtility import class Basics.AsyncProcess @@ -69,9 +70,9 @@ public final class UserToolchain: Toolchain { /// The target triple that should be used for compilation. @available(*, deprecated, renamed: "targetTriple") - public var triple: Triple { targetTriple } + public var triple: Basics.Triple { targetTriple } - public let targetTriple: Triple + public let targetTriple: Basics.Triple /// The list of CPU architectures to build for. public let architectures: [String]? @@ -162,7 +163,7 @@ public final class UserToolchain: Toolchain { // MARK: - public API public static func determineLibrarian( - triple: Triple, + triple: Basics.Triple, binDirectories: [AbsolutePath], useXcrun: Bool, environment: Environment, @@ -405,7 +406,7 @@ public final class UserToolchain: Toolchain { #endif internal static func deriveSwiftCFlags( - triple: Triple, + triple: Basics.Triple, swiftSDK: SwiftSDK, environment: Environment, fileSystem: any FileSystem @@ -839,7 +840,7 @@ public final class UserToolchain: Toolchain { return .init(swiftCompilerPath: swiftCompilerPath) } - private static func derivePluginServerPath(triple: Triple) throws -> AbsolutePath? { + private static func derivePluginServerPath(triple: Basics.Triple) throws -> AbsolutePath? { if triple.isDarwin() { let pluginServerPathFindArgs = ["/usr/bin/xcrun", "--find", "swift-plugin-server"] if let path = try? AsyncProcess.checkNonZeroExit(arguments: pluginServerPathFindArgs, environment: [:]) @@ -889,7 +890,7 @@ public final class UserToolchain: Toolchain { // TODO: We should have some general utility to find tools. private static func deriveXCTestPath( swiftSDK: SwiftSDK, - triple: Triple, + triple: Basics.Triple, environment: Environment, fileSystem: any FileSystem ) throws -> AbsolutePath? { @@ -970,9 +971,9 @@ public final class UserToolchain: Toolchain { /// Find the swift-testing path if it is within a path that will need extra search paths. private static func deriveSwiftTestingPath( - derivedSwiftCompiler: AbsolutePath, + derivedSwiftCompiler: Basics.AbsolutePath, swiftSDK: SwiftSDK, - triple: Triple, + triple: Basics.Triple, environment: Environment, fileSystem: any FileSystem ) throws -> AbsolutePath? { From 3fec67d2839b288e0d2f16bd8bd4f0a5560d9d38 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:38:07 -0400 Subject: [PATCH 12/35] Adopt MemberImportVisiblity - PackageModelSyntax --- Package.swift | 1 + Sources/PackageModelSyntax/AddTarget.swift | 1 + Sources/PackageModelSyntax/ManifestSyntaxRepresentable.swift | 1 + Sources/PackageModelSyntax/PackageDependency+Syntax.swift | 1 + Sources/PackageModelSyntax/ProductDescription+Syntax.swift | 1 + Sources/PackageModelSyntax/SyntaxEditUtils.swift | 1 + Sources/PackageModelSyntax/TargetDescription+Syntax.swift | 2 +- 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index a94aeab0536..6ce6ac6cf4d 100644 --- a/Package.swift +++ b/Package.swift @@ -324,6 +324,7 @@ let package = Package( ] + swiftSyntaxDependencies(["SwiftBasicFormat", "SwiftDiagnostics", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax", "SwiftSyntaxBuilder"]), exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageModelSyntax/AddTarget.swift b/Sources/PackageModelSyntax/AddTarget.swift index addb4e4886a..b6a081a7d67 100644 --- a/Sources/PackageModelSyntax/AddTarget.swift +++ b/Sources/PackageModelSyntax/AddTarget.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Basics +import Foundation import PackageModel import SwiftParser import SwiftSyntax diff --git a/Sources/PackageModelSyntax/ManifestSyntaxRepresentable.swift b/Sources/PackageModelSyntax/ManifestSyntaxRepresentable.swift index 1b40b2d592a..146bc6e3b74 100644 --- a/Sources/PackageModelSyntax/ManifestSyntaxRepresentable.swift +++ b/Sources/PackageModelSyntax/ManifestSyntaxRepresentable.swift @@ -12,6 +12,7 @@ import Basics import SwiftSyntax +import SwiftSyntaxBuilder /// Describes an entity in the package model that can be represented as /// a syntax node. diff --git a/Sources/PackageModelSyntax/PackageDependency+Syntax.swift b/Sources/PackageModelSyntax/PackageDependency+Syntax.swift index b8a7445938e..6133b9d7344 100644 --- a/Sources/PackageModelSyntax/PackageDependency+Syntax.swift +++ b/Sources/PackageModelSyntax/PackageDependency+Syntax.swift @@ -14,6 +14,7 @@ import Basics import PackageModel import SwiftParser import SwiftSyntax +import SwiftSyntaxBuilder import struct TSCUtility.Version extension MappablePackageDependency.Kind: ManifestSyntaxRepresentable { diff --git a/Sources/PackageModelSyntax/ProductDescription+Syntax.swift b/Sources/PackageModelSyntax/ProductDescription+Syntax.swift index eed6650dfce..614d5db8bf4 100644 --- a/Sources/PackageModelSyntax/ProductDescription+Syntax.swift +++ b/Sources/PackageModelSyntax/ProductDescription+Syntax.swift @@ -13,6 +13,7 @@ import Basics import PackageModel import SwiftSyntax +import SwiftSyntaxBuilder import SwiftParser extension ProductDescription: ManifestSyntaxRepresentable { diff --git a/Sources/PackageModelSyntax/SyntaxEditUtils.swift b/Sources/PackageModelSyntax/SyntaxEditUtils.swift index df64aa4c2d3..6e3c2a2a518 100644 --- a/Sources/PackageModelSyntax/SyntaxEditUtils.swift +++ b/Sources/PackageModelSyntax/SyntaxEditUtils.swift @@ -15,6 +15,7 @@ import PackageModel import SwiftBasicFormat import SwiftSyntax import SwiftParser +import SwiftSyntaxBuilder /// Default indent when we have to introduce indentation but have no context /// to get it right. diff --git a/Sources/PackageModelSyntax/TargetDescription+Syntax.swift b/Sources/PackageModelSyntax/TargetDescription+Syntax.swift index f47f6590f06..eed59e5fcae 100644 --- a/Sources/PackageModelSyntax/TargetDescription+Syntax.swift +++ b/Sources/PackageModelSyntax/TargetDescription+Syntax.swift @@ -13,9 +13,9 @@ import Basics import PackageModel import SwiftSyntax +import SwiftSyntaxBuilder import SwiftParser - extension TargetDescription: ManifestSyntaxRepresentable { /// The function name in the package manifest. private var functionName: String { From bbf8cd947660a7daecbe5ce88b3c97b5133eb5a2 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sat, 12 Apr 2025 21:53:46 -0400 Subject: [PATCH 13/35] Adopt MemberImportVisiblity - PackageLoading --- Package.swift | 1 + .../ManifestLoader+Validation.swift | 8 ++- .../PackageLoading/ModuleMapGenerator.swift | 39 ++++++------- Sources/PackageLoading/PackageBuilder.swift | 2 + Sources/PackageLoading/PkgConfig.swift | 38 +++++++------ Sources/PackageLoading/Platform.swift | 7 ++- ...RegistryReleaseMetadataSerialization.swift | 5 +- Sources/PackageLoading/Target+PkgConfig.swift | 1 + .../PackageLoading/TargetSourcesBuilder.swift | 57 ++++++++++--------- 9 files changed, 85 insertions(+), 73 deletions(-) diff --git a/Package.swift b/Package.swift index 6ce6ac6cf4d..79cf82fa615 100644 --- a/Package.swift +++ b/Package.swift @@ -339,6 +339,7 @@ let package = Package( ], exclude: ["CMakeLists.txt", "README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageLoading/ManifestLoader+Validation.swift b/Sources/PackageLoading/ManifestLoader+Validation.swift index 285736c1198..a0213af9239 100644 --- a/Sources/PackageLoading/ManifestLoader+Validation.swift +++ b/Sources/PackageLoading/ManifestLoader+Validation.swift @@ -13,6 +13,8 @@ import Basics import Foundation import PackageModel +import TSCBasic +import TSCUtility public struct ManifestValidator { static var supportedLocalBinaryDependencyExtensions: [String] { @@ -160,7 +162,7 @@ public struct ManifestValidator { continue } - guard let relativePath = try? RelativePath(validating: path) else { + guard let relativePath = try? Basics.RelativePath(validating: path) else { diagnostics.append(.invalidLocalBinaryPath(path: path, targetName: target.name)) continue } @@ -274,7 +276,7 @@ public struct ManifestValidator { } public protocol ManifestSourceControlValidator { - func isValidDirectory(_ path: AbsolutePath) throws -> Bool + func isValidDirectory(_ path: Basics.AbsolutePath) throws -> Bool } extension Basics.Diagnostic { @@ -344,7 +346,7 @@ extension Basics.Diagnostic { } } - static func invalidSourceControlDirectory(_ path: AbsolutePath, underlyingError: Error? = nil) -> Self { + static func invalidSourceControlDirectory(_ path: Basics.AbsolutePath, underlyingError: Error? = nil) -> Self { .error("cannot clone from local directory \(path)\nPlease git init or use \"path:\" for \(path)\(errorSuffix(underlyingError))") } diff --git a/Sources/PackageLoading/ModuleMapGenerator.swift b/Sources/PackageLoading/ModuleMapGenerator.swift index 3009970eb3a..5f9cb4cb09d 100644 --- a/Sources/PackageLoading/ModuleMapGenerator.swift +++ b/Sources/PackageLoading/ModuleMapGenerator.swift @@ -13,11 +13,12 @@ import Basics import Foundation import PackageModel +import TSCBasic /// Name of the module map file recognized by the Clang and Swift compilers. public let moduleMapFilename = "module.modulemap" -extension AbsolutePath { +extension Basics.AbsolutePath { fileprivate var moduleEscapedPathString: String { return self.pathString.replacing("\\", with: "\\\\") } @@ -25,27 +26,27 @@ extension AbsolutePath { /// A protocol for targets which might have a modulemap. protocol ModuleMapProtocol { - var moduleMapPath: AbsolutePath { get } + var moduleMapPath: Basics.AbsolutePath { get } - var moduleMapDirectory: AbsolutePath { get } + var moduleMapDirectory: Basics.AbsolutePath { get } } extension SystemLibraryModule: ModuleMapProtocol { - var moduleMapDirectory: AbsolutePath { + var moduleMapDirectory: Basics.AbsolutePath { return path } - public var moduleMapPath: AbsolutePath { + public var moduleMapPath: Basics.AbsolutePath { return moduleMapDirectory.appending(component: moduleMapFilename) } } extension ClangModule: ModuleMapProtocol { - var moduleMapDirectory: AbsolutePath { + var moduleMapDirectory: Basics.AbsolutePath { return includeDir } - public var moduleMapPath: AbsolutePath { + public var moduleMapPath: Basics.AbsolutePath { return moduleMapDirectory.appending(component: moduleMapFilename) } } @@ -75,12 +76,12 @@ public struct ModuleMapGenerator { private let moduleName: String /// The target's public-headers directory. - private let publicHeadersDir: AbsolutePath + private let publicHeadersDir: Basics.AbsolutePath /// The file system to be used. private let fileSystem: FileSystem - public init(targetName: String, moduleName: String, publicHeadersDir: AbsolutePath, fileSystem: FileSystem) { + public init(targetName: String, moduleName: String, publicHeadersDir: Basics.AbsolutePath, fileSystem: FileSystem) { self.targetName = targetName self.moduleName = moduleName self.publicHeadersDir = publicHeadersDir @@ -110,7 +111,7 @@ public struct ModuleMapGenerator { } // Next try to get the entries in the public-headers directory. - let entries: Set + let entries: Set do { entries = try Set(fileSystem.getDirectoryContents(publicHeadersDir).map({ publicHeadersDir.appending(component: $0) })) } @@ -174,7 +175,7 @@ public struct ModuleMapGenerator { } /// Generates a module map based of the specified type, throwing an error if anything goes wrong. Any diagnostics are added to the receiver's diagnostics engine. - public func generateModuleMap(type: GeneratedModuleMapType, at path: AbsolutePath) throws { + public func generateModuleMap(type: GeneratedModuleMapType, at path: Basics.AbsolutePath) throws { var moduleMap = "module \(moduleName) {\n" switch type { case .umbrellaHeader(let hdr): @@ -205,8 +206,8 @@ public struct ModuleMapGenerator { /// A type of module map to generate. public enum GeneratedModuleMapType { - case umbrellaHeader(AbsolutePath) - case umbrellaDirectory(AbsolutePath) + case umbrellaHeader(Basics.AbsolutePath) + case umbrellaDirectory(Basics.AbsolutePath) } public extension ModuleMapType { @@ -223,32 +224,32 @@ public extension ModuleMapType { private extension Basics.Diagnostic { /// Warning emitted if the public-headers directory is missing. - static func missingPublicHeadersDirectory(targetName: String, publicHeadersDir: AbsolutePath) -> Self { + static func missingPublicHeadersDirectory(targetName: String, publicHeadersDir: Basics.AbsolutePath) -> Self { .warning("no include directory found for target '\(targetName)'; libraries cannot be imported without public headers") } /// Error emitted if the public-headers directory is inaccessible. - static func inaccessiblePublicHeadersDirectory(targetName: String, publicHeadersDir: AbsolutePath, fileSystemError: Error) -> Self { + static func inaccessiblePublicHeadersDirectory(targetName: String, publicHeadersDir: Basics.AbsolutePath, fileSystemError: Error) -> Self { .error("cannot access public-headers directory for target '\(targetName)': \(String(describing: fileSystemError))") } /// Warning emitted if a misnamed umbrella header was found. - static func misnamedUmbrellaHeader(misnamedUmbrellaHeader: AbsolutePath, umbrellaHeader: AbsolutePath) -> Self { + static func misnamedUmbrellaHeader(misnamedUmbrellaHeader: Basics.AbsolutePath, umbrellaHeader: Basics.AbsolutePath) -> Self { .warning("\(misnamedUmbrellaHeader) should be renamed to \(umbrellaHeader) to be used as an umbrella header") } /// Error emitted if there are directories next to a top-level umbrella header. - static func umbrellaHeaderHasSiblingDirectories(targetName: String, umbrellaHeader: AbsolutePath, siblingDirs: Set) -> Self { + static func umbrellaHeaderHasSiblingDirectories(targetName: String, umbrellaHeader: Basics.AbsolutePath, siblingDirs: Set) -> Self { .error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but directories exist next to it: \(siblingDirs.map({ String(describing: $0) }).sorted().joined(separator: ", ")); consider removing them") } /// Error emitted if there are other directories next to the parent directory of a nested umbrella header. - static func umbrellaHeaderParentDirHasSiblingDirectories(targetName: String, umbrellaHeader: AbsolutePath, siblingDirs: Set) -> Self { + static func umbrellaHeaderParentDirHasSiblingDirectories(targetName: String, umbrellaHeader: Basics.AbsolutePath, siblingDirs: Set) -> Self { .error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but more than one directory exists next to its parent directory: \(siblingDirs.map({ String(describing: $0) }).sorted().joined(separator: ", ")); consider reducing them to one") } /// Error emitted if there are other headers next to the parent directory of a nested umbrella header. - static func umbrellaHeaderParentDirHasSiblingHeaders(targetName: String, umbrellaHeader: AbsolutePath, siblingHeaders: Set) -> Self { + static func umbrellaHeaderParentDirHasSiblingHeaders(targetName: String, umbrellaHeader: Basics.AbsolutePath, siblingHeaders: Set) -> Self { .error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but additional header files exist: \((siblingHeaders.map({ String(describing: $0) }).sorted().joined(separator: ", "))); consider reducing them to one") } } diff --git a/Sources/PackageLoading/PackageBuilder.swift b/Sources/PackageLoading/PackageBuilder.swift index 5e8f0c81122..8524e8ff707 100644 --- a/Sources/PackageLoading/PackageBuilder.swift +++ b/Sources/PackageLoading/PackageBuilder.swift @@ -14,6 +14,8 @@ import Basics import Dispatch import OrderedCollections import PackageModel +import Foundation +import TSCUtility import func TSCBasic.findCycle import struct TSCBasic.KeyedPair diff --git a/Sources/PackageLoading/PkgConfig.swift b/Sources/PackageLoading/PkgConfig.swift index b98d01932d5..86509d0f5cd 100644 --- a/Sources/PackageLoading/PkgConfig.swift +++ b/Sources/PackageLoading/PkgConfig.swift @@ -13,6 +13,8 @@ import Basics import Foundation import OrderedCollections +import TSCUtility +import TSCBasic import class Basics.AsyncProcess @@ -22,7 +24,7 @@ public struct PkgConfig { public let name: String /// The path to the definition file. - public let pcFile: AbsolutePath + public let pcFile: Basics.AbsolutePath /// The list of C compiler flags in the definition. public let cFlags: [String] @@ -44,9 +46,9 @@ public struct PkgConfig { /// - throws: PkgConfigError public init( name: String, - additionalSearchPaths: [AbsolutePath]? = .none, - brewPrefix: AbsolutePath? = .none, - sysrootDir: AbsolutePath? = .none, + additionalSearchPaths: [Basics.AbsolutePath]? = .none, + brewPrefix: Basics.AbsolutePath? = .none, + sysrootDir: Basics.AbsolutePath? = .none, fileSystem: FileSystem, observabilityScope: ObservabilityScope ) throws { @@ -63,16 +65,16 @@ public struct PkgConfig { private init( name: String, - additionalSearchPaths: [AbsolutePath], - brewPrefix: AbsolutePath?, - sysrootDir: AbsolutePath?, + additionalSearchPaths: [Basics.AbsolutePath], + brewPrefix: Basics.AbsolutePath?, + sysrootDir: Basics.AbsolutePath?, loadingContext: LoadingContext, fileSystem: FileSystem, observabilityScope: ObservabilityScope ) throws { loadingContext.pkgConfigStack.append(name) - if let path = try? AbsolutePath(validating: name) { + if let path = try? Basics.AbsolutePath(validating: name) { guard fileSystem.isFile(path) else { throw PkgConfigError.couldNotFindConfigFile(name: name) } self.name = path.basenameWithoutExt self.pcFile = path @@ -127,7 +129,7 @@ public struct PkgConfig { loadingContext.pkgConfigStack.removeLast(); } - private static var envSearchPaths: [AbsolutePath] { + private static var envSearchPaths: [Basics.AbsolutePath] { get throws { if let configPath = Environment.current["PKG_CONFIG_PATH"] { #if os(Windows) @@ -158,7 +160,7 @@ extension PkgConfig { /// See: https://www.freedesktop.org/wiki/Software/pkg-config/ // This is only internal so it can be unit tested. internal struct PkgConfigParser { - public let pcFile: AbsolutePath + public let pcFile: Basics.AbsolutePath private let fileSystem: FileSystem public private(set) var variables = [String: String]() public private(set) var dependencies = [String]() @@ -167,7 +169,7 @@ internal struct PkgConfigParser { public private(set) var libs = [String]() public private(set) var sysrootDir: String? - public init(pcFile: AbsolutePath, fileSystem: FileSystem, sysrootDir: String?) throws { + public init(pcFile: Basics.AbsolutePath, fileSystem: FileSystem, sysrootDir: String?) throws { guard fileSystem.isFile(pcFile) else { throw StringError("invalid pcfile \(pcFile)") } @@ -268,7 +270,7 @@ internal struct PkgConfigParser { // Add pc_sysrootdir variable. This is the path of the sysroot directory for pc files. // pkgconf does not define pc_sysrootdir if the path of the .pc file is outside sysrootdir. // SwiftPM does not currently make that check. - variables["pc_sysrootdir"] = sysrootDir ?? AbsolutePath.root.pathString + variables["pc_sysrootdir"] = sysrootDir ?? Basics.AbsolutePath.root.pathString let fileContents: String = try fileSystem.readFileContents(pcFile) for line in fileContents.components(separatedBy: "\n") { @@ -461,7 +463,7 @@ internal struct PCFileFinder { /// FIXME: This shouldn't use a static variable, since the first lookup /// will cache the result of whatever `brewPrefix` was passed in. It is /// also not threadsafe. - public private(set) static var pkgConfigPaths: [AbsolutePath]? // FIXME: @testable(internal) + public private(set) static var pkgConfigPaths: [Basics.AbsolutePath]? // FIXME: @testable(internal) private static var shouldEmitPkgConfigPathsDiagnostic = false /// The built-in search path list. @@ -469,7 +471,7 @@ internal struct PCFileFinder { /// By default, this is combined with the search paths inferred from /// `pkg-config` itself. static let searchPaths = [ - try? AbsolutePath(validating: "/usr/local/lib/pkgconfig"), + try? Basics.AbsolutePath(validating: "/usr/local/lib/pkgconfig"), try? AbsolutePath(validating: "/usr/local/share/pkgconfig"), try? AbsolutePath(validating: "/usr/lib/pkgconfig"), try? AbsolutePath(validating: "/usr/share/pkgconfig"), @@ -498,11 +500,11 @@ internal struct PCFileFinder { } } - public init(brewPrefix: AbsolutePath?) { + public init(brewPrefix: Basics.AbsolutePath?) { self.init(pkgConfigPath: brewPrefix?.appending(components: "bin", "pkg-config").pathString ?? "pkg-config") } - public init(pkgConfig: AbsolutePath? = .none) { + public init(pkgConfig: Basics.AbsolutePath? = .none) { self.init(pkgConfigPath: pkgConfig?.pathString ?? "pkg-config") } @@ -516,10 +518,10 @@ internal struct PCFileFinder { public func locatePCFile( name: String, - customSearchPaths: [AbsolutePath], + customSearchPaths: [Basics.AbsolutePath], fileSystem: FileSystem, observabilityScope: ObservabilityScope - ) throws -> AbsolutePath { + ) throws -> Basics.AbsolutePath { // FIXME: We should consider building a registry for all items in the // search paths, which is likely to be substantially more efficient if // we end up searching for a reasonably sized number of packages. diff --git a/Sources/PackageLoading/Platform.swift b/Sources/PackageLoading/Platform.swift index b98a3848cf4..cb7ddeecca8 100644 --- a/Sources/PackageLoading/Platform.swift +++ b/Sources/PackageLoading/Platform.swift @@ -12,12 +12,13 @@ import Basics import Foundation +import TSCBasic import class Basics.AsyncProcess private func isAndroid() -> Bool { - (try? localFileSystem.isFile(AbsolutePath(validating: "/system/bin/toolchain"))) ?? false || - (try? localFileSystem.isFile(AbsolutePath(validating: "/system/bin/toybox"))) ?? false + (try? Basics.localFileSystem.isFile(AbsolutePath(validating: "/system/bin/toolchain"))) ?? false || + (try? Basics.localFileSystem.isFile(AbsolutePath(validating: "/system/bin/toybox"))) ?? false } public enum Platform: Equatable, Sendable { @@ -48,7 +49,7 @@ extension Platform { case "freebsd"?: return .freebsd case "linux"?: - return Platform.findCurrentPlatformLinux(localFileSystem) + return Platform.findCurrentPlatformLinux(Basics.localFileSystem) default: return nil } diff --git a/Sources/PackageLoading/RegistryReleaseMetadataSerialization.swift b/Sources/PackageLoading/RegistryReleaseMetadataSerialization.swift index cf60cd9a211..31dd959ea30 100644 --- a/Sources/PackageLoading/RegistryReleaseMetadataSerialization.swift +++ b/Sources/PackageLoading/RegistryReleaseMetadataSerialization.swift @@ -13,6 +13,7 @@ import Basics import Foundation import PackageModel +import TSCBasic public enum RegistryReleaseMetadataStorage { public static let fileName = ".registry-metadata" @@ -20,13 +21,13 @@ public enum RegistryReleaseMetadataStorage { private static let encoder = JSONEncoder.makeWithDefaults() private static let decoder = JSONDecoder.makeWithDefaults() - public static func save(_ metadata: RegistryReleaseMetadata, to path: AbsolutePath, fileSystem: FileSystem) throws { + public static func save(_ metadata: RegistryReleaseMetadata, to path: Basics.AbsolutePath, fileSystem: FileSystem) throws { let codableMetadata = CodableRegistryReleaseMetadata(metadata) let data = try Self.encoder.encode(codableMetadata) try fileSystem.writeFileContents(path, data: data) } - public static func load(from path: AbsolutePath, fileSystem: FileSystem) throws -> RegistryReleaseMetadata { + public static func load(from path: Basics.AbsolutePath, fileSystem: FileSystem) throws -> RegistryReleaseMetadata { let codableMetadata = try Self.decoder.decode( path: path, fileSystem: fileSystem, diff --git a/Sources/PackageLoading/Target+PkgConfig.swift b/Sources/PackageLoading/Target+PkgConfig.swift index 8ed3d9db588..49b6fc30be7 100644 --- a/Sources/PackageLoading/Target+PkgConfig.swift +++ b/Sources/PackageLoading/Target+PkgConfig.swift @@ -12,6 +12,7 @@ import Basics import PackageModel +import Foundation import class Basics.AsyncProcess import struct TSCBasic.RegEx diff --git a/Sources/PackageLoading/TargetSourcesBuilder.swift b/Sources/PackageLoading/TargetSourcesBuilder.swift index 0d22e06101e..17f36fb2cbe 100644 --- a/Sources/PackageLoading/TargetSourcesBuilder.swift +++ b/Sources/PackageLoading/TargetSourcesBuilder.swift @@ -13,6 +13,7 @@ import Basics import Foundation import PackageModel +import TSCBasic /// A utility to compute the source/resource files of a target. public struct TargetSourcesBuilder { @@ -23,19 +24,19 @@ public struct TargetSourcesBuilder { public let packageKind: PackageReference.Kind /// The package path. - public let packagePath: AbsolutePath + public let packagePath: Basics.AbsolutePath /// The target for which we're computing source/resource files. public let target: TargetDescription /// The path of the target. - public let targetPath: AbsolutePath + public let targetPath: Basics.AbsolutePath /// The list of declared sources in the package manifest. - public let declaredSources: [AbsolutePath]? + public let declaredSources: [Basics.AbsolutePath]? /// The list of declared resources in the package manifest. - public let declaredResources: [(path: AbsolutePath, rule: TargetDescription.Resource.Rule)] + public let declaredResources: [(path: Basics.AbsolutePath, rule: TargetDescription.Resource.Rule)] /// The default localization. public let defaultLocalization: String? @@ -47,7 +48,7 @@ public struct TargetSourcesBuilder { public let toolsVersion: ToolsVersion /// The set of paths that should be excluded from any consideration. - public let excludedPaths: Set + public let excludedPaths: Set /// The set of opaque directories extensions (should not be treated as source) private let opaqueDirectoriesExtensions: Set @@ -62,9 +63,9 @@ public struct TargetSourcesBuilder { public init( packageIdentity: PackageIdentity, packageKind: PackageReference.Kind, - packagePath: AbsolutePath, + packagePath: Basics.AbsolutePath, target: TargetDescription, - path: AbsolutePath, + path: Basics.AbsolutePath, defaultLocalization: String?, additionalFileRules: [FileRuleDescription], toolsVersion: ToolsVersion, @@ -136,7 +137,7 @@ public struct TargetSourcesBuilder { } @discardableResult - private func validTargetPath(at: AbsolutePath) -> Error? { + private func validTargetPath(at: Basics.AbsolutePath) -> Error? { // Check if paths that are enumerated in targets: [] exist guard self.fileSystem.exists(at) else { return StringError("File not found") @@ -165,11 +166,11 @@ public struct TargetSourcesBuilder { } /// Run the builder to produce the sources of the target. - public func run() throws -> (sources: Sources, resources: [Resource], headers: [AbsolutePath], ignored: [AbsolutePath], others: [AbsolutePath]) { + public func run() throws -> (sources: Sources, resources: [Resource], headers: [Basics.AbsolutePath], ignored: [Basics.AbsolutePath], others: [Basics.AbsolutePath]) { let contents = self.computeContents() - var pathToRule: [AbsolutePath: FileRuleDescription.Rule] = [:] + var pathToRule: [Basics.AbsolutePath: FileRuleDescription.Rule] = [:] - var handledResources = [AbsolutePath]() + var handledResources = [Basics.AbsolutePath]() for path in contents { pathToRule[path] = Self.computeRule( for: path, @@ -222,7 +223,7 @@ public struct TargetSourcesBuilder { } /// Compute the rule for the given path. - private static func computeRule(for path: AbsolutePath, + private static func computeRule(for path: Basics.AbsolutePath, toolsVersion: ToolsVersion, additionalFileRules: [FileRuleDescription], observabilityScope: ObservabilityScope) -> FileRuleDescription.Rule { @@ -232,12 +233,12 @@ public struct TargetSourcesBuilder { } private static func computeRule( - for path: AbsolutePath, + for path: Basics.AbsolutePath, toolsVersion: ToolsVersion, rules: [FileRuleDescription], - declaredResources: [(path: AbsolutePath, rule: TargetDescription.Resource.Rule)], - declaredSources: [AbsolutePath]?, - matchingResourceRuleHandler: (AbsolutePath) -> () = { _ in }, + declaredResources: [(path: Basics.AbsolutePath, rule: TargetDescription.Resource.Rule)], + declaredSources: [Basics.AbsolutePath]?, + matchingResourceRuleHandler: (Basics.AbsolutePath) -> () = { _ in }, observabilityScope: ObservabilityScope ) -> FileRuleDescription.Rule { var matchedRule: FileRuleDescription.Rule = .none @@ -303,7 +304,7 @@ public struct TargetSourcesBuilder { } /// Returns the `Resource` file associated with a file and a particular rule, if there is one. - private static func resource(for path: AbsolutePath, with rule: FileRuleDescription.Rule, defaultLocalization: String?, targetName: String, targetPath: AbsolutePath, observabilityScope: ObservabilityScope) -> Resource? { + private static func resource(for path: Basics.AbsolutePath, with rule: FileRuleDescription.Rule, defaultLocalization: String?, targetName: String, targetPath: Basics.AbsolutePath, observabilityScope: ObservabilityScope) -> Resource? { switch rule { case .compile, .header, .none, .modulemap, .ignored: return nil @@ -342,7 +343,7 @@ public struct TargetSourcesBuilder { } } - private func resource(for path: AbsolutePath, with rule: FileRuleDescription.Rule) -> Resource? { + private func resource(for path: Basics.AbsolutePath, with rule: FileRuleDescription.Rule) -> Resource? { return Self.resource(for: path, with: rule, defaultLocalization: defaultLocalization, targetName: target.name, targetPath: targetPath, observabilityScope: observabilityScope) } @@ -406,7 +407,7 @@ public struct TargetSourcesBuilder { } /// Returns true if the given path is a declared source. - func isDeclaredSource(_ path: AbsolutePath) -> Bool { + func isDeclaredSource(_ path: Basics.AbsolutePath) -> Bool { return path == targetPath || declaredSources?.contains(path) == true } @@ -414,9 +415,9 @@ public struct TargetSourcesBuilder { /// /// This avoids recursing into certain directories like exclude or the /// ones that should be copied as-is. - public func computeContents() -> [AbsolutePath] { - var contents: [AbsolutePath] = [] - var queue: [AbsolutePath] = [targetPath] + public func computeContents() -> [Basics.AbsolutePath] { + var contents: [Basics.AbsolutePath] = [] + var queue: [Basics.AbsolutePath] = [targetPath] // Ignore xcodeproj and playground directories. var ignoredDirectoryExtensions = ["xcodeproj", "playground", "xcworkspace"] @@ -518,8 +519,8 @@ public struct TargetSourcesBuilder { return contents } - public static func computeContents(for generatedFiles: [AbsolutePath], toolsVersion: ToolsVersion, additionalFileRules: [FileRuleDescription], defaultLocalization: String?, targetName: String, targetPath: AbsolutePath, observabilityScope: ObservabilityScope) -> (sources: [AbsolutePath], resources: [Resource]) { - var sources = [AbsolutePath]() + public static func computeContents(for generatedFiles: [Basics.AbsolutePath], toolsVersion: ToolsVersion, additionalFileRules: [FileRuleDescription], defaultLocalization: String?, targetName: String, targetPath: Basics.AbsolutePath, observabilityScope: ObservabilityScope) -> (sources: [Basics.AbsolutePath], resources: [Resource]) { + var sources = [Basics.AbsolutePath]() var resources = [Resource]() generatedFiles.forEach { absPath in @@ -613,7 +614,7 @@ public struct FileRuleDescription: Sendable { } /// Match the given path to the rule. - public func match(path: AbsolutePath, toolsVersion: ToolsVersion) -> Bool { + public func match(path: Basics.AbsolutePath, toolsVersion: ToolsVersion) -> Bool { if toolsVersion < self.toolsVersion { return false } @@ -800,12 +801,12 @@ extension Resource { } extension Basics.Diagnostic { - static func symlinkInSources(symlink: RelativePath, targetName: String) -> Self { + static func symlinkInSources(symlink: Basics.RelativePath, targetName: String) -> Self { .warning("ignoring symlink at '\(symlink)' in target '\(targetName)'") } static func localizationDirectoryContainsSubDirectories( - localizationDirectory: RelativePath, + localizationDirectory: Basics.RelativePath, targetName: String ) -> Self { .error("localization directory '\(localizationDirectory)' in target '\(targetName)' contains sub-directories, which is forbidden") @@ -839,7 +840,7 @@ extension PackageReference.Kind { } extension PackageModel.Resource { - fileprivate var destinationForGrouping: RelativePath? { + fileprivate var destinationForGrouping: Basics.RelativePath? { do { return try self.destination } catch { From 9212ad4fe49a3337332bcb95052e232826604260 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 20:58:51 -0400 Subject: [PATCH 14/35] Adopt MemberImportVisiblity - PackageGraph --- Package.swift | 1 + Sources/PackageGraph/ModulesGraph+Loading.swift | 1 + Sources/PackageGraph/ModulesGraph.swift | 16 +++++++++------- .../Resolution/PubGrub/ContainerProvider.swift | 1 + .../PubGrub/DiagnosticReportBuilder.swift | 4 ++++ .../PackageGraph/Resolution/ResolvedModule.swift | 1 + 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Package.swift b/Package.swift index 79cf82fa615..889fca31443 100644 --- a/Package.swift +++ b/Package.swift @@ -357,6 +357,7 @@ let package = Package( ], exclude: ["CMakeLists.txt", "README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageGraph/ModulesGraph+Loading.swift b/Sources/PackageGraph/ModulesGraph+Loading.swift index e91f2d8f0a2..03b8ebd1e23 100644 --- a/Sources/PackageGraph/ModulesGraph+Loading.swift +++ b/Sources/PackageGraph/ModulesGraph+Loading.swift @@ -14,6 +14,7 @@ import Basics import OrderedCollections import PackageLoading import PackageModel +import Foundation import func TSCBasic.bestMatch import func TSCBasic.findCycle diff --git a/Sources/PackageGraph/ModulesGraph.swift b/Sources/PackageGraph/ModulesGraph.swift index d0ed47cfdb4..928f3c9d405 100644 --- a/Sources/PackageGraph/ModulesGraph.swift +++ b/Sources/PackageGraph/ModulesGraph.swift @@ -10,12 +10,14 @@ // //===----------------------------------------------------------------------===// -import protocol Basics.FileSystem -import class Basics.ObservabilityScope -import struct Basics.IdentifiableSet import OrderedCollections import PackageLoading import PackageModel +import TSCBasic + +import protocol Basics.FileSystem +import class Basics.ObservabilityScope +import struct Basics.IdentifiableSet enum PackageGraphError: Swift.Error { /// Indicates a non-root package with no modules. @@ -268,7 +270,7 @@ public struct ModulesGraph { for module in rootModules where module.type == .executable { // Find all dependencies of this module within its package. Note that we do not traverse plugin usages. - let dependencies = try topologicalSort(module.dependencies, successors: { + let dependencies = try topologicalSortIdentifiable(module.dependencies, successors: { $0.dependencies.compactMap{ $0.module }.filter{ $0.type != .plugin }.map{ .module($0, conditions: []) } }).compactMap({ $0.module }) @@ -399,12 +401,12 @@ enum GraphError: Error { /// /// - Complexity: O(v + e) where (v, e) are the number of vertices and edges /// reachable from the input nodes via the relation. -func topologicalSort( +func topologicalSortIdentifiable( _ nodes: [T], successors: (T) throws -> [T] ) throws -> [T] { // Implements a topological sort via recursion and reverse postorder DFS. func visit(_ node: T, - _ stack: inout OrderedSet, _ visited: inout Set, _ result: inout [T], + _ stack: inout OrderedCollections.OrderedSet, _ visited: inout Set, _ result: inout [T], _ successors: (T) throws -> [T]) throws { // Mark this node as visited -- we are done if it already was. if !visited.insert(node.id).inserted { @@ -431,7 +433,7 @@ func topologicalSort( // FIXME: This should use a stack not recursion. var visited = Set() var result = [T]() - var stack = OrderedSet() + var stack = OrderedCollections.OrderedSet() for node in nodes { precondition(stack.isEmpty) stack.append(node.id) diff --git a/Sources/PackageGraph/Resolution/PubGrub/ContainerProvider.swift b/Sources/PackageGraph/Resolution/PubGrub/ContainerProvider.swift index 8352c146820..6508e5e145d 100644 --- a/Sources/PackageGraph/Resolution/PubGrub/ContainerProvider.swift +++ b/Sources/PackageGraph/Resolution/PubGrub/ContainerProvider.swift @@ -13,6 +13,7 @@ import Basics import Dispatch import PackageModel +import TSCBasic /// An utility class around PackageContainerProvider that allows "prefetching" the containers /// in parallel. The basic idea is to kick off container fetching before starting the resolution diff --git a/Sources/PackageGraph/Resolution/PubGrub/DiagnosticReportBuilder.swift b/Sources/PackageGraph/Resolution/PubGrub/DiagnosticReportBuilder.swift index 7792390d1eb..c1b6275dcee 100644 --- a/Sources/PackageGraph/Resolution/PubGrub/DiagnosticReportBuilder.swift +++ b/Sources/PackageGraph/Resolution/PubGrub/DiagnosticReportBuilder.swift @@ -10,6 +10,10 @@ // //===----------------------------------------------------------------------===// +import Foundation +import PackageModel +import TSCUtility + struct DiagnosticReportBuilder { let rootNode: DependencyResolutionNode let incompatibilities: [DependencyResolutionNode: [Incompatibility]] diff --git a/Sources/PackageGraph/Resolution/ResolvedModule.swift b/Sources/PackageGraph/Resolution/ResolvedModule.swift index c37e82c26a6..5f4aec5625c 100644 --- a/Sources/PackageGraph/Resolution/ResolvedModule.swift +++ b/Sources/PackageGraph/Resolution/ResolvedModule.swift @@ -12,6 +12,7 @@ import PackageModel +import func TSCBasic.topologicalSort import struct Basics.IdentifiableSet @available(*, deprecated, renamed: "ResolvedModule") From f40e214fa73103100aaf83f6061cddcdd5cec815 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 20:59:27 -0400 Subject: [PATCH 15/35] Adopt MemberImportVisiblity - PackageCollectionsModel --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 889fca31443..7713c6f0c25 100644 --- a/Package.swift +++ b/Package.swift @@ -372,6 +372,7 @@ let package = Package( "Formats/v1.md", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), From cc152fd9ac2c1d3413ca1a6120b72f84cb8c9bd8 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 21:03:10 -0400 Subject: [PATCH 16/35] Adopt MemberImportVisiblity - PackageCollections --- Package.swift | 1 + .../PackageCollections/PackageCollections+Validation.swift | 1 + Sources/PackageCollections/PackageCollections.swift | 1 + .../Providers/JSONPackageCollectionProvider.swift | 3 ++- .../Storage/FilePackageCollectionsSourcesStorage.swift | 5 +++-- .../Storage/SQLitePackageCollectionsStorage.swift | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 7713c6f0c25..be5c15de165 100644 --- a/Package.swift +++ b/Package.swift @@ -388,6 +388,7 @@ let package = Package( "SourceControl", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageCollections/PackageCollections+Validation.swift b/Sources/PackageCollections/PackageCollections+Validation.swift index 3940021555d..c0e7bbd5c2e 100644 --- a/Sources/PackageCollections/PackageCollections+Validation.swift +++ b/Sources/PackageCollections/PackageCollections+Validation.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Basics +import Foundation import PackageCollectionsModel import PackageModel diff --git a/Sources/PackageCollections/PackageCollections.swift b/Sources/PackageCollections/PackageCollections.swift index b37eca329b2..17db7491bf1 100644 --- a/Sources/PackageCollections/PackageCollections.swift +++ b/Sources/PackageCollections/PackageCollections.swift @@ -13,6 +13,7 @@ import _Concurrency import Basics import PackageModel +import Foundation import protocol TSCBasic.Closable diff --git a/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift b/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift index 1df42244400..4e24bb717e0 100644 --- a/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift +++ b/Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift @@ -24,6 +24,7 @@ import PackageCollectionsModel import PackageCollectionsSigning import PackageModel import SourceControl +import TSCBasic import struct TSCUtility.Version @@ -64,7 +65,7 @@ struct JSONPackageCollectionProvider: PackageCollectionProvider { self.httpClient = customHTTPClient ?? Self.makeDefaultHTTPClient() self.signatureValidator = customSignatureValidator ?? PackageCollectionSigning( trustedRootCertsDir: configuration.trustedRootCertsDir ?? - (try? fileSystem.swiftPMConfigurationDirectory.appending("trust-root-certs").asURL) ?? AbsolutePath.root.asURL, + (try? fileSystem.swiftPMConfigurationDirectory.appending("trust-root-certs").asURL) ?? Basics.AbsolutePath.root.asURL, additionalTrustedRootCerts: sourceCertPolicy.allRootCerts.map { Array($0) }, observabilityScope: observabilityScope ) diff --git a/Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift b/Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift index b3760d3b246..ddc24c23f2b 100644 --- a/Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift +++ b/Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift @@ -13,6 +13,7 @@ import _Concurrency import Basics import Dispatch +import TSCBasic import struct Foundation.Data import class Foundation.JSONDecoder import class Foundation.JSONEncoder @@ -20,12 +21,12 @@ import struct Foundation.URL struct FilePackageCollectionsSourcesStorage: PackageCollectionsSourcesStorage { let fileSystem: FileSystem - let path: AbsolutePath + let path: Basics.AbsolutePath private let encoder: JSONEncoder private let decoder: JSONDecoder - init(fileSystem: FileSystem, path: AbsolutePath? = nil) { + init(fileSystem: FileSystem, path: Basics.AbsolutePath? = nil) { self.fileSystem = fileSystem self.path = path ?? (try? fileSystem.swiftPMConfigurationDirectory.appending("collections.json")) ?? .root diff --git a/Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift b/Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift index 30bd2589136..295a496deb7 100644 --- a/Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift +++ b/Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift @@ -20,6 +20,7 @@ import class Foundation.JSONEncoder import class Foundation.NSLock import struct Foundation.URL import PackageModel +import TSCUtility import protocol TSCBasic.Closable From 5915448226cd87f0d523f73ea353fadf22096070 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 21:04:25 -0400 Subject: [PATCH 17/35] Adopt MemberImportVisiblity - PackageCollectionsSigning --- Package.swift | 1 + Sources/PackageCollectionsSigning/PackageCollectionSigning.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Package.swift b/Package.swift index be5c15de165..825cb4b2ccc 100644 --- a/Package.swift +++ b/Package.swift @@ -402,6 +402,7 @@ let package = Package( "PackageCollectionsModel", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageCollectionsSigning/PackageCollectionSigning.swift b/Sources/PackageCollectionsSigning/PackageCollectionSigning.swift index 0903c0fccad..0dbc770acbe 100644 --- a/Sources/PackageCollectionsSigning/PackageCollectionSigning.swift +++ b/Sources/PackageCollectionsSigning/PackageCollectionSigning.swift @@ -15,6 +15,7 @@ import Basics import Dispatch import Foundation import PackageCollectionsModel +import SwiftASN1 #if USE_IMPL_ONLY_IMPORTS @_implementationOnly import _CryptoExtras From c8ff19c5f7a8eeb6d16b45eec2cb79ade6f4d7ba Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 21:06:29 -0400 Subject: [PATCH 18/35] Adopt MemberImportVisiblity - PackageFingerprint --- Package.swift | 1 + .../PackageFingerprint/FilePackageFingerprintStorage.swift | 5 +++-- Sources/PackageFingerprint/PackageFingerprintStorage.swift | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 825cb4b2ccc..af21f338802 100644 --- a/Package.swift +++ b/Package.swift @@ -415,6 +415,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageFingerprint/FilePackageFingerprintStorage.swift b/Sources/PackageFingerprint/FilePackageFingerprintStorage.swift index 54f3c11af01..a0af231bd6c 100644 --- a/Sources/PackageFingerprint/FilePackageFingerprintStorage.swift +++ b/Sources/PackageFingerprint/FilePackageFingerprintStorage.swift @@ -14,17 +14,18 @@ import Basics import Dispatch import Foundation import PackageModel +import TSCBasic import struct TSCUtility.Version public struct FilePackageFingerprintStorage: PackageFingerprintStorage { let fileSystem: FileSystem - let directoryPath: AbsolutePath + let directoryPath: Basics.AbsolutePath private let encoder: JSONEncoder private let decoder: JSONDecoder - public init(fileSystem: FileSystem, directoryPath: AbsolutePath) { + public init(fileSystem: FileSystem, directoryPath: Basics.AbsolutePath) { self.fileSystem = fileSystem self.directoryPath = directoryPath diff --git a/Sources/PackageFingerprint/PackageFingerprintStorage.swift b/Sources/PackageFingerprint/PackageFingerprintStorage.swift index 94355c02a0c..397a8e3f308 100644 --- a/Sources/PackageFingerprint/PackageFingerprintStorage.swift +++ b/Sources/PackageFingerprint/PackageFingerprintStorage.swift @@ -13,6 +13,7 @@ import Basics import Dispatch import PackageModel +import TSCBasic import struct TSCUtility.Version From 47910d5e6d3b7f2a239393afecdcab5c2d8f6933 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Sun, 13 Apr 2025 21:09:39 -0400 Subject: [PATCH 19/35] Adopt MemberImportVisiblity - PackageSigning --- Package.swift | 1 + Sources/PackageSigning/CertificateStores.swift | 2 ++ .../SigningEntity/FilePackageSigningEntityStorage.swift | 5 +++-- Sources/PackageSigning/SigningIdentity.swift | 1 + Sources/PackageSigning/X509Extensions.swift | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index af21f338802..1647a717270 100644 --- a/Package.swift +++ b/Package.swift @@ -430,6 +430,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageSigning/CertificateStores.swift b/Sources/PackageSigning/CertificateStores.swift index 48d3bf22e90..7d001f8484f 100644 --- a/Sources/PackageSigning/CertificateStores.swift +++ b/Sources/PackageSigning/CertificateStores.swift @@ -12,8 +12,10 @@ #if USE_IMPL_ONLY_IMPORTS @_implementationOnly import X509 +@_implementationOnly import SwiftASN1 #else import X509 +import SwiftASN1 #endif enum Certificates { diff --git a/Sources/PackageSigning/SigningEntity/FilePackageSigningEntityStorage.swift b/Sources/PackageSigning/SigningEntity/FilePackageSigningEntityStorage.swift index 91eb7287cbe..28fa216ecbc 100644 --- a/Sources/PackageSigning/SigningEntity/FilePackageSigningEntityStorage.swift +++ b/Sources/PackageSigning/SigningEntity/FilePackageSigningEntityStorage.swift @@ -14,17 +14,18 @@ import Basics import Dispatch import Foundation import PackageModel +import TSCBasic import struct TSCUtility.Version public struct FilePackageSigningEntityStorage: PackageSigningEntityStorage { let fileSystem: FileSystem - let directoryPath: AbsolutePath + let directoryPath: Basics.AbsolutePath private let encoder: JSONEncoder private let decoder: JSONDecoder - public init(fileSystem: FileSystem, directoryPath: AbsolutePath) { + public init(fileSystem: FileSystem, directoryPath: Basics.AbsolutePath) { self.fileSystem = fileSystem self.directoryPath = directoryPath diff --git a/Sources/PackageSigning/SigningIdentity.swift b/Sources/PackageSigning/SigningIdentity.swift index 084bc67d70d..ded10b2a483 100644 --- a/Sources/PackageSigning/SigningIdentity.swift +++ b/Sources/PackageSigning/SigningIdentity.swift @@ -27,6 +27,7 @@ import X509 #endif import Basics +import TSCBasic public protocol SigningIdentity {} diff --git a/Sources/PackageSigning/X509Extensions.swift b/Sources/PackageSigning/X509Extensions.swift index 7045a22ac81..c6f40cbb957 100644 --- a/Sources/PackageSigning/X509Extensions.swift +++ b/Sources/PackageSigning/X509Extensions.swift @@ -29,6 +29,7 @@ import X509 #endif import Basics +import TSCBasic #if canImport(Security) extension Certificate { From 034a721df989d01acbe24bfe3975faa305e5f706 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 14 Apr 2025 21:32:58 -0400 Subject: [PATCH 20/35] Adopt MemberImportVisiblity - SPMBuildCore --- Package.swift | 1 + .../BinaryTarget+Extensions.swift | 7 ++-- .../BuildParameters/BuildParameters.swift | 35 ++++++++++--------- .../Plugins/PluginContextSerializer.swift | 10 +++--- .../Plugins/PluginScriptRunner.swift | 24 +++++++------ .../ResolvedPackage+Extensions.swift | 3 ++ 6 files changed, 45 insertions(+), 35 deletions(-) diff --git a/Package.swift b/Package.swift index 1647a717270..8ee69475d60 100644 --- a/Package.swift +++ b/Package.swift @@ -447,6 +447,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/SPMBuildCore/BinaryTarget+Extensions.swift b/Sources/SPMBuildCore/BinaryTarget+Extensions.swift index 088e7616325..ee91e7ed2b2 100644 --- a/Sources/SPMBuildCore/BinaryTarget+Extensions.swift +++ b/Sources/SPMBuildCore/BinaryTarget+Extensions.swift @@ -14,14 +14,15 @@ import Basics import Foundation import PackageGraph import PackageModel +import TSCBasic /// Information about a library from a binary dependency. public struct LibraryInfo: Equatable { /// The path to the binary. - public let libraryPath: AbsolutePath + public let libraryPath: Basics.AbsolutePath /// The paths to the headers directories. - public let headersPaths: [AbsolutePath] + public let headersPaths: [Basics.AbsolutePath] } /// Information about an executable from a binary dependency. @@ -30,7 +31,7 @@ public struct ExecutableInfo: Equatable { public let name: String /// The path to the executable. - public let executablePath: AbsolutePath + public let executablePath: Basics.AbsolutePath /// Supported triples, e.g. `x86_64-apple-macosx` public let supportedTriples: [Triple] diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift index e4650254a14..a7e926d2c2c 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift @@ -14,6 +14,7 @@ import Basics import class Foundation.ProcessInfo import PackageModel import PackageGraph +import TSCBasic public struct BuildParameters: Encodable { public enum PrepareForIndexingMode: Encodable { @@ -50,7 +51,7 @@ public struct BuildParameters: Encodable { public var destination: Destination /// The path to the data directory. - public var dataPath: AbsolutePath + public var dataPath: Basics.AbsolutePath /// The build configuration. public var configuration: BuildConfiguration @@ -69,7 +70,7 @@ public struct BuildParameters: Encodable { public var flags: BuildFlags /// An array of paths to search for pkg-config `.pc` files. - public var pkgConfigDirectories: [AbsolutePath] + public var pkgConfigDirectories: [Basics.AbsolutePath] /// The architectures to build for. // FIXME: this may be inconsistent with `targetTriple`. @@ -146,13 +147,13 @@ public struct BuildParameters: Encodable { public init( destination: Destination, - dataPath: AbsolutePath, + dataPath: Basics.AbsolutePath, configuration: BuildConfiguration, toolchain: Toolchain, triple: Triple? = nil, flags: BuildFlags, buildSystemKind: BuildSystemProvider.Kind = .native, - pkgConfigDirectories: [AbsolutePath] = [], + pkgConfigDirectories: [Basics.AbsolutePath] = [], architectures: [String]? = nil, workers: UInt32 = UInt32(ProcessInfo.processInfo.activeProcessorCount), shouldCreateDylibForDynamicProducts: Bool = true, @@ -223,7 +224,7 @@ public struct BuildParameters: Encodable { } /// The path to the build directory (inside the data directory). - public var buildPath: AbsolutePath { + public var buildPath: Basics.AbsolutePath { // TODO: query the build system for this. switch buildSystemKind { case .xcode, .swiftbuild: @@ -240,47 +241,47 @@ public struct BuildParameters: Encodable { } /// The path to the index store directory. - public var indexStore: AbsolutePath { + public var indexStore: Basics.AbsolutePath { assert(indexStoreMode != .off, "index store is disabled") return buildPath.appending(components: "index", "store") } /// The path to the code coverage directory. - public var codeCovPath: AbsolutePath { + public var codeCovPath: Basics.AbsolutePath { return buildPath.appending("codecov") } /// The path to the code coverage profdata file. - public var codeCovDataFile: AbsolutePath { + public var codeCovDataFile: Basics.AbsolutePath { return codeCovPath.appending("default.profdata") } - public var llbuildManifest: AbsolutePath { + public var llbuildManifest: Basics.AbsolutePath { // FIXME: this path isn't specific to `BuildParameters` due to its use of `..` // FIXME: it should be calculated in a different place return dataPath.appending(components: "..", configuration.dirname + ".yaml") } - public var pifManifest: AbsolutePath { + public var pifManifest: Basics.AbsolutePath { // FIXME: this path isn't specific to `BuildParameters` due to its use of `..` // FIXME: it should be calculated in a different place return dataPath.appending(components: "..", "manifest.pif") } - public var buildDescriptionPath: AbsolutePath { + public var buildDescriptionPath: Basics.AbsolutePath { // FIXME: this path isn't specific to `BuildParameters`, should be moved one directory level higher return buildPath.appending(components: "description.json") } - public var testOutputPath: AbsolutePath { + public var testOutputPath: Basics.AbsolutePath { return buildPath.appending(component: "testOutput.txt") } /// Returns the path to the binary of a product for the current build parameters. - public func binaryPath(for product: ResolvedProduct) throws -> AbsolutePath { + public func binaryPath(for product: ResolvedProduct) throws -> Basics.AbsolutePath { return try buildPath.appending(binaryRelativePath(for: product)) } - public func macroBinaryPath(_ module: ResolvedModule) throws -> AbsolutePath { + public func macroBinaryPath(_ module: ResolvedModule) throws -> Basics.AbsolutePath { assert(module.type == .macro) #if BUILD_MACROS_AS_DYLIBS return buildPath.appending(try dynamicLibraryPath(for: module.name)) @@ -290,17 +291,17 @@ public struct BuildParameters: Encodable { } /// Returns the path to the dynamic library of a product for the current build parameters. - private func dynamicLibraryPath(for name: String) throws -> RelativePath { + private func dynamicLibraryPath(for name: String) throws -> Basics.RelativePath { try RelativePath(validating: "\(self.triple.dynamicLibraryPrefix)\(name)\(self.suffix)\(self.triple.dynamicLibraryExtension)") } /// Returns the path to the executable of a product for the current build parameters. - package func executablePath(for name: String) throws -> RelativePath { + package func executablePath(for name: String) throws -> Basics.RelativePath { try RelativePath(validating: "\(name)\(self.suffix)\(self.triple.executableExtension)") } /// Returns the path to the binary of a product for the current build parameters, relative to the build directory. - public func binaryRelativePath(for product: ResolvedProduct) throws -> RelativePath { + public func binaryRelativePath(for product: ResolvedProduct) throws -> Basics.RelativePath { switch product.type { case .executable, .snippet: return try executablePath(for: product.name) diff --git a/Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift b/Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift index abb2f6d67c5..83b3b90321d 100644 --- a/Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift +++ b/Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift @@ -15,6 +15,8 @@ import Foundation import PackageGraph import PackageLoading import PackageModel +import TSCBasic +import TSCUtility typealias WireInput = HostToPluginMessage.InputContext @@ -24,10 +26,10 @@ internal struct PluginContextSerializer { let fileSystem: FileSystem let modulesGraph: ModulesGraph let buildEnvironment: BuildEnvironment - let pkgConfigDirectories: [AbsolutePath] - let sdkRootPath: AbsolutePath? + let pkgConfigDirectories: [Basics.AbsolutePath] + let sdkRootPath: Basics.AbsolutePath? var paths: [WireInput.URL] = [] - var pathsToIds: [AbsolutePath: WireInput.URL.Id] = [:] + var pathsToIds: [Basics.AbsolutePath: WireInput.URL.Id] = [:] var targets: [WireInput.Target] = [] var targetsToWireIDs: [ResolvedModule.ID: WireInput.Target.Id] = [:] var products: [WireInput.Product] = [] @@ -42,7 +44,7 @@ internal struct PluginContextSerializer { /// Adds a path to the serialized structure, if it isn't already there. /// Either way, this function returns the path's wire ID. - mutating func serialize(path: AbsolutePath) throws -> WireInput.URL.Id { + mutating func serialize(path: Basics.AbsolutePath) throws -> WireInput.URL.Id { // If we've already seen the path, just return the wire ID we already assigned to it. if let id = pathsToIds[path] { return id } diff --git a/Sources/SPMBuildCore/Plugins/PluginScriptRunner.swift b/Sources/SPMBuildCore/Plugins/PluginScriptRunner.swift index f8d6b569062..fda28b919a0 100644 --- a/Sources/SPMBuildCore/Plugins/PluginScriptRunner.swift +++ b/Sources/SPMBuildCore/Plugins/PluginScriptRunner.swift @@ -16,6 +16,8 @@ import Foundation import PackageModel import PackageLoading import PackageGraph +import TSCBasic +import TSCUtility /// Implements the mechanics of running and communicating with a plugin (implemented as a set of Swift source files). In most environments this is done by compiling the code to an executable, invoking it as a sandboxed subprocess, and communicating with it using pipes. Specific implementations are free to implement things differently, however. public protocol PluginScriptRunner { @@ -23,7 +25,7 @@ public protocol PluginScriptRunner { /// Public protocol function that starts compiling the plugin script to an executable. The name is used as the basename for the executable and auxiliary files. The tools version controls the availability of APIs in PackagePlugin, and should be set to the tools version of the package that defines the plugin (not of the target to which it is being applied). This function returns immediately and then calls the completion handler on the callback queue when compilation ends. @available(*, noasync, message: "Use the async alternative") func compilePluginScript( - sourceFiles: [AbsolutePath], + sourceFiles: [Basics.AbsolutePath], pluginName: String, toolsVersion: ToolsVersion, observabilityScope: ObservabilityScope, @@ -43,13 +45,13 @@ public protocol PluginScriptRunner { /// /// Every concrete implementation should cache any intermediates as necessary to avoid redundant work. func runPluginScript( - sourceFiles: [AbsolutePath], + sourceFiles: [Basics.AbsolutePath], pluginName: String, initialMessage: Data, toolsVersion: ToolsVersion, - workingDirectory: AbsolutePath, - writableDirectories: [AbsolutePath], - readOnlyDirectories: [AbsolutePath], + workingDirectory: Basics.AbsolutePath, + writableDirectories: [Basics.AbsolutePath], + readOnlyDirectories: [Basics.AbsolutePath], allowNetworkConnections: [SandboxNetworkPermission], fileSystem: FileSystem, observabilityScope: ObservabilityScope, @@ -60,12 +62,12 @@ public protocol PluginScriptRunner { /// Returns the Triple that represents the host for which plugin script tools should be built, or for which binary /// tools should be selected. - var hostTriple: Triple { get throws } + var hostTriple: Basics.Triple { get throws } } public extension PluginScriptRunner { func compilePluginScript( - sourceFiles: [AbsolutePath], + sourceFiles: [Basics.AbsolutePath], pluginName: String, toolsVersion: ToolsVersion, observabilityScope: ObservabilityScope, @@ -118,10 +120,10 @@ public struct PluginCompilationResult: Equatable { public var commandLine: [String] /// Path of the compiled executable. - public var executableFile: AbsolutePath + public var executableFile: Basics.AbsolutePath /// Path of the libClang diagnostics file emitted by the compiler. - public var diagnosticsFile: AbsolutePath + public var diagnosticsFile: Basics.AbsolutePath /// Any output emitted by the compiler (stdout and stderr combined). public var rawCompilerOutput: String @@ -132,8 +134,8 @@ public struct PluginCompilationResult: Equatable { public init( succeeded: Bool, commandLine: [String], - executableFile: AbsolutePath, - diagnosticsFile: AbsolutePath, + executableFile: Basics.AbsolutePath, + diagnosticsFile: Basics.AbsolutePath, compilerOutput rawCompilerOutput: String, cached: Bool ) { diff --git a/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift index 509a377a236..e70e3bcdbbc 100644 --- a/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift +++ b/Sources/SPMBuildCore/ResolvedPackage+Extensions.swift @@ -10,6 +10,9 @@ // //===----------------------------------------------------------------------===// +import PackageModel +import TSCUtility + import struct PackageGraph.ResolvedPackage import struct PackageGraph.ResolvedModule From e3ab583c23eb832b800af2a031fac87e3d9346e2 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 14 Apr 2025 21:58:46 -0400 Subject: [PATCH 21/35] Adopt MemberImportVisiblity - Build --- Package.swift | 1 + .../ProductBuildDescription.swift | 3 ++- .../SwiftModuleBuildDescription.swift | 1 + .../LLBuildManifestBuilder+Clang.swift | 1 + .../LLBuildManifestBuilder+Product.swift | 2 ++ .../LLBuildManifestBuilder+Resources.swift | 2 ++ .../LLBuildManifestBuilder+Swift.swift | 8 ++++++- Sources/Build/BuildPlan/BuildPlan+Clang.swift | 5 +++++ Sources/Build/BuildPlan/BuildPlan+Swift.swift | 4 ++++ Sources/Build/BuildPlan/BuildPlan.swift | 21 ++++++++++--------- Sources/Build/LLBuildDescription.swift | 1 + Sources/Build/SwiftCompilerOutputParser.swift | 1 + 12 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Package.swift b/Package.swift index 8ee69475d60..2e01fb3ffd8 100644 --- a/Package.swift +++ b/Package.swift @@ -466,6 +466,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/Build/BuildDescription/ProductBuildDescription.swift b/Sources/Build/BuildDescription/ProductBuildDescription.swift index 742c75154db..a98633d91ad 100644 --- a/Sources/Build/BuildDescription/ProductBuildDescription.swift +++ b/Sources/Build/BuildDescription/ProductBuildDescription.swift @@ -18,6 +18,7 @@ import PackageModel import OrderedCollections import SPMBuildCore +import TSCUtility import struct TSCBasic.SortedArray @@ -434,7 +435,7 @@ extension SortedArray where Element == AbsolutePath { } } -extension Triple { +extension Basics.Triple { var supportsFrameworks: Bool { return self.isDarwin() } diff --git a/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift b/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift index 4eac7878727..347e4c9ca35 100644 --- a/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift @@ -15,6 +15,7 @@ import Basics import Foundation import PackageGraph import PackageLoading +import TSCUtility @_spi(SwiftPMInternal) import PackageModel diff --git a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift index 69962b11bc2..34476408fff 100644 --- a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift +++ b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift @@ -16,6 +16,7 @@ import struct Basics.InternalError import class Basics.ObservabilityScope import struct PackageGraph.ResolvedModule import PackageModel +import SPMBuildCore extension LLBuildManifestBuilder { /// Create a llbuild target for a Clang target description. diff --git a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift index 9817039a4fd..33eb6f4558f 100644 --- a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift +++ b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import PackageModel + import struct Basics.AbsolutePath import struct Basics.InternalError import struct LLBuildManifest.Node diff --git a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Resources.swift b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Resources.swift index 4d72ff35076..1f185cb4ce8 100644 --- a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Resources.swift +++ b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Resources.swift @@ -13,6 +13,8 @@ import struct LLBuildManifest.Node import struct Basics.RelativePath +import PackageModel + extension LLBuildManifestBuilder { /// Adds command for creating the resources bundle of the given target. /// diff --git a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift index 11668bbe1b3..b2679e95b5a 100644 --- a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift +++ b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Swift.swift @@ -24,10 +24,14 @@ import struct Basics.Environment #if USE_IMPL_ONLY_IMPORTS @_implementationOnly import class DriverSupport.SPMSwiftDriverExecutor +@_implementationOnly import Foundation @_implementationOnly import SwiftDriver +@_implementationOnly import TSCUtility #else import class DriverSupport.SPMSwiftDriverExecutor +import Foundation import SwiftDriver +import TSCUtility #endif import PackageModel @@ -81,7 +85,8 @@ extension LLBuildManifestBuilder { args: commandLine, diagnosticsOutput: .handler(self.observabilityScope.makeDiagnosticsHandler()), fileSystem: self.fileSystem, - executor: executor + executor: executor, + compilerIntegratedTooling: false ) try driver.checkLDPathOption(commandLine: commandLine) @@ -297,6 +302,7 @@ extension LLBuildManifestBuilder { args: commandLine, fileSystem: self.fileSystem, executor: executor, + compilerIntegratedTooling: false, externalTargetModuleDetailsMap: dependencyModuleDetailsMap, interModuleDependencyOracle: dependencyOracle ) diff --git a/Sources/Build/BuildPlan/BuildPlan+Clang.swift b/Sources/Build/BuildPlan/BuildPlan+Clang.swift index ca83e4b2e6a..eef1675a3e9 100644 --- a/Sources/Build/BuildPlan/BuildPlan+Clang.swift +++ b/Sources/Build/BuildPlan/BuildPlan+Clang.swift @@ -10,6 +10,11 @@ // //===----------------------------------------------------------------------===// +import Basics +import PackageGraph +import PackageLoading +import SPMBuildCore + import class PackageModel.BinaryModule import class PackageModel.ClangModule import class PackageModel.SwiftModule diff --git a/Sources/Build/BuildPlan/BuildPlan+Swift.swift b/Sources/Build/BuildPlan/BuildPlan+Swift.swift index f0c0b256cbb..d04c86e6033 100644 --- a/Sources/Build/BuildPlan/BuildPlan+Swift.swift +++ b/Sources/Build/BuildPlan/BuildPlan+Swift.swift @@ -16,6 +16,10 @@ import class PackageModel.BinaryModule import class PackageModel.ClangModule import class PackageModel.SystemLibraryModule +import PackageGraph +import PackageLoading +import SPMBuildCore + extension BuildPlan { func plan(swiftTarget: SwiftModuleBuildDescription) throws { // We need to iterate recursive dependencies because Swift compiler needs to see all the targets a target diff --git a/Sources/Build/BuildPlan/BuildPlan.swift b/Sources/Build/BuildPlan/BuildPlan.swift index 01ffe8ec665..22a9727191f 100644 --- a/Sources/Build/BuildPlan/BuildPlan.swift +++ b/Sources/Build/BuildPlan/BuildPlan.swift @@ -19,6 +19,7 @@ import PackageGraph import PackageLoading import PackageModel import SPMBuildCore +import TSCBasic #if USE_IMPL_ONLY_IMPORTS @_implementationOnly import SwiftDriver @@ -90,7 +91,7 @@ extension [String] { extension BuildParameters { /// Returns the directory to be used for module cache. - public var moduleCache: AbsolutePath { + public var moduleCache: Basics.AbsolutePath { get throws { // FIXME: We use this hack to let swiftpm's functional test use shared // cache so it doesn't become painfully slow. @@ -168,9 +169,9 @@ public class BuildPlan: SPMBuildCore.BuildPlan { /// Return value of `inputs()` package enum Input { /// Any file in this directory affects the build plan - case directoryStructure(AbsolutePath) + case directoryStructure(Basics.AbsolutePath) /// The file at the given path affects the build plan - case file(AbsolutePath) + case file(Basics.AbsolutePath) } public enum Error: Swift.Error, CustomStringConvertible, Equatable { @@ -276,7 +277,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan { pluginConfiguration: PluginConfiguration? = nil, pluginTools: [ResolvedModule.ID: [String: PluginTool]] = [:], additionalFileRules: [FileRuleDescription] = [], - pkgConfigDirectories: [AbsolutePath] = [], + pkgConfigDirectories: [Basics.AbsolutePath] = [], disableSandbox: Bool = false, fileSystem: any FileSystem, observabilityScope: ObservabilityScope @@ -698,7 +699,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan { .map { .directoryStructure($0) } // Add the output paths of any prebuilds that were run, so that we redo the plan if they change. - var derivedSourceDirPaths: [AbsolutePath] = [] + var derivedSourceDirPaths: [Basics.AbsolutePath] = [] for result in self.prebuildCommandResults.values.flatMap({ $0 }) { derivedSourceDirPaths.append(contentsOf: result.outputDirectories) } @@ -768,7 +769,7 @@ extension BuildPlan { modulesGraph: ModulesGraph, tools: [ResolvedModule.ID: [String: PluginTool]], additionalFileRules: [FileRuleDescription], - pkgConfigDirectories: [AbsolutePath], + pkgConfigDirectories: [Basics.AbsolutePath], fileSystem: any FileSystem, observabilityScope: ObservabilityScope, surfaceDiagnostics: Bool = false @@ -895,8 +896,8 @@ extension BuildPlan { try pluginResults.map { pluginResult in // As we go we will collect a list of prebuild output directories whose contents should be input to the // build, and a list of the files in those directories after running the commands. - var derivedFiles: [AbsolutePath] = [] - var prebuildOutputDirs: [AbsolutePath] = [] + var derivedFiles: [Basics.AbsolutePath] = [] + var prebuildOutputDirs: [Basics.AbsolutePath] = [] for command in pluginResult.prebuildCommands { observabilityScope .emit( @@ -1248,7 +1249,7 @@ extension Basics.Diagnostic { extension BuildParameters { /// Returns a named bundle's path inside the build directory. - func bundlePath(named name: String) -> AbsolutePath { + func bundlePath(named name: String) -> Basics.AbsolutePath { self.buildPath.appending(component: name + self.triple.nsbundleExtension) } } @@ -1257,7 +1258,7 @@ extension BuildParameters { func generateResourceInfoPlist( fileSystem: FileSystem, target: ResolvedModule, - path: AbsolutePath + path: Basics.AbsolutePath ) throws -> Bool { guard let defaultLocalization = target.defaultLocalization else { return false diff --git a/Sources/Build/LLBuildDescription.swift b/Sources/Build/LLBuildDescription.swift index 81aeec613dd..8149a687129 100644 --- a/Sources/Build/LLBuildDescription.swift +++ b/Sources/Build/LLBuildDescription.swift @@ -15,6 +15,7 @@ import Foundation import LLBuildManifest import SPMBuildCore import PackageGraph +import PackageModel import struct TSCBasic.ByteString diff --git a/Sources/Build/SwiftCompilerOutputParser.swift b/Sources/Build/SwiftCompilerOutputParser.swift index 11eaf585d58..9f06aae52fe 100644 --- a/Sources/Build/SwiftCompilerOutputParser.swift +++ b/Sources/Build/SwiftCompilerOutputParser.swift @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +import Basics import Foundation import class TSCUtility.JSONMessageStreamingParser From 7cae693d9e3b442f3b80ca08e0ef0c1cc1715efc Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 14 Apr 2025 22:01:42 -0400 Subject: [PATCH 22/35] Adopt MemberImportVisiblity - DriverSupport --- Package.swift | 1 + Sources/DriverSupport/DriverSupportUtils.swift | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 2e01fb3ffd8..bae1371fd66 100644 --- a/Package.swift +++ b/Package.swift @@ -479,6 +479,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/DriverSupport/DriverSupportUtils.swift b/Sources/DriverSupport/DriverSupportUtils.swift index 497bd403373..1497ec1b94a 100644 --- a/Sources/DriverSupport/DriverSupportUtils.swift +++ b/Sources/DriverSupport/DriverSupportUtils.swift @@ -12,7 +12,7 @@ @_spi(SwiftPMInternal) import Basics - +import Foundation import PackageModel import SwiftDriver import class TSCBasic.Process @@ -42,6 +42,7 @@ public enum DriverSupport { let driver = try Driver( args: ["swiftc"], executor: executor, + compilerIntegratedTooling: false, compilerExecutableDir: TSCAbsolutePath(toolchain.swiftCompilerPath.parentDirectory) ) let supportedFlagSet = Set(driver.supportedFrontendFlags.map { $0.trimmingCharacters(in: ["-"]) }) From 6f648e1689ea983a88dcdb1fcd1a8d8657616195 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 14 Apr 2025 22:03:37 -0400 Subject: [PATCH 23/35] Adopt MemberImportVisiblity - XCBuildSupport --- Package.swift | 1 + Sources/XCBuildSupport/PIFBuilder.swift | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index bae1371fd66..a3d973d4949 100644 --- a/Package.swift +++ b/Package.swift @@ -493,6 +493,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/XCBuildSupport/PIFBuilder.swift b/Sources/XCBuildSupport/PIFBuilder.swift index 93b88286edc..3d020614783 100644 --- a/Sources/XCBuildSupport/PIFBuilder.swift +++ b/Sources/XCBuildSupport/PIFBuilder.swift @@ -15,6 +15,7 @@ import Foundation import PackageGraph import PackageLoading import PackageModel +import TSCUtility @_spi(SwiftPMInternal) import SPMBuildCore @@ -24,7 +25,7 @@ import func TSCBasic.topologicalSort /// The parameters required by `PIFBuilder`. struct PIFBuilderParameters { - let triple: Triple + let triple: Basics.Triple /// Whether the toolchain supports `-package-name` option. let isPackageAccessModifierSupported: Bool From d369f8853642affc9eca4b5206a0c37660f44bcf Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 14 Apr 2025 22:09:27 -0400 Subject: [PATCH 24/35] Adopt MemberImportVisiblity - SwiftBuildSupport --- Package.swift | 5 ++++- Sources/SwiftBuildSupport/PIFBuilder.swift | 3 ++- .../SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift | 1 + .../PackagePIFProjectBuilder+Products.swift | 3 ++- Sources/SwiftBuildSupport/PackagePIFProjectBuilder.swift | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index a3d973d4949..7d0abd576a3 100644 --- a/Package.swift +++ b/Package.swift @@ -503,7 +503,10 @@ let package = Package( "SPMBuildCore", "PackageGraph", ], - exclude: ["CMakeLists.txt", "README.md"] + exclude: ["CMakeLists.txt", "README.md"], + swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), + ] ), .target( /** High level functionality */ diff --git a/Sources/SwiftBuildSupport/PIFBuilder.swift b/Sources/SwiftBuildSupport/PIFBuilder.swift index e5a4762c926..82ff3afa4e7 100644 --- a/Sources/SwiftBuildSupport/PIFBuilder.swift +++ b/Sources/SwiftBuildSupport/PIFBuilder.swift @@ -15,6 +15,7 @@ import Foundation import PackageGraph import PackageLoading import PackageModel +import TSCUtility @_spi(SwiftPMInternal) import SPMBuildCore @@ -24,7 +25,7 @@ import func TSCBasic.topologicalSort /// The parameters required by `PIFBuilder`. struct PIFBuilderParameters { - let triple: Triple + let triple: Basics.Triple /// Whether the toolchain supports `-package-name` option. let isPackageAccessModifierSupported: Bool diff --git a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift index 89d7d1f7b16..3898369a6a9 100644 --- a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift +++ b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Foundation +import TSCUtility import struct Basics.AbsolutePath import class Basics.ObservabilitySystem diff --git a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift index e44f2b099ff..9b621736daa 100644 --- a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift +++ b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Foundation +import TSCUtility import struct Basics.AbsolutePath import class Basics.ObservabilitySystem @@ -989,7 +990,7 @@ extension PackagePIFProjectBuilder { private struct PackageRegistrySignature: Encodable { enum Source: Encodable { - case registry(url: URL) + case registry(url: Foundation.URL) } let packageIdentity: String diff --git a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder.swift b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder.swift index 149d97e84ab..903c923dbc9 100644 --- a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder.swift +++ b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Foundation +import TSCUtility import struct Basics.AbsolutePath import struct Basics.Diagnostic From 48583c906a72cb003952de130a87fede8527f2b3 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 11:54:00 -0400 Subject: [PATCH 25/35] Adopt MemberImportVisiblity - Workspace --- Package.swift | 1 + Sources/Workspace/InitPackage.swift | 1 + Sources/Workspace/ManagedArtifact.swift | 9 +++-- Sources/Workspace/ManagedDependency.swift | 21 +++++----- Sources/Workspace/ManagedPrebuilt.swift | 3 +- .../RegistryPackageContainer.swift | 5 ++- .../Workspace/Workspace+BinaryArtifacts.swift | 1 + Sources/Workspace/Workspace+Editing.swift | 3 ++ .../Workspace+PackageContainer.swift | 3 ++ Sources/Workspace/Workspace+Prebuilts.swift | 1 + .../Workspace+ResolvedPackages.swift | 2 + .../Workspace/Workspace+SourceControl.swift | 2 + Sources/Workspace/Workspace+State.swift | 39 ++++++++++--------- 13 files changed, 55 insertions(+), 36 deletions(-) diff --git a/Package.swift b/Package.swift index 7d0abd576a3..78d51d8b874 100644 --- a/Package.swift +++ b/Package.swift @@ -524,6 +524,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/Workspace/InitPackage.swift b/Sources/Workspace/InitPackage.swift index 1eb4596918d..1c1fc6b8953 100644 --- a/Sources/Workspace/InitPackage.swift +++ b/Sources/Workspace/InitPackage.swift @@ -13,6 +13,7 @@ import Basics import PackageModel import SPMBuildCore +import TSCUtility import protocol TSCBasic.OutputByteStream diff --git a/Sources/Workspace/ManagedArtifact.swift b/Sources/Workspace/ManagedArtifact.swift index 013d938c3a4..3919250eae0 100644 --- a/Sources/Workspace/ManagedArtifact.swift +++ b/Sources/Workspace/ManagedArtifact.swift @@ -14,6 +14,7 @@ import Basics import PackageGraph import PackageModel import SourceControl +import TSCBasic extension Workspace { /// A downloaded artifact managed by the workspace. @@ -28,7 +29,7 @@ extension Workspace { public let source: Source /// The path of the artifact on disk - public let path: AbsolutePath + public let path: Basics.AbsolutePath public let kind: BinaryModule.Kind @@ -36,7 +37,7 @@ extension Workspace { packageRef: PackageReference, targetName: String, source: Source, - path: AbsolutePath, + path: Basics.AbsolutePath, kind: BinaryModule.Kind ) { self.packageRef = packageRef @@ -52,7 +53,7 @@ extension Workspace { targetName: String, url: String, checksum: String, - path: AbsolutePath, + path: Basics.AbsolutePath, kind: BinaryModule.Kind ) -> ManagedArtifact { return ManagedArtifact( @@ -68,7 +69,7 @@ extension Workspace { public static func local( packageRef: PackageReference, targetName: String, - path: AbsolutePath, + path: Basics.AbsolutePath, kind: BinaryModule.Kind, checksum: String? = nil ) -> ManagedArtifact { diff --git a/Sources/Workspace/ManagedDependency.swift b/Sources/Workspace/ManagedDependency.swift index 30d810c88c2..dfbe53dd111 100644 --- a/Sources/Workspace/ManagedDependency.swift +++ b/Sources/Workspace/ManagedDependency.swift @@ -14,6 +14,7 @@ import Basics import PackageGraph import PackageModel import SourceControl +import TSCBasic import struct TSCUtility.Version @@ -26,7 +27,7 @@ extension Workspace { /// Represents the state of the managed dependency. public indirect enum State: Equatable, CustomStringConvertible { /// The dependency is a local package on the file system. - case fileSystem(AbsolutePath) + case fileSystem(Basics.AbsolutePath) /// The dependency is a managed source control checkout. case sourceControlCheckout(CheckoutState) @@ -39,9 +40,9 @@ extension Workspace { /// If the path is non-nil, the dependency is managed by a user and is /// located at the path. In other words, this dependency is being used /// for top of the tree style development. - case edited(basedOn: ManagedDependency?, unmanagedPath: AbsolutePath?) + case edited(basedOn: ManagedDependency?, unmanagedPath: Basics.AbsolutePath?) - case custom(version: Version, path: AbsolutePath) + case custom(version: Version, path: Basics.AbsolutePath) public var description: String { switch self { @@ -66,12 +67,12 @@ extension Workspace { public let state: State /// The checked out path of the dependency on disk, relative to the workspace checkouts path. - public let subpath: RelativePath + public let subpath: Basics.RelativePath internal init( packageRef: PackageReference, state: State, - subpath: RelativePath + subpath: Basics.RelativePath ) { self.packageRef = packageRef self.subpath = subpath @@ -84,7 +85,7 @@ extension Workspace { /// - Parameters: /// - subpath: The subpath inside the editable directory. /// - unmanagedPath: A custom absolute path instead of the subpath. - public func edited(subpath: RelativePath, unmanagedPath: AbsolutePath?) throws -> ManagedDependency { + public func edited(subpath: Basics.RelativePath, unmanagedPath: Basics.AbsolutePath?) throws -> ManagedDependency { guard case .sourceControlCheckout = self.state else { throw InternalError("invalid dependency state: \(self.state)") } @@ -116,7 +117,7 @@ extension Workspace { public static func sourceControlCheckout( packageRef: PackageReference, state: CheckoutState, - subpath: RelativePath + subpath: Basics.RelativePath ) throws -> ManagedDependency { switch packageRef.kind { case .localSourceControl, .remoteSourceControl: @@ -134,7 +135,7 @@ extension Workspace { public static func registryDownload( packageRef: PackageReference, version: Version, - subpath: RelativePath + subpath: Basics.RelativePath ) throws -> ManagedDependency { guard case .registry = packageRef.kind else { throw InternalError("invalid package type: \(packageRef.kind)") @@ -149,9 +150,9 @@ extension Workspace { /// Create an edited dependency public static func edited( packageRef: PackageReference, - subpath: RelativePath, + subpath: Basics.RelativePath, basedOn: ManagedDependency?, - unmanagedPath: AbsolutePath? + unmanagedPath: Basics.AbsolutePath? ) -> ManagedDependency { return ManagedDependency( packageRef: packageRef, diff --git a/Sources/Workspace/ManagedPrebuilt.swift b/Sources/Workspace/ManagedPrebuilt.swift index 108402e3b26..9c8aafc2343 100644 --- a/Sources/Workspace/ManagedPrebuilt.swift +++ b/Sources/Workspace/ManagedPrebuilt.swift @@ -12,6 +12,7 @@ import Basics import PackageModel +import TSCBasic extension Workspace { /// A downloaded prebuilt managed by the workspace. @@ -23,7 +24,7 @@ extension Workspace { public let libraryName: String /// The path to the extracted prebuilt artifacts - public let path: AbsolutePath + public let path: Basics.AbsolutePath /// The products in the library public let products: [String] diff --git a/Sources/Workspace/PackageContainer/RegistryPackageContainer.swift b/Sources/Workspace/PackageContainer/RegistryPackageContainer.swift index 1a618257df2..208b05dd2e0 100644 --- a/Sources/Workspace/PackageContainer/RegistryPackageContainer.swift +++ b/Sources/Workspace/PackageContainer/RegistryPackageContainer.swift @@ -17,6 +17,7 @@ import PackageGraph import PackageLoading import PackageModel import PackageRegistry +import TSCBasic import struct TSCUtility.Version @@ -178,7 +179,7 @@ public class RegistryPackageContainer: PackageContainer { throw StringError("failed locating placeholder manifest for \(preferredToolsVersion)") } // replace the fake manifest with the real manifest content - let manifestPath = AbsolutePath.root.appending(component: placeholderManifestFileName) + let manifestPath = Basics.AbsolutePath.root.appending(component: placeholderManifestFileName) try fileSystem.removeFileTree(manifestPath) try fileSystem.writeFileContents(manifestPath, string: manifestContent) // finally, load the manifest @@ -202,7 +203,7 @@ public class RegistryPackageContainer: PackageContainer { // ToolsVersionLoader is designed to scan files to decide which is the best tools-version // as such, this writes a fake manifest based on the information returned by the registry // with only the header line which is all that is needed by ToolsVersionLoader - let fileSystem = InMemoryFileSystem() + let fileSystem = Basics.InMemoryFileSystem() for manifest in manifests { let content = manifest.value.content ?? "// swift-tools-version:\(manifest.value.toolsVersion)" try fileSystem.writeFileContents(AbsolutePath.root.appending(component: manifest.key), string: content) diff --git a/Sources/Workspace/Workspace+BinaryArtifacts.swift b/Sources/Workspace/Workspace+BinaryArtifacts.swift index 3fb72f3b984..d7dcfedd382 100644 --- a/Sources/Workspace/Workspace+BinaryArtifacts.swift +++ b/Sources/Workspace/Workspace+BinaryArtifacts.swift @@ -13,6 +13,7 @@ import Basics import Foundation import PackageLoading +import PackageGraph import PackageModel import SPMBuildCore diff --git a/Sources/Workspace/Workspace+Editing.swift b/Sources/Workspace/Workspace+Editing.swift index c38036fc04c..a403ca26931 100644 --- a/Sources/Workspace/Workspace+Editing.swift +++ b/Sources/Workspace/Workspace+Editing.swift @@ -11,6 +11,9 @@ //===----------------------------------------------------------------------===// import _Concurrency +import PackageModel +import TSCBasic + import struct Basics.AbsolutePath import class Basics.InMemoryFileSystem import class Basics.ObservabilityScope diff --git a/Sources/Workspace/Workspace+PackageContainer.swift b/Sources/Workspace/Workspace+PackageContainer.swift index 4787e3adef4..0b0a824f8fd 100644 --- a/Sources/Workspace/Workspace+PackageContainer.swift +++ b/Sources/Workspace/Workspace+PackageContainer.swift @@ -10,6 +10,9 @@ // //===----------------------------------------------------------------------===// +import SourceControl +import TSCBasic + import class Basics.ObservabilityScope import func Dispatch.dispatchPrecondition import class Dispatch.DispatchQueue diff --git a/Sources/Workspace/Workspace+Prebuilts.swift b/Sources/Workspace/Workspace+Prebuilts.swift index 7b58f142e98..8cca15bde2c 100644 --- a/Sources/Workspace/Workspace+Prebuilts.swift +++ b/Sources/Workspace/Workspace+Prebuilts.swift @@ -12,6 +12,7 @@ import Basics import Foundation +import OrderedCollections import PackageModel import protocol TSCBasic.HashAlgorithm diff --git a/Sources/Workspace/Workspace+ResolvedPackages.swift b/Sources/Workspace/Workspace+ResolvedPackages.swift index 4be96b417a1..3586926fba6 100644 --- a/Sources/Workspace/Workspace+ResolvedPackages.swift +++ b/Sources/Workspace/Workspace+ResolvedPackages.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import SourceControl + import class Basics.ObservabilityScope import class PackageGraph.ResolvedPackagesStore import struct PackageModel.PackageReference diff --git a/Sources/Workspace/Workspace+SourceControl.swift b/Sources/Workspace/Workspace+SourceControl.swift index c2afe146c51..773c856e17a 100644 --- a/Sources/Workspace/Workspace+SourceControl.swift +++ b/Sources/Workspace/Workspace+SourceControl.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import TSCBasic + import struct Basics.AbsolutePath import struct Basics.InternalError import class Basics.ObservabilityScope diff --git a/Sources/Workspace/Workspace+State.swift b/Sources/Workspace/Workspace+State.swift index adee2633287..3c395133031 100644 --- a/Sources/Workspace/Workspace+State.swift +++ b/Sources/Workspace/Workspace+State.swift @@ -15,6 +15,7 @@ import Foundation import PackageGraph import PackageModel import SourceControl +import TSCBasic import struct TSCUtility.Version @@ -30,14 +31,14 @@ public actor WorkspaceState { public private(set) var prebuilts: Workspace.ManagedPrebuilts /// Path to the state file. - public let storagePath: AbsolutePath + public let storagePath: Basics.AbsolutePath /// storage private let storage: WorkspaceStateStorage init( fileSystem: FileSystem, - storageDirectory: AbsolutePath, + storageDirectory: Basics.AbsolutePath, initializationWarningHandler: (String) -> Void ) { self.storagePath = storageDirectory.appending("workspace-state.json") @@ -101,12 +102,12 @@ public actor WorkspaceState { // MARK: - Serialization private struct WorkspaceStateStorage { - private let path: AbsolutePath + private let path: Basics.AbsolutePath private let fileSystem: FileSystem private let encoder = JSONEncoder.makeWithDefaults() private let decoder = JSONDecoder.makeWithDefaults() - init(path: AbsolutePath, fileSystem: FileSystem) { + init(path: Basics.AbsolutePath, fileSystem: FileSystem) { self.path = path self.fileSystem = fileSystem } @@ -285,7 +286,7 @@ extension WorkspaceStateStorage { let kind = try container.decode(String.self, forKey: .name) switch kind { case "local", "fileSystem": - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return self.init(underlying: .fileSystem(path)) case "checkout", "sourceControlCheckout": let checkout = try container.decode(CheckoutInfo.self, forKey: .checkoutState) @@ -295,14 +296,14 @@ extension WorkspaceStateStorage { return try self .init(underlying: .registryDownload(version: TSCUtility.Version(versionString: version))) case "edited": - let path = try container.decode(AbsolutePath?.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath?.self, forKey: .path) return try self.init(underlying: .edited( basedOn: basedOn.map { try .init($0) }, unmanagedPath: path )) case "custom": let version = try container.decode(String.self, forKey: .version) - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return try self.init(underlying: .custom( version: TSCUtility.Version(versionString: version), path: path @@ -456,7 +457,7 @@ extension WorkspaceStateStorage { struct Prebuilt: Codable { let packageRef: PackageReference let libraryName: String - let path: AbsolutePath + let path: Basics.AbsolutePath let products: [String] let cModules: [String] @@ -669,7 +670,7 @@ extension WorkspaceStateStorage { let kind = try container.decode(String.self, forKey: .name) switch kind { case "local", "fileSystem": - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return self.init(underlying: .fileSystem(path)) case "checkout", "sourceControlCheckout": let checkout = try container.decode(CheckoutInfo.self, forKey: .checkoutState) @@ -679,14 +680,14 @@ extension WorkspaceStateStorage { return try self .init(underlying: .registryDownload(version: TSCUtility.Version(versionString: version))) case "edited": - let path = try container.decode(AbsolutePath?.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath?.self, forKey: .path) return try self.init(underlying: .edited( basedOn: basedOn.map { try .init($0) }, unmanagedPath: path )) case "custom": let version = try container.decode(String.self, forKey: .version) - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return try self.init(underlying: .custom( version: TSCUtility.Version(versionString: version), path: path @@ -1025,7 +1026,7 @@ extension WorkspaceStateStorage { let kind = try container.decode(String.self, forKey: .name) switch kind { case "local", "fileSystem": - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return self.init(underlying: .fileSystem(path)) case "checkout", "sourceControlCheckout": let checkout = try container.decode(CheckoutInfo.self, forKey: .checkoutState) @@ -1035,14 +1036,14 @@ extension WorkspaceStateStorage { return try self .init(underlying: .registryDownload(version: TSCUtility.Version(versionString: version))) case "edited": - let path = try container.decode(AbsolutePath?.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath?.self, forKey: .path) return try self.init(underlying: .edited( basedOn: basedOn.map { try .init($0) }, unmanagedPath: path )) case "custom": let version = try container.decode(String.self, forKey: .version) - let path = try container.decode(AbsolutePath.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath.self, forKey: .path) return try self.init(underlying: .custom( version: TSCUtility.Version(versionString: version), path: path @@ -1215,7 +1216,7 @@ extension Workspace.ManagedDependency { extension Workspace.ManagedArtifact { fileprivate init(_ artifact: WorkspaceStateStorage.V5.Artifact) throws { - let path = try AbsolutePath(validating: artifact.path) + let path = try Basics.AbsolutePath(validating: artifact.path) try self.init( packageRef: .init(artifact.packageRef), targetName: artifact.targetName, @@ -1337,7 +1338,7 @@ extension WorkspaceStateStorage { let checkout = try container.decode(CheckoutInfo.self, forKey: .checkoutState) return try self.init(underlying: .sourceControlCheckout(.init(checkout))) case "edited": - let path = try container.decode(AbsolutePath?.self, forKey: .path) + let path = try container.decode(Basics.AbsolutePath?.self, forKey: .path) return try self.init(underlying: .edited( basedOn: basedOn.map { try .init($0) }, unmanagedPath: path @@ -1458,7 +1459,7 @@ extension Workspace.ManagedDependency { extension Workspace.ManagedArtifact { fileprivate init(_ artifact: WorkspaceStateStorage.V4.Artifact) throws { - let path = try AbsolutePath(validating: artifact.path) + let path = try Basics.AbsolutePath(validating: artifact.path) try self.init( packageRef: .init(artifact.packageRef), targetName: artifact.targetName, @@ -1479,7 +1480,7 @@ extension PackageModel.PackageReference { case "local": kind = try .fileSystem(.init(validating: reference.location)) case "remote": - if let path = try? AbsolutePath(validating: reference.location) { + if let path = try? Basics.AbsolutePath(validating: reference.location) { kind = .localSourceControl(path) } else { kind = .remoteSourceControl(SourceControlURL(reference.location)) @@ -1512,7 +1513,7 @@ extension CheckoutState { // backwards compatibility for older formats extension BinaryModule.Kind { - fileprivate static func forPath(_ path: AbsolutePath) -> Self { + fileprivate static func forPath(_ path: Basics.AbsolutePath) -> Self { if let kind = allCases.first(where: { $0.fileExtension == path.extension }) { return kind } From 8d90be8b25df46ce42c7d13eff8b331789d7392b Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 11:55:27 -0400 Subject: [PATCH 26/35] Adopt MemberImportVisiblity - PackageMetadata --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 78d51d8b874..7fe97200be8 100644 --- a/Package.swift +++ b/Package.swift @@ -539,6 +539,7 @@ let package = Package( "PackageSigning", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), From 1b246647e8fd8f4403bcc59ad8914030fd4b398d Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 11:57:32 -0400 Subject: [PATCH 27/35] Adopt MemberImportVisiblity - CoreCommands --- Package.swift | 1 + Sources/CoreCommands/BuildSystemSupport.swift | 1 + Sources/CoreCommands/SwiftCommandObservabilityHandler.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/Package.swift b/Package.swift index 7fe97200be8..c13d4456435 100644 --- a/Package.swift +++ b/Package.swift @@ -562,6 +562,7 @@ let package = Package( ], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/CoreCommands/BuildSystemSupport.swift b/Sources/CoreCommands/BuildSystemSupport.swift index 9407a10f8a4..28fa15d1407 100644 --- a/Sources/CoreCommands/BuildSystemSupport.swift +++ b/Sources/CoreCommands/BuildSystemSupport.swift @@ -16,6 +16,7 @@ import SPMBuildCore import XCBuildSupport import SwiftBuildSupport import PackageGraph +import Workspace import class Basics.ObservabilityScope import struct PackageGraph.ModulesGraph diff --git a/Sources/CoreCommands/SwiftCommandObservabilityHandler.swift b/Sources/CoreCommands/SwiftCommandObservabilityHandler.swift index 59b52d15d21..f555d2331d7 100644 --- a/Sources/CoreCommands/SwiftCommandObservabilityHandler.swift +++ b/Sources/CoreCommands/SwiftCommandObservabilityHandler.swift @@ -13,6 +13,7 @@ @_spi(SwiftPMInternal) import Basics import Dispatch +import PackageModel import protocol TSCBasic.OutputByteStream import class TSCBasic.TerminalController From e7b9b1c0fe83e2ae415b9c3fb082d9377c5eb2c1 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 12:54:52 -0400 Subject: [PATCH 28/35] Adopt MemberImportVisiblity - Commands --- Package.swift | 1 + Sources/Commands/PackageCommands/APIDiff.swift | 2 ++ Sources/Commands/PackageCommands/AddDependency.swift | 2 ++ Sources/Commands/PackageCommands/AddProduct.swift | 2 ++ Sources/Commands/PackageCommands/AddTarget.swift | 2 ++ .../Commands/PackageCommands/AddTargetDependency.swift | 2 ++ Sources/Commands/PackageCommands/ArchiveSource.swift | 2 ++ Sources/Commands/PackageCommands/CompletionCommand.swift | 3 +++ Sources/Commands/PackageCommands/Config.swift | 1 + Sources/Commands/PackageCommands/Describe.swift | 2 ++ Sources/Commands/PackageCommands/DumpCommands.swift | 4 ++++ Sources/Commands/PackageCommands/EditCommands.swift | 1 + Sources/Commands/PackageCommands/Format.swift | 5 ++++- Sources/Commands/PackageCommands/Init.swift | 1 + Sources/Commands/PackageCommands/Install.swift | 3 +++ Sources/Commands/PackageCommands/Learn.swift | 1 + Sources/Commands/PackageCommands/PluginCommand.swift | 6 ++++-- Sources/Commands/PackageCommands/ResetCommands.swift | 1 + Sources/Commands/PackageCommands/Resolve.swift | 2 ++ Sources/Commands/PackageCommands/ShowExecutables.swift | 2 ++ Sources/Commands/PackageCommands/Update.swift | 1 + Sources/Commands/Snippets/Cards/SnippetCard.swift | 3 +++ Sources/Commands/Snippets/Cards/SnippetGroupCard.swift | 1 + Sources/Commands/Snippets/Cards/TopCard.swift | 1 + Sources/Commands/SwiftRunCommand.swift | 1 + Sources/Commands/SwiftTestCommand.swift | 1 + Sources/Commands/Utilities/DependenciesSerializer.swift | 2 ++ Sources/Commands/Utilities/MultiRootSupport.swift | 8 +++++--- Sources/Commands/Utilities/SymbolGraphExtract.swift | 1 + Sources/Commands/Utilities/TestingSupport.swift | 1 + 30 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index c13d4456435..ac145564b25 100644 --- a/Package.swift +++ b/Package.swift @@ -585,6 +585,7 @@ let package = Package( ] + swiftSyntaxDependencies(["SwiftIDEUtils"]), exclude: ["CMakeLists.txt", "README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/Commands/PackageCommands/APIDiff.swift b/Sources/Commands/PackageCommands/APIDiff.swift index 416c7a40057..3e114341fe8 100644 --- a/Sources/Commands/PackageCommands/APIDiff.swift +++ b/Sources/Commands/PackageCommands/APIDiff.swift @@ -17,6 +17,8 @@ import Dispatch import PackageGraph import PackageModel import SourceControl +import SPMBuildCore +import TSCUtility import _Concurrency struct DeprecatedAPIDiff: ParsableCommand { diff --git a/Sources/Commands/PackageCommands/AddDependency.swift b/Sources/Commands/PackageCommands/AddDependency.swift index 76b32169c9f..a968965b118 100644 --- a/Sources/Commands/PackageCommands/AddDependency.swift +++ b/Sources/Commands/PackageCommands/AddDependency.swift @@ -13,6 +13,8 @@ import ArgumentParser import Basics import CoreCommands +import Foundation +import PackageGraph import PackageModel import PackageModelSyntax import SwiftParser diff --git a/Sources/Commands/PackageCommands/AddProduct.swift b/Sources/Commands/PackageCommands/AddProduct.swift index 4a60bf1e6db..787dc84ea99 100644 --- a/Sources/Commands/PackageCommands/AddProduct.swift +++ b/Sources/Commands/PackageCommands/AddProduct.swift @@ -13,6 +13,8 @@ import ArgumentParser import Basics import CoreCommands +import Foundation +import PackageGraph import PackageModel import PackageModelSyntax import SwiftParser diff --git a/Sources/Commands/PackageCommands/AddTarget.swift b/Sources/Commands/PackageCommands/AddTarget.swift index 8d9bea9fe5a..a1fb583d15e 100644 --- a/Sources/Commands/PackageCommands/AddTarget.swift +++ b/Sources/Commands/PackageCommands/AddTarget.swift @@ -13,6 +13,8 @@ import ArgumentParser import Basics import CoreCommands +import Foundation +import PackageGraph import PackageModel import PackageModelSyntax import SwiftParser diff --git a/Sources/Commands/PackageCommands/AddTargetDependency.swift b/Sources/Commands/PackageCommands/AddTargetDependency.swift index d629469d4d7..9c888546b5b 100644 --- a/Sources/Commands/PackageCommands/AddTargetDependency.swift +++ b/Sources/Commands/PackageCommands/AddTargetDependency.swift @@ -13,6 +13,8 @@ import ArgumentParser import Basics import CoreCommands +import Foundation +import PackageGraph import PackageModel import PackageModelSyntax import SwiftParser diff --git a/Sources/Commands/PackageCommands/ArchiveSource.swift b/Sources/Commands/PackageCommands/ArchiveSource.swift index bf06cf70c9a..807a9f1a6c8 100644 --- a/Sources/Commands/PackageCommands/ArchiveSource.swift +++ b/Sources/Commands/PackageCommands/ArchiveSource.swift @@ -13,6 +13,8 @@ import ArgumentParser import Basics import CoreCommands +import PackageGraph +import PackageModel import SourceControl extension SwiftPackageCommand { diff --git a/Sources/Commands/PackageCommands/CompletionCommand.swift b/Sources/Commands/PackageCommands/CompletionCommand.swift index c73710aa8ae..10f51bd0676 100644 --- a/Sources/Commands/PackageCommands/CompletionCommand.swift +++ b/Sources/Commands/PackageCommands/CompletionCommand.swift @@ -11,7 +11,10 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import Basics import CoreCommands +import PackageModel +import PackageGraph import var TSCBasic.stdoutStream diff --git a/Sources/Commands/PackageCommands/Config.swift b/Sources/Commands/PackageCommands/Config.swift index 0d61c59a449..6f4b14220b0 100644 --- a/Sources/Commands/PackageCommands/Config.swift +++ b/Sources/Commands/PackageCommands/Config.swift @@ -13,6 +13,7 @@ import ArgumentParser import Basics import CoreCommands +import PackageGraph import Workspace import var TSCBasic.stderrStream diff --git a/Sources/Commands/PackageCommands/Describe.swift b/Sources/Commands/PackageCommands/Describe.swift index 8edeb96b2dc..4392b0040fe 100644 --- a/Sources/Commands/PackageCommands/Describe.swift +++ b/Sources/Commands/PackageCommands/Describe.swift @@ -15,6 +15,8 @@ import Basics import CoreCommands import Foundation import PackageModel +import PackageGraph +import Workspace import struct TSCBasic.StringError diff --git a/Sources/Commands/PackageCommands/DumpCommands.swift b/Sources/Commands/PackageCommands/DumpCommands.swift index be0d9f18b19..3d40e42644e 100644 --- a/Sources/Commands/PackageCommands/DumpCommands.swift +++ b/Sources/Commands/PackageCommands/DumpCommands.swift @@ -15,6 +15,10 @@ import Basics import CoreCommands import Foundation import PackageModel +import PackageGraph +import SPMBuildCore +import TSCBasic +import Workspace import XCBuildSupport struct DumpSymbolGraph: AsyncSwiftCommand { diff --git a/Sources/Commands/PackageCommands/EditCommands.swift b/Sources/Commands/PackageCommands/EditCommands.swift index 6e3bbdc4a0c..f0966e2378d 100644 --- a/Sources/Commands/PackageCommands/EditCommands.swift +++ b/Sources/Commands/PackageCommands/EditCommands.swift @@ -14,6 +14,7 @@ import ArgumentParser import Basics import CoreCommands import SourceControl +import Workspace extension SwiftPackageCommand { struct Edit: AsyncSwiftCommand { diff --git a/Sources/Commands/PackageCommands/Format.swift b/Sources/Commands/PackageCommands/Format.swift index c114a5e25ca..29399d5ec8c 100644 --- a/Sources/Commands/PackageCommands/Format.swift +++ b/Sources/Commands/PackageCommands/Format.swift @@ -14,6 +14,9 @@ import ArgumentParser import Basics import CoreCommands import PackageModel +import PackageGraph +import TSCBasic +import Workspace import class Basics.AsyncProcess @@ -34,7 +37,7 @@ extension SwiftPackageCommand { func run(_ swiftCommandState: SwiftCommandState) async throws { // Look for swift-format binary. // FIXME: This should be moved to user toolchain. - let swiftFormatInEnv = lookupExecutablePath(filename: Environment.current["SWIFT_FORMAT"]) + let swiftFormatInEnv = Basics.lookupExecutablePath(filename: Environment.current["SWIFT_FORMAT"]) guard let swiftFormat = swiftFormatInEnv ?? AsyncProcess.findExecutable("swift-format") else { swiftCommandState.observabilityScope.emit(error: "Could not find swift-format in PATH or SWIFT_FORMAT") throw TSCUtility.Diagnostics.fatalError diff --git a/Sources/Commands/PackageCommands/Init.swift b/Sources/Commands/PackageCommands/Init.swift index 3cc7f87fa24..5eb8293ee2a 100644 --- a/Sources/Commands/PackageCommands/Init.swift +++ b/Sources/Commands/PackageCommands/Init.swift @@ -16,6 +16,7 @@ import Basics @_spi(SwiftPMInternal) import CoreCommands +import PackageModel import Workspace import SPMBuildCore diff --git a/Sources/Commands/PackageCommands/Install.swift b/Sources/Commands/PackageCommands/Install.swift index 1401819b47a..87a0a16c493 100644 --- a/Sources/Commands/PackageCommands/Install.swift +++ b/Sources/Commands/PackageCommands/Install.swift @@ -14,8 +14,11 @@ import ArgumentParser import struct Basics.Environment import CoreCommands import Foundation +import PackageGraph import PackageModel +import SPMBuildCore import TSCBasic +import Workspace extension SwiftPackageCommand { struct Install: AsyncSwiftCommand { diff --git a/Sources/Commands/PackageCommands/Learn.swift b/Sources/Commands/PackageCommands/Learn.swift index 72a9843abdb..176f7cd45fa 100644 --- a/Sources/Commands/PackageCommands/Learn.swift +++ b/Sources/Commands/PackageCommands/Learn.swift @@ -13,6 +13,7 @@ import ArgumentParser import Basics import CoreCommands +import Foundation import PackageGraph import PackageModel diff --git a/Sources/Commands/PackageCommands/PluginCommand.swift b/Sources/Commands/PackageCommands/PluginCommand.swift index 5f05d421f42..fcc9b73192c 100644 --- a/Sources/Commands/PackageCommands/PluginCommand.swift +++ b/Sources/Commands/PackageCommands/PluginCommand.swift @@ -15,10 +15,12 @@ import Basics import _Concurrency import CoreCommands import Dispatch - +import SPMBuildCore import PackageGraph - import PackageModel +import TSCBasic +import TSCUtility +import Workspace struct PluginCommand: AsyncSwiftCommand { static let configuration = CommandConfiguration( diff --git a/Sources/Commands/PackageCommands/ResetCommands.swift b/Sources/Commands/PackageCommands/ResetCommands.swift index 7f010d0932d..2b8e5c02708 100644 --- a/Sources/Commands/PackageCommands/ResetCommands.swift +++ b/Sources/Commands/PackageCommands/ResetCommands.swift @@ -12,6 +12,7 @@ import ArgumentParser import CoreCommands +import Workspace extension SwiftPackageCommand { struct Clean: SwiftCommand { diff --git a/Sources/Commands/PackageCommands/Resolve.swift b/Sources/Commands/PackageCommands/Resolve.swift index cae63da126b..baf18eb9e7b 100644 --- a/Sources/Commands/PackageCommands/Resolve.swift +++ b/Sources/Commands/PackageCommands/Resolve.swift @@ -11,8 +11,10 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import Basics import CoreCommands import TSCUtility +import Workspace import struct PackageGraph.TraitConfiguration diff --git a/Sources/Commands/PackageCommands/ShowExecutables.swift b/Sources/Commands/PackageCommands/ShowExecutables.swift index fb08f22ee90..c1e50248b19 100644 --- a/Sources/Commands/PackageCommands/ShowExecutables.swift +++ b/Sources/Commands/PackageCommands/ShowExecutables.swift @@ -14,6 +14,8 @@ import ArgumentParser import Basics import CoreCommands import Foundation +import PackageModel +import PackageGraph import Workspace struct ShowExecutables: AsyncSwiftCommand { diff --git a/Sources/Commands/PackageCommands/Update.swift b/Sources/Commands/PackageCommands/Update.swift index 31b3738af23..36a09a1aa75 100644 --- a/Sources/Commands/PackageCommands/Update.swift +++ b/Sources/Commands/PackageCommands/Update.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import Basics import CoreCommands import Dispatch import PackageModel diff --git a/Sources/Commands/Snippets/Cards/SnippetCard.swift b/Sources/Commands/Snippets/Cards/SnippetCard.swift index f6ddd901137..d54b916ccf3 100644 --- a/Sources/Commands/Snippets/Cards/SnippetCard.swift +++ b/Sources/Commands/Snippets/Cards/SnippetCard.swift @@ -12,7 +12,10 @@ import Basics import CoreCommands +import Foundation import PackageModel +import PackageGraph +import SPMBuildCore import func TSCBasic.exec import enum TSCBasic.ProcessEnv diff --git a/Sources/Commands/Snippets/Cards/SnippetGroupCard.swift b/Sources/Commands/Snippets/Cards/SnippetGroupCard.swift index cd5e070f1b6..1a27442a5c9 100644 --- a/Sources/Commands/Snippets/Cards/SnippetGroupCard.swift +++ b/Sources/Commands/Snippets/Cards/SnippetGroupCard.swift @@ -12,6 +12,7 @@ import CoreCommands import PackageModel +import TSCUtility /// A card showing the snippets in a ``SnippetGroup``. struct SnippetGroupCard: Card { diff --git a/Sources/Commands/Snippets/Cards/TopCard.swift b/Sources/Commands/Snippets/Cards/TopCard.swift index a1e24c39976..614a20b6080 100644 --- a/Sources/Commands/Snippets/Cards/TopCard.swift +++ b/Sources/Commands/Snippets/Cards/TopCard.swift @@ -14,6 +14,7 @@ import CoreCommands import Foundation import PackageGraph import PackageModel +import TSCUtility /// The top menu card for a package's help contents, including snippets. struct TopCard: Card { diff --git a/Sources/Commands/SwiftRunCommand.swift b/Sources/Commands/SwiftRunCommand.swift index 07d6b3b138f..21c455edd55 100644 --- a/Sources/Commands/SwiftRunCommand.swift +++ b/Sources/Commands/SwiftRunCommand.swift @@ -16,6 +16,7 @@ import CoreCommands import Foundation import PackageGraph import PackageModel +import SPMBuildCore import enum TSCBasic.ProcessEnv import func TSCBasic.exec diff --git a/Sources/Commands/SwiftTestCommand.swift b/Sources/Commands/SwiftTestCommand.swift index 0eaf6b8623c..8c1ede99e02 100644 --- a/Sources/Commands/SwiftTestCommand.swift +++ b/Sources/Commands/SwiftTestCommand.swift @@ -28,6 +28,7 @@ import PackageGraph import PackageModel import SPMBuildCore +import TSCUtility import func TSCLibc.exit import Workspace diff --git a/Sources/Commands/Utilities/DependenciesSerializer.swift b/Sources/Commands/Utilities/DependenciesSerializer.swift index 25190f011c4..d58e5c58162 100644 --- a/Sources/Commands/Utilities/DependenciesSerializer.swift +++ b/Sources/Commands/Utilities/DependenciesSerializer.swift @@ -10,8 +10,10 @@ // //===----------------------------------------------------------------------===// +import Basics import PackageModel import PackageGraph +import TSCUtility import enum TSCBasic.JSON import protocol TSCBasic.OutputByteStream diff --git a/Sources/Commands/Utilities/MultiRootSupport.swift b/Sources/Commands/Utilities/MultiRootSupport.swift index 7ee468a81f5..7cd42e877bc 100644 --- a/Sources/Commands/Utilities/MultiRootSupport.swift +++ b/Sources/Commands/Utilities/MultiRootSupport.swift @@ -13,6 +13,8 @@ import Basics import CoreCommands import Foundation +import TSCBasic + #if canImport(FoundationXML) import FoundationXML #endif @@ -44,7 +46,7 @@ public struct XcodeWorkspaceLoader: WorkspaceLoader { } /// Load the given workspace and return the file ref paths from it. - public func load(workspace: AbsolutePath) throws -> [AbsolutePath] { + public func load(workspace: Basics.AbsolutePath) throws -> [Basics.AbsolutePath] { let path = workspace.appending("contents.xcworkspacedata") let contents: Data = try self.fileSystem.readFileContents(path) @@ -56,9 +58,9 @@ public struct XcodeWorkspaceLoader: WorkspaceLoader { } /// Convert the parsed result into absolute paths. - var result: [AbsolutePath] = [] + var result: [Basics.AbsolutePath] = [] for location in delegate.locations { - let path: AbsolutePath + let path: Basics.AbsolutePath switch location.kind { case .absolute: diff --git a/Sources/Commands/Utilities/SymbolGraphExtract.swift b/Sources/Commands/Utilities/SymbolGraphExtract.swift index cadf1b2a4b4..f18f9aa1b76 100644 --- a/Sources/Commands/Utilities/SymbolGraphExtract.swift +++ b/Sources/Commands/Utilities/SymbolGraphExtract.swift @@ -12,6 +12,7 @@ import ArgumentParser import Basics +import Foundation import PackageGraph import PackageModel import SPMBuildCore diff --git a/Sources/Commands/Utilities/TestingSupport.swift b/Sources/Commands/Utilities/TestingSupport.swift index 84206c5e4dd..5eae29a06aa 100644 --- a/Sources/Commands/Utilities/TestingSupport.swift +++ b/Sources/Commands/Utilities/TestingSupport.swift @@ -14,6 +14,7 @@ import Basics import CoreCommands import PackageModel import SPMBuildCore +import TSCUtility import Workspace import struct TSCBasic.FileSystemError From 0676ca7097894e1e4e222445f97b2cf54db86202 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 12:55:55 -0400 Subject: [PATCH 29/35] Adopt MemberImportVisiblity - SwiftSDKCommand --- Package.swift | 1 + Sources/SwiftSDKCommand/RemoveSwiftSDK.swift | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index ac145564b25..5dbc60a410f 100644 --- a/Package.swift +++ b/Package.swift @@ -602,6 +602,7 @@ let package = Package( ], exclude: ["CMakeLists.txt", "README.md"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/SwiftSDKCommand/RemoveSwiftSDK.swift b/Sources/SwiftSDKCommand/RemoveSwiftSDK.swift index 78bc3248a0d..acb75dff6a3 100644 --- a/Sources/SwiftSDKCommand/RemoveSwiftSDK.swift +++ b/Sources/SwiftSDKCommand/RemoveSwiftSDK.swift @@ -14,6 +14,7 @@ import ArgumentParser import Basics import CoreCommands import PackageModel +import TSCBasic package struct RemoveSwiftSDK: SwiftSDKSubcommand { package static let configuration = CommandConfiguration( @@ -33,12 +34,12 @@ package struct RemoveSwiftSDK: SwiftSDKSubcommand { func run( hostTriple: Triple, - _ swiftSDKsDirectory: AbsolutePath, + _ swiftSDKsDirectory: Basics.AbsolutePath, _ observabilityScope: ObservabilityScope ) async throws { let artifactBundleDirectory = swiftSDKsDirectory.appending(component: self.sdkIDOrBundleName) - let removedBundleDirectory: AbsolutePath + let removedBundleDirectory: Basics.AbsolutePath if fileSystem.exists(artifactBundleDirectory) { try fileSystem.removeFileTree(artifactBundleDirectory) From dcf528cac29ae17c336d496e0f2c280d57aed366 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 12:56:59 -0400 Subject: [PATCH 30/35] Adopt MemberImportVisiblity - PackageCollectionsCommand --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 5dbc60a410f..77f476ee2da 100644 --- a/Package.swift +++ b/Package.swift @@ -619,6 +619,7 @@ let package = Package( "PackageModel", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), From 835852aea01be13e27d4ed2d611589e595e29292 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 18:56:57 -0400 Subject: [PATCH 31/35] Adopt MemberImportVisiblity - PackageRegistryCommand --- Package.swift | 1 + .../PackageRegistryCommand/PackageRegistryCommand+Auth.swift | 3 +++ .../PackageRegistryCommand+Publish.swift | 1 + Sources/PackageRegistryCommand/PackageRegistryCommand.swift | 1 + 4 files changed, 6 insertions(+) diff --git a/Package.swift b/Package.swift index 77f476ee2da..6210426736e 100644 --- a/Package.swift +++ b/Package.swift @@ -642,6 +642,7 @@ let package = Package( "Workspace", ], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-static"]), ] ), diff --git a/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift b/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift index 690253a4ea3..d5658857f10 100644 --- a/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift +++ b/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift @@ -15,8 +15,11 @@ import Basics import Commands import CoreCommands import Foundation +import PackageFingerprint import PackageModel import PackageRegistry +import PackageSigning +import Workspace import struct TSCBasic.SHA256 diff --git a/Sources/PackageRegistryCommand/PackageRegistryCommand+Publish.swift b/Sources/PackageRegistryCommand/PackageRegistryCommand+Publish.swift index e2f4550ac60..1b1ffc700fb 100644 --- a/Sources/PackageRegistryCommand/PackageRegistryCommand+Publish.swift +++ b/Sources/PackageRegistryCommand/PackageRegistryCommand+Publish.swift @@ -16,6 +16,7 @@ import Commands import CoreCommands import Foundation import PackageModel +import PackageFingerprint import PackageRegistry import PackageSigning import Workspace diff --git a/Sources/PackageRegistryCommand/PackageRegistryCommand.swift b/Sources/PackageRegistryCommand/PackageRegistryCommand.swift index 2861b53e336..0b7cd4b88e7 100644 --- a/Sources/PackageRegistryCommand/PackageRegistryCommand.swift +++ b/Sources/PackageRegistryCommand/PackageRegistryCommand.swift @@ -12,6 +12,7 @@ import ArgumentParser import Basics +import Commands import CoreCommands import Foundation import PackageModel From 4a7e73c01e9fb3334363099f069eb0fe427aabb6 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 18:58:43 -0400 Subject: [PATCH 32/35] Adopt MemberImportVisiblity - CompilerPluginSupport --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 6210426736e..dace67ea754 100644 --- a/Package.swift +++ b/Package.swift @@ -751,6 +751,7 @@ let package = Package( dependencies: ["PackageDescription"], exclude: ["CMakeLists.txt"], swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), ] From 52e68392dc4a60551597d750c041d816710eb2a4 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 15 Apr 2025 22:23:28 -0400 Subject: [PATCH 33/35] Adopt MemberImportVisiblity - PackageGraphTests --- Package.swift | 5 ++++- Sources/PackageGraph/ModulesGraph.swift | 2 ++ .../CrossCompilationPackageGraphTests.swift | 1 + Tests/PackageGraphTests/ModulesGraphTests.swift | 4 +++- Tests/PackageGraphTests/TopologicalSortTests.swift | 2 +- Tests/PackageGraphTests/VersionSetSpecifierTests.swift | 1 + 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index dace67ea754..f4b723642ed 100644 --- a/Package.swift +++ b/Package.swift @@ -876,7 +876,10 @@ let package = Package( ), .testTarget( name: "PackageGraphTests", - dependencies: ["PackageGraph", "_InternalTestSupport"] + dependencies: ["PackageGraph", "_InternalTestSupport"], + swiftSettings: [ + .enableExperimentalFeature("MemberImportVisibility"), + ], ), .testTarget( name: "PackageGraphPerformanceTests", diff --git a/Sources/PackageGraph/ModulesGraph.swift b/Sources/PackageGraph/ModulesGraph.swift index 928f3c9d405..d17ab81e06d 100644 --- a/Sources/PackageGraph/ModulesGraph.swift +++ b/Sources/PackageGraph/ModulesGraph.swift @@ -384,6 +384,8 @@ enum GraphError: Error { case unexpectedCycle } +// TODO: Rename this back and only import what is required from TSCBasic to omit importing its implementation of topologicalSort + /// Perform a topological sort of an graph. /// /// This function is optimized for use cases where cycles are unexpected, and diff --git a/Tests/PackageGraphTests/CrossCompilationPackageGraphTests.swift b/Tests/PackageGraphTests/CrossCompilationPackageGraphTests.swift index 5e7119d5b45..88385d33868 100644 --- a/Tests/PackageGraphTests/CrossCompilationPackageGraphTests.swift +++ b/Tests/PackageGraphTests/CrossCompilationPackageGraphTests.swift @@ -17,6 +17,7 @@ import _InternalTestSupport @testable import PackageGraph +import PackageModel import XCTest final class CrossCompilationPackageGraphTests: XCTestCase { diff --git a/Tests/PackageGraphTests/ModulesGraphTests.swift b/Tests/PackageGraphTests/ModulesGraphTests.swift index fa128410127..d840f8e189a 100644 --- a/Tests/PackageGraphTests/ModulesGraphTests.swift +++ b/Tests/PackageGraphTests/ModulesGraphTests.swift @@ -11,6 +11,8 @@ //===----------------------------------------------------------------------===// import Basics +import PackageLoading +import TSCUtility @_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) @testable import PackageGraph @@ -2921,7 +2923,7 @@ final class ModulesGraphTests: XCTestCase { ] let expectedPlatformsForTests = customXCTestMinimumDeploymentTargets - .reduce(into: [Platform: PlatformVersion]()) { partialResult, entry in + .reduce(into: [PackageModel.Platform: PlatformVersion]()) { partialResult, entry in if entry.value > entry.key.oldestSupportedVersion { partialResult[entry.key] = entry.value } else { diff --git a/Tests/PackageGraphTests/TopologicalSortTests.swift b/Tests/PackageGraphTests/TopologicalSortTests.swift index ce357f1b5a3..650c340167b 100644 --- a/Tests/PackageGraphTests/TopologicalSortTests.swift +++ b/Tests/PackageGraphTests/TopologicalSortTests.swift @@ -37,7 +37,7 @@ extension Int { extension Int: @retroactive Identifiable {} private func topologicalSort(_ nodes: [Int], _ successors: [Int: [Int]]) throws -> [Int] { - return try topologicalSort(nodes, successors: { successors[$0] ?? [] }) + return try topologicalSortIdentifiable(nodes, successors: { successors[$0] ?? [] }) } private func topologicalSort(_ node: Int, _ successors: [Int: [Int]]) throws -> [Int] { return try topologicalSort([node], successors) diff --git a/Tests/PackageGraphTests/VersionSetSpecifierTests.swift b/Tests/PackageGraphTests/VersionSetSpecifierTests.swift index a79e635b02e..6fa280c8815 100644 --- a/Tests/PackageGraphTests/VersionSetSpecifierTests.swift +++ b/Tests/PackageGraphTests/VersionSetSpecifierTests.swift @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// import Foundation +import TSCUtility import XCTest import PackageGraph From a96a73331d151f0c8149c0df575261d9180b557c Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Thu, 17 Apr 2025 14:32:30 -0400 Subject: [PATCH 34/35] Cleanup --- Package.swift | 2 +- Sources/PackageGraph/ModulesGraph.swift | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index f4b723642ed..3a490d54538 100644 --- a/Package.swift +++ b/Package.swift @@ -879,7 +879,7 @@ let package = Package( dependencies: ["PackageGraph", "_InternalTestSupport"], swiftSettings: [ .enableExperimentalFeature("MemberImportVisibility"), - ], + ] ), .testTarget( name: "PackageGraphPerformanceTests", diff --git a/Sources/PackageGraph/ModulesGraph.swift b/Sources/PackageGraph/ModulesGraph.swift index d17ab81e06d..928f3c9d405 100644 --- a/Sources/PackageGraph/ModulesGraph.swift +++ b/Sources/PackageGraph/ModulesGraph.swift @@ -384,8 +384,6 @@ enum GraphError: Error { case unexpectedCycle } -// TODO: Rename this back and only import what is required from TSCBasic to omit importing its implementation of topologicalSort - /// Perform a topological sort of an graph. /// /// This function is optimized for use cases where cycles are unexpected, and From 32d6aff888c443a461c22198e91a586ca9d0850b Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Thu, 17 Apr 2025 20:26:12 -0400 Subject: [PATCH 35/35] Refactor out settings in to a variable, don't use MemberImportVisibility on targets that fail to compile with 6.0.3 --- Package.swift | 114 ++++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 68 deletions(-) diff --git a/Package.swift b/Package.swift index 3a490d54538..f609be16e3a 100644 --- a/Package.swift +++ b/Package.swift @@ -35,6 +35,19 @@ if let resourceDirPath = ProcessInfo.processInfo.environment["SWIFTCI_INSTALL_RP packageLibraryLinkSettings = [] } +// Common experimental flags to be added to all targets. +let commonExperimentalFeatures: [SwiftSetting] = [ + .enableExperimentalFeature("MemberImportVisibility"), +] + +// Certain targets fail to compile with MemberImportVisibility enabled on 6.0.3 +// but work with >=6.1. These targets opt in to using `swift6CompatibleExperimentalFeatures`. +#if swift(>=6.1) +let swift6CompatibleExperimentalFeatures = commonExperimentalFeatures +#else +let swift6CompatibleExperimentalFeatures: [SwiftSetting] = [] +#endif + /** SwiftPMDataModel is the subset of SwiftPM product that includes just its data model. This allows some clients (such as IDEs) that use SwiftPM's data model but not its build system to not have to depend on SwiftDriver, SwiftLLBuild, etc. We should probably have better names here, @@ -152,8 +165,7 @@ let package = Package( .target( name: "PackageDescription", exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .define("USE_IMPL_ONLY_IMPORTS"), .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), @@ -170,8 +182,7 @@ let package = Package( // AppleProductTypes library when they import it without further // messing with the manifest loader. dependencies: ["PackageDescription"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"], .when(platforms: [.macOS])), .unsafeFlags(["-Xfrontend", "-module-link-name", "-Xfrontend", "AppleProductTypes"]) @@ -183,8 +194,7 @@ let package = Package( .target( name: "PackagePlugin", exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), ], @@ -202,8 +212,7 @@ let package = Package( "SPMBuildCore", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .enableExperimentalFeature("AccessLevelOnImport"), .unsafeFlags(["-static"]), ] @@ -219,8 +228,7 @@ let package = Package( .product(name: "SystemPackage", package: "swift-system"), ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .enableExperimentalFeature("StrictConcurrency"), .enableExperimentalFeature("AccessLevelOnImport"), .enableExperimentalFeature("InternalImportsByDefault"), @@ -240,8 +248,7 @@ let package = Package( .product(name: "SystemPackage", package: "swift-system"), ], exclude: ["CMakeLists.txt", "Vendor/README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: swift6CompatibleExperimentalFeatures + [ .enableExperimentalFeature("StrictConcurrency"), .enableExperimentalFeature("AccessLevelOnImport"), .unsafeFlags(["-static"]), @@ -253,8 +260,7 @@ let package = Package( name: "LLBuildManifest", dependencies: ["Basics"], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -270,8 +276,7 @@ let package = Package( "PackageSigning", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -284,8 +289,7 @@ let package = Package( "PackageModel", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -295,8 +299,7 @@ let package = Package( name: "SPMLLBuild", dependencies: ["Basics"], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -308,8 +311,7 @@ let package = Package( name: "PackageModel", dependencies: ["Basics"], exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: swift6CompatibleExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -323,8 +325,7 @@ let package = Package( "PackageModel", ] + swiftSyntaxDependencies(["SwiftBasicFormat", "SwiftDiagnostics", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax", "SwiftSyntaxBuilder"]), exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -338,8 +339,7 @@ let package = Package( "SourceControl", ], exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -356,8 +356,7 @@ let package = Package( .product(name: "OrderedCollections", package: "swift-collections"), ], exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -371,8 +370,7 @@ let package = Package( exclude: [ "Formats/v1.md", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -387,8 +385,7 @@ let package = Package( "PackageModel", "SourceControl", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: swift6CompatibleExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -401,8 +398,7 @@ let package = Package( "Basics", "PackageCollectionsModel", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -414,8 +410,7 @@ let package = Package( "PackageModel", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -429,8 +424,7 @@ let package = Package( "PackageModel", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -446,8 +440,7 @@ let package = Package( .product(name: "OrderedCollections", package: "swift-collections"), ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -465,8 +458,7 @@ let package = Package( "DriverSupport", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -478,8 +470,7 @@ let package = Package( .product(name: "SwiftDriver", package: "swift-driver"), ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -492,8 +483,7 @@ let package = Package( .product(name: "OrderedCollections", package: "swift-collections"), ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -504,9 +494,7 @@ let package = Package( "PackageGraph", ], exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), - ] + swiftSettings: commonExperimentalFeatures ), .target( /** High level functionality */ @@ -523,8 +511,7 @@ let package = Package( .product(name: "OrderedCollections", package: "swift-collections"), ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -538,8 +525,7 @@ let package = Package( "PackageRegistry", "PackageSigning", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -561,8 +547,7 @@ let package = Package( "SwiftBuildSupport", ], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -584,8 +569,7 @@ let package = Package( "SwiftBuildSupport", ] + swiftSyntaxDependencies(["SwiftIDEUtils"]), exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: swift6CompatibleExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -601,8 +585,7 @@ let package = Package( "PackageModel", ], exclude: ["CMakeLists.txt", "README.md"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -618,8 +601,7 @@ let package = Package( "PackageCollections", "PackageModel", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -641,8 +623,7 @@ let package = Package( "SPMBuildCore", "Workspace", ], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-static"]), ] ), @@ -750,8 +731,7 @@ let package = Package( name: "CompilerPluginSupport", dependencies: ["PackageDescription"], exclude: ["CMakeLists.txt"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), + swiftSettings: commonExperimentalFeatures + [ .unsafeFlags(["-package-description-version", "999.0"]), .unsafeFlags(["-enable-library-evolution"]), ] @@ -877,9 +857,7 @@ let package = Package( .testTarget( name: "PackageGraphTests", dependencies: ["PackageGraph", "_InternalTestSupport"], - swiftSettings: [ - .enableExperimentalFeature("MemberImportVisibility"), - ] + swiftSettings: commonExperimentalFeatures ), .testTarget( name: "PackageGraphPerformanceTests",