From 4f2e2c39db4e1c51482c0799f002f3712c4360df Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 17 Oct 2024 09:48:11 +0900 Subject: [PATCH 1/4] Drop all backward compatibilities --- Package@swift-5.10.swift | 89 ------------------- Package@swift-5.9.swift | 77 ---------------- Plugins/GenerateScipioVersion/plugin.swift | 13 --- Sources/ScipioKit/DescriptionPackage.swift | 28 ------ Sources/ScipioKit/Executor.swift | 20 ----- .../Producer/Cache/CacheSystem.swift | 35 -------- .../Producer/FrameworkProducer.swift | 6 -- .../Producer/InfoPlistGenerator.swift | 4 - .../PIF/BuildParametersGenerator.swift | 6 -- .../ScipioKit/Producer/PIF/PIFCompiler.swift | 22 ----- .../ScipioKit/Producer/PIF/PIFGenerator.swift | 19 ---- .../Producer/PIF/ToolchainGenerator.swift | 27 ------ .../Producer/PIF/XCBuildExecutor.swift | 2 - Sources/ScipioKit/Runner.swift | 4 - Sources/ScipioKit/SwiftPM+Compatibility.swift | 63 ------------- Sources/scipio/Arguments.swift | 12 --- Tests/ScipioKitTests/CacheSystemTests.swift | 5 -- 17 files changed, 432 deletions(-) delete mode 100644 Package@swift-5.10.swift delete mode 100644 Package@swift-5.9.swift diff --git a/Package@swift-5.10.swift b/Package@swift-5.10.swift deleted file mode 100644 index 496f5e05..00000000 --- a/Package@swift-5.10.swift +++ /dev/null @@ -1,89 +0,0 @@ -// swift-tools-version: 5.10 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription -import Foundation - -let swiftSettings: [SwiftSetting] = [ - .enableExperimentalFeature("StrictConcurrency"), - .unsafeFlags(["-strict-concurrency=complete"]), -] - -let package = Package( - name: "Scipio", - platforms: [ - .macOS(.v13), - ], - products: [ - .executable(name: "scipio", - targets: ["scipio"]), - .library( - name: "ScipioKit", - targets: ["ScipioKit"]), - ], - dependencies: [ - .package(url: "https://github.com/swiftlang/swift-package-manager.git", - revision: "swift-5.10-RELEASE"), - .package(url: "https://github.com/apple/swift-log.git", - from: "1.5.2"), - .package(url: "https://github.com/apple/swift-collections", - from: "1.0.4"), - .package(url: "https://github.com/apple/swift-argument-parser.git", - from: "1.1.0"), - .package(url: "https://github.com/apple/swift-algorithms.git", - from: "1.0.0"), - .package(url: "https://github.com/onevcat/Rainbow", - .upToNextMinor(from: "4.0.1")), - .package(url: "https://github.com/giginet/scipio-cache-storage.git", - from: "1.0.0"), - ], - targets: [ - .executableTarget( - name: "scipio", - dependencies: [ - .target(name: "ScipioKit"), - .product(name: "ArgumentParser", package: "swift-argument-parser"), - ], - swiftSettings: swiftSettings - ), - .target( - name: "ScipioKit", - dependencies: [ - .product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"), - .product(name: "XCBuildSupport", package: "swift-package-manager"), - .product(name: "Logging", package: "swift-log"), - .product(name: "Collections", package: "swift-collections"), - .product(name: "Algorithms", package: "swift-algorithms"), - .product(name: "Rainbow", package: "Rainbow"), - .product(name: "ScipioStorage", package: "scipio-cache-storage"), - ], - swiftSettings: swiftSettings, - plugins: [ - .plugin(name: "GenerateScipioVersion") - ] - ), - .plugin( - name: "GenerateScipioVersion", - capability: .buildTool() - ), - .testTarget( - name: "ScipioKitTests", - dependencies: [ - .target(name: "ScipioKit"), - ], - exclude: ["Resources/Fixtures/"], - resources: [.copy("Resources/Fixtures")], - swiftSettings: swiftSettings - ), - ] -) - -let isDevelopment = ProcessInfo.processInfo.environment["SCIPIO_DEVELOPMENT"] == "1" - -// swift-docs is not needed for package users -if isDevelopment { - package.dependencies += [ - .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.3.0"), - .package(url: "https://github.com/freddi-kit/ArtifactBundleGen.git", from: "0.0.6"), - ] -} diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift deleted file mode 100644 index 9db58fac..00000000 --- a/Package@swift-5.9.swift +++ /dev/null @@ -1,77 +0,0 @@ -// swift-tools-version: 5.8 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription -import Foundation - -let package = Package( - name: "Scipio", - platforms: [ - .macOS(.v13), - ], - products: [ - .executable(name: "scipio", - targets: ["scipio"]), - .library( - name: "ScipioKit", - targets: ["ScipioKit"]), - ], - dependencies: [ - .package(url: "https://github.com/swiftlang/swift-package-manager.git", - revision: "swift-5.9-RELEASE"), - .package(url: "https://github.com/apple/swift-log.git", - .upToNextMinor(from: "1.4.2")), - .package(url: "https://github.com/apple/swift-collections", - from: "1.0.4"), - .package(url: "https://github.com/apple/swift-argument-parser.git", - from: "1.1.0"), - .package(url: "https://github.com/apple/swift-algorithms.git", - from: "1.0.0"), - .package(url: "https://github.com/onevcat/Rainbow", - .upToNextMinor(from: "4.0.1")), - .package(url: "https://github.com/giginet/scipio-cache-storage.git", - from: "1.0.0"), - ], - targets: [ - .executableTarget(name: "scipio", - dependencies: [ - .target(name: "ScipioKit"), - .product(name: "ArgumentParser", package: "swift-argument-parser"), - ]), - .target( - name: "ScipioKit", - dependencies: [ - .product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"), - .product(name: "XCBuildSupport", package: "swift-package-manager"), - .product(name: "Logging", package: "swift-log"), - .product(name: "Collections", package: "swift-collections"), - .product(name: "Algorithms", package: "swift-algorithms"), - .product(name: "Rainbow", package: "Rainbow"), - .product(name: "ScipioStorage", package: "scipio-cache-storage"), - ], - plugins: [ - .plugin(name: "GenerateScipioVersion") - ] - ), - .plugin( - name: "GenerateScipioVersion", - capability: .buildTool() - ), - .testTarget( - name: "ScipioKitTests", - dependencies: [ - .target(name: "ScipioKit"), - ], - exclude: ["Resources/Fixtures/"], - resources: [.copy("Resources/Fixtures")]), - ] -) - -let isDevelopment = ProcessInfo.processInfo.environment["SCIPIO_DEVELOPMENT"] == "1" - -// swift-docs is not needed for package users -if isDevelopment { - package.dependencies += [ - .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.3.0"), - ] -} diff --git a/Plugins/GenerateScipioVersion/plugin.swift b/Plugins/GenerateScipioVersion/plugin.swift index fabe9d6d..17fd5e60 100644 --- a/Plugins/GenerateScipioVersion/plugin.swift +++ b/Plugins/GenerateScipioVersion/plugin.swift @@ -6,11 +6,7 @@ struct GenerateScipioVersion: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { let zshPath = URL(filePath: "/bin/zsh") // execute dummy command - #if compiler(>=6.0) let generatedSourceDir = context.pluginWorkDirectoryURL - #else - let generatedSourceDir = URL(filePath: context.pluginWorkDirectory.string) - #endif let generatedSourcePath = generatedSourceDir .appending(component: "ScipioVersion.generated.swift") @@ -43,11 +39,7 @@ struct GenerateScipioVersion: BuildToolPlugin { let standardOutput = Pipe() let process = Process() - #if compiler(>=6.0) let repositoryPath = context.package.directoryURL.path() - #else - let repositoryPath = context.package.directory.string - #endif process.executableURL = URL(fileURLWithPath: "/usr/bin/git") process.arguments = [ @@ -68,9 +60,6 @@ struct GenerateScipioVersion: BuildToolPlugin { } } -#if compiler(<6.0) - -// Backward compatibility below 6.0 compiler // Convert Foundation.URL to Path extension Command { fileprivate static func prebuildCommand( @@ -88,5 +77,3 @@ extension Command { ) } } - -#endif diff --git a/Sources/ScipioKit/DescriptionPackage.swift b/Sources/ScipioKit/DescriptionPackage.swift index 8603aff6..8cdae2b4 100644 --- a/Sources/ScipioKit/DescriptionPackage.swift +++ b/Sources/ScipioKit/DescriptionPackage.swift @@ -121,11 +121,7 @@ struct DescriptionPackage { self.packageDirectory = packageDirectory self.mode = mode - #if swift(>=5.10) let toolchain = try UserToolchain(swiftSDK: try .hostSwiftSDK()) - #else - let toolchain = try UserToolchain(destination: try .hostDestination()) - #endif self.toolchain = toolchain let workspace = try Self.makeWorkspace(toolchain: toolchain, packagePath: packageDirectory) @@ -215,17 +211,10 @@ private final class BuildProductsResolver { products = try topologicalSort(products) { (product) in return product.target.dependencies.flatMap { (dependency) -> [BuildProduct] in switch dependency { - #if compiler(>=6.0) case .module(let module, conditions: _): return [resolvedTargetToBuildProduct(module)] case .product(let product, conditions: _): return product.modules.map(resolvedTargetToBuildProduct) - #else - case .target(let target, conditions: _): - return [resolvedTargetToBuildProduct(target)] - case .product(let product, conditions: _): - return product.targets.map(resolvedTargetToBuildProduct) - #endif } } } @@ -247,19 +236,11 @@ private final class BuildProductsResolver { let rootPackage = try fetchRootPackage() let productNamesToBuild = rootPackage.manifest.products.map { $0.name } let productsToBuild = rootPackage.products.filter { productNamesToBuild.contains($0.name) } - #if compiler(>=6.0) return productsToBuild.flatMap(\.modules) - #else - return productsToBuild.flatMap(\.targets) - #endif case .prepareDependencies: // In prepare mode, all targets should be built // In future update, users will be enable to specify targets want to build - #if compiler(>=6.0) return Array(try fetchRootPackage().modules) - #else - return try fetchRootPackage().targets - #endif } } @@ -271,13 +252,8 @@ private final class BuildProductsResolver { } private func resolveBuildProduct(from rootTarget: ScipioResolvedModule) throws -> Set { - #if compiler(>=6.0) let dependencyProducts = Set(try rootTarget.recursiveModuleDependencies() .flatMap(buildProducts(from:))) - #else - let dependencyProducts = Set(try rootTarget.recursiveTargetDependencies() - .flatMap(buildProducts(from:))) - #endif switch descriptionPackage.mode { case .createPackage: @@ -301,11 +277,7 @@ private final class BuildProductsResolver { return buildProducts } - #if compiler(>=6.0) let dependencyProducts = try target.recursiveDependencies().compactMap(\.module).flatMap(buildProducts(from:)) - #else - let dependencyProducts = try target.recursiveDependencies().compactMap(\.target).flatMap(buildProducts(from:)) - #endif let buildProducts = Set([rootTargetProduct] + dependencyProducts) buildProductsCache.updateValue(buildProducts, forKey: rootTargetProduct) diff --git a/Sources/ScipioKit/Executor.swift b/Sources/ScipioKit/Executor.swift index 4d55e05f..07bafcae 100644 --- a/Sources/ScipioKit/Executor.swift +++ b/Sources/ScipioKit/Executor.swift @@ -37,7 +37,6 @@ extension Executor { extension ProcessResult { mutating func setOutput(_ newValue: Result<[UInt8], Swift.Error>) { - #if compiler(>=6.0) self = ProcessResult( arguments: arguments, environmentBlock: environmentBlock, @@ -45,19 +44,9 @@ extension ProcessResult { output: newValue, stderrOutput: stderrOutput ) - #else - self = ProcessResult( - arguments: arguments, - environment: environment, - exitStatus: exitStatus, - output: newValue, - stderrOutput: stderrOutput - ) - #endif } mutating func setStderrOutput(_ newValue: Result<[UInt8], Swift.Error>) { - #if compiler(>=6.0) self = ProcessResult( arguments: arguments, environmentBlock: environmentBlock, @@ -65,15 +54,6 @@ extension ProcessResult { output: output, stderrOutput: newValue ) - #else - self = ProcessResult( - arguments: arguments, - environment: environment, - exitStatus: exitStatus, - output: output, - stderrOutput: newValue - ) - #endif } } diff --git a/Sources/ScipioKit/Producer/Cache/CacheSystem.swift b/Sources/ScipioKit/Producer/Cache/CacheSystem.swift index e4badedb..a0a34110 100644 --- a/Sources/ScipioKit/Producer/Cache/CacheSystem.swift +++ b/Sources/ScipioKit/Producer/Cache/CacheSystem.swift @@ -79,8 +79,6 @@ extension PinsStore.PinState: Codable { } } -#if compiler(>=6.0) - extension PinsStore.PinState: @retroactive Hashable { public func hash(into hasher: inout Hasher) { switch self { @@ -96,25 +94,6 @@ extension PinsStore.PinState: @retroactive Hashable { } } -#else - -extension PinsStore.PinState: Hashable { - public func hash(into hasher: inout Hasher) { - switch self { - case .revision(let revision): - hasher.combine(revision) - case .version(let version, let revision): - hasher.combine(version) - hasher.combine(revision) - case .branch(let branchName, let revision): - hasher.combine(branchName) - hasher.combine(revision) - } - } -} - -#endif - public struct SwiftPMCacheKey: CacheKey { public var targetName: String public var pin: PinsStore.PinState @@ -272,19 +251,9 @@ struct CacheSystem: Sendable { } private func retrievePin(package: ResolvedPackage) throws -> PinsStore.Pin { - #if compiler(>=6.0) guard let pin = pinsStore.pins[package.identity] ?? package.makePinFromRevision() else { throw Error.revisionNotDetected(package.manifest.displayName) } - #elseif swift(>=5.10) - guard let pin = pinsStore.pins[package.identity] else { - throw Error.revisionNotDetected(package.manifest.displayName) - } - #else - guard let pin = pinsStore.pinsMap[package.identity] else { - throw Error.revisionNotDetected(package.manifest.displayName) - } - #endif return pin } @@ -313,8 +282,6 @@ public struct VersionFileDecoder { } } -#if compiler(>=6.0) - extension ResolvedPackage { fileprivate func makePinFromRevision() -> PinsStore.Pin? { let repository = GitRepository(path: path) @@ -337,5 +304,3 @@ extension ResolvedPackage { ) } } - -#endif diff --git a/Sources/ScipioKit/Producer/FrameworkProducer.swift b/Sources/ScipioKit/Producer/FrameworkProducer.swift index 3b3c7c9f..cfb5be6f 100644 --- a/Sources/ScipioKit/Producer/FrameworkProducer.swift +++ b/Sources/ScipioKit/Producer/FrameworkProducer.swift @@ -243,15 +243,9 @@ struct FrameworkProducer { outputDirectory: outputDir, overwrite: overwrite) case .binary: - #if compiler(>=6.0) guard let binaryTarget = product.target.underlying as? BinaryModule else { fatalError("Unexpected failure") } - #else - guard let binaryTarget = product.target.underlyingTarget as? BinaryTarget else { - fatalError("Unexpected failure") - } - #endif let binaryExtractor = BinaryExtractor( package: descriptionPackage, outputDirectory: outputDir, diff --git a/Sources/ScipioKit/Producer/InfoPlistGenerator.swift b/Sources/ScipioKit/Producer/InfoPlistGenerator.swift index ce8f4093..9fa266c4 100644 --- a/Sources/ScipioKit/Producer/InfoPlistGenerator.swift +++ b/Sources/ScipioKit/Producer/InfoPlistGenerator.swift @@ -10,11 +10,7 @@ struct InfoPlistGenerator { func generateForResourceBundle(at path: AbsolutePath) throws { let body = resourceBundleBody - #if swift(>=5.10) try fileSystem.writeFileContents(path.spmAbsolutePath, string: body) - #else - try fileSystem.writeFileContents(path, string: body) - #endif } private var resourceBundleBody: String { diff --git a/Sources/ScipioKit/Producer/PIF/BuildParametersGenerator.swift b/Sources/ScipioKit/Producer/PIF/BuildParametersGenerator.swift index 2954709b..c7edc90e 100644 --- a/Sources/ScipioKit/Producer/PIF/BuildParametersGenerator.swift +++ b/Sources/ScipioKit/Producer/PIF/BuildParametersGenerator.swift @@ -36,13 +36,7 @@ struct BuildParametersGenerator { } func generate(for sdk: SDK, buildParameters: BuildParameters, destinationDir: AbsolutePath) throws -> AbsolutePath { - #if compiler(>=6.0) let targetArchitecture = buildParameters.triple.arch?.rawValue ?? "arm64" - #elseif swift(>=5.10) - let targetArchitecture = buildParameters.targetTriple.arch?.rawValue ?? "arm64" - #elseif swift(>=5.9) - let targetArchitecture = buildParameters.triple.arch?.rawValue ?? "arm64" - #endif // Generate the run destination parameters. let runDestination = XCBBuildParameters.RunDestination( diff --git a/Sources/ScipioKit/Producer/PIF/PIFCompiler.swift b/Sources/ScipioKit/Producer/PIF/PIFCompiler.swift index bae94f27..7f832b08 100644 --- a/Sources/ScipioKit/Producer/PIF/PIFCompiler.swift +++ b/Sources/ScipioKit/Producer/PIF/PIFCompiler.swift @@ -117,7 +117,6 @@ struct PIFCompiler: Compiler { } private func makeBuildParameters(toolchain: UserToolchain) throws -> BuildParameters { - #if compiler(>=6.0) try .init( destination: .target, dataPath: descriptionPackage.buildDirectory.spmAbsolutePath, @@ -127,27 +126,6 @@ struct PIFCompiler: Compiler { isXcodeBuildSystemEnabled: true, driverParameters: BuildParameters.Driver(enableParseableModuleInterfaces: buildOptions.enableLibraryEvolution) ) - #elseif swift(>=5.10) - try .init( - dataPath: descriptionPackage.buildDirectory.spmAbsolutePath, - configuration: buildOptions.buildConfiguration.spmConfiguration, - toolchain: toolchain, - targetTriple: toolchain.targetTriple, - flags: .init(), - isXcodeBuildSystemEnabled: true, - driverParameters: BuildParameters.Driver(enableParseableModuleInterfaces: buildOptions.enableLibraryEvolution) - ) - #else - try .init( - dataPath: descriptionPackage.buildDirectory.spmAbsolutePath, - configuration: buildOptions.buildConfiguration.spmConfiguration, - toolchain: toolchain, - destinationTriple: toolchain.triple, - flags: .init(), - enableParseableModuleInterfaces: buildOptions.enableLibraryEvolution, - isXcodeBuildSystemEnabled: true - ) - #endif } } diff --git a/Sources/ScipioKit/Producer/PIF/PIFGenerator.swift b/Sources/ScipioKit/Producer/PIF/PIFGenerator.swift index 54267e3e..22c2637c 100644 --- a/Sources/ScipioKit/Producer/PIF/PIFGenerator.swift +++ b/Sources/ScipioKit/Producer/PIF/PIFGenerator.swift @@ -169,15 +169,9 @@ private struct PIFLibraryTargetModifier { let c99Name = pifTarget.name.spm_mangledToC99ExtendedIdentifier() - #if compiler(>=6.0) guard let resolvedTarget = descriptionPackage.graph.allModules.first(where: { $0.c99name == c99Name }) else { fatalError("Resolved Target named \(c99Name) is not found.") } - #else - guard let resolvedTarget = descriptionPackage.graph.allTargets.first(where: { $0.c99name == c99Name }) else { - fatalError("Resolved Target named \(c99Name) is not found.") - } - #endif guard let resolvedPackage = descriptionPackage.graph.package(for: resolvedTarget) else { fatalError("Could not find a package") @@ -300,8 +294,6 @@ private struct PIFLibraryTargetModifier { } } -#if compiler(>=6.0) - extension PIF.TopLevelObject: @retroactive Decodable { public init(from decoder: Decoder) throws { var container = try decoder.unkeyedContainer() @@ -309,17 +301,6 @@ extension PIF.TopLevelObject: @retroactive Decodable { } } -#else - -extension PIF.TopLevelObject: Decodable { - public init(from decoder: Decoder) throws { - var container = try decoder.unkeyedContainer() - self.init(workspace: try container.decode(PIF.Workspace.self)) - } -} - -#endif - extension AbsolutePath { fileprivate var moduleEscapedPathString: String { return self.pathString.replacingOccurrences(of: "\\", with: "\\\\") diff --git a/Sources/ScipioKit/Producer/PIF/ToolchainGenerator.swift b/Sources/ScipioKit/Producer/PIF/ToolchainGenerator.swift index 6a048093..6f07c9ca 100644 --- a/Sources/ScipioKit/Producer/PIF/ToolchainGenerator.swift +++ b/Sources/ScipioKit/Producer/PIF/ToolchainGenerator.swift @@ -1,11 +1,7 @@ import Foundation import TSCUtility -#if compiler(>=6.0) @_spi(SwiftPMInternal) import PackageModel @_spi(SwiftPMInternal) import struct Basics.Environment -#else -import PackageModel -#endif import TSCBasic import struct Basics.Triple @@ -26,16 +22,10 @@ struct ToolchainGenerator { func makeToolChain(sdk: SDK) async throws -> UserToolchain { let destination: SwiftSDK = try await makeDestination(sdk: sdk) - #if compiler(>=6.0) return try UserToolchain( swiftSDK: destination, environment: environment.map(Environment.init) ?? .current ) - #elseif swift(>=5.10) - return try UserToolchain(swiftSDK: destination) - #else - return try UserToolchain(destination: destination) - #endif } private func makeDestination( @@ -61,7 +51,6 @@ struct ToolchainGenerator { extraSwiftCFlags += ["-L", sdkPaths.lib.pathString] let buildFlags = BuildFlags(cCompilerFlags: extraCCFlags, swiftCompilerFlags: extraSwiftCFlags) - #if compiler(>=6.0) return SwiftSDK( hostTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), targetTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), @@ -69,21 +58,5 @@ struct ToolchainGenerator { pathsConfiguration: .init(sdkRootPath: sdkPath.spmAbsolutePath), xctestSupport: .supported ) - #elseif swift(>=5.10) - return SwiftSDK( - hostTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), - targetTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), - toolset: .init(toolchainBinDir: toolchainDirPath.spmAbsolutePath, buildFlags: buildFlags), - pathsConfiguration: .init(sdkRootPath: sdkPath.spmAbsolutePath) - ) - #else - return Destination( - hostTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), - targetTriple: try? Triple("arm64-apple-\(sdk.settingValue)"), - sdkRootDir: sdkPath.spmAbsolutePath, - toolchainBinDir: toolchainDirPath.spmAbsolutePath, - extraFlags: buildFlags - ) - #endif } } diff --git a/Sources/ScipioKit/Producer/PIF/XCBuildExecutor.swift b/Sources/ScipioKit/Producer/PIF/XCBuildExecutor.swift index 3aec60bc..ddb274c3 100644 --- a/Sources/ScipioKit/Producer/PIF/XCBuildExecutor.swift +++ b/Sources/ScipioKit/Producer/PIF/XCBuildExecutor.swift @@ -139,10 +139,8 @@ private final class _Executor { case .cancelled: log(level: .error, target: target, task: task.taskID, "cancelled") } - #if swift(>=5.10) case .unknown: break - #endif } } diff --git a/Sources/ScipioKit/Runner.swift b/Sources/ScipioKit/Runner.swift index 22294061..3a8e4a41 100644 --- a/Sources/ScipioKit/Runner.swift +++ b/Sources/ScipioKit/Runner.swift @@ -44,12 +44,8 @@ public struct Runner { if fileURL.path.hasPrefix("/") { return try AbsolutePath(validating: fileURL.path) } else if let currentDirectory = fileSystem.currentWorkingDirectory { - #if swift(>=5.10) let scipioCurrentDirectory = try ScipioAbsolutePath(validating: currentDirectory.pathString) return try ScipioAbsolutePath(scipioCurrentDirectory, validating: fileURL.path) - #else - return ScipioAbsolutePath(currentDirectory, fileURL.path) - #endif } else { return try! AbsolutePath(validating: fileURL.path) } diff --git a/Sources/ScipioKit/SwiftPM+Compatibility.swift b/Sources/ScipioKit/SwiftPM+Compatibility.swift index 53911856..f933bf12 100644 --- a/Sources/ScipioKit/SwiftPM+Compatibility.swift +++ b/Sources/ScipioKit/SwiftPM+Compatibility.swift @@ -10,26 +10,9 @@ import PackageModel // These has almost identical feature and interface. Unfortunately, Scipio still uses TSC versions of them // so It's better to remove TSC dependencies from Scipio. // At this moment, we just provides utils to bridge them at this time as below. -#if swift(>=5.10) - -// Above Swift 5.10, SwiftPM requires their own AbsolutePath, -// so we have to bridge them to Scipio requires by typealias - typealias ScipioAbsolutePath = TSCBasic.AbsolutePath typealias SwiftPMAbsolutePath = Basics.AbsolutePath -#else - -// Below Swift 5.9, Basics.AbsolutePath is not implemented yet. So this is required to keep backward-compatibility - -typealias ScipioAbsolutePath = TSCBasic.AbsolutePath -typealias SwiftPMAbsolutePath = TSCBasic.AbsolutePath - -// In Swift 5.10, Destination is renamed to SwiftSDK, so this is required to keep backward-compatibility -typealias SwiftSDK = Destination - -#endif - extension ScipioAbsolutePath { var spmAbsolutePath: SwiftPMAbsolutePath { try! SwiftPMAbsolutePath(validating: pathString) @@ -42,53 +25,7 @@ extension SwiftPMAbsolutePath { } } -// Since 6.0, all `~Target` has been renamed to `~Module` -#if compiler(>=6.0) - typealias ScipioResolvedModule = ResolvedModule typealias ScipioSwiftModule = SwiftModule typealias ScipioClangModule = ClangModule typealias ScipioBinaryModule = BinaryModule - -#else - -typealias ScipioResolvedModule = ResolvedTarget -typealias ScipioSwiftModule = SwiftTarget -typealias ScipioClangModule = ClangTarget -typealias ScipioBinaryModule = BinaryTarget - -#endif - -#if compiler(<6.0) - -extension ResolvedProduct { - var modules: [ResolvedTarget] { - targets - } -} - -extension ResolvedPackage { - var modules: [ScipioResolvedModule] { - targets - } -} - -extension ScipioResolvedModule { - var underlying: Target { - underlyingTarget - } -} - -extension ScipioResolvedModule.Dependency { - var module: ScipioResolvedModule? { - target - } -} - -#endif - -#if compiler(<6.0) - -typealias ModulesGraph = PackageGraph - -#endif diff --git a/Sources/scipio/Arguments.swift b/Sources/scipio/Arguments.swift index c83abf31..da796284 100644 --- a/Sources/scipio/Arguments.swift +++ b/Sources/scipio/Arguments.swift @@ -2,24 +2,12 @@ import Foundation import ArgumentParser import ScipioKit -#if compiler(>=6.0) - extension URL: @retroactive ExpressibleByArgument { public init?(argument: String) { self.init(fileURLWithPath: argument) } } -#else - -extension URL: ExpressibleByArgument { - public init?(argument: String) { - self.init(fileURLWithPath: argument) - } -} - -#endif - extension BuildConfiguration: ExpressibleByArgument { public init?(argument: String) { switch argument.lowercased() { diff --git a/Tests/ScipioKitTests/CacheSystemTests.swift b/Tests/ScipioKitTests/CacheSystemTests.swift index 9f2b364a..83b1064a 100644 --- a/Tests/ScipioKitTests/CacheSystemTests.swift +++ b/Tests/ScipioKitTests/CacheSystemTests.swift @@ -74,8 +74,6 @@ final class CacheSystemTests: XCTestCase { XCTAssertEqual(rawString, expected) } - #if compiler(>=6.0) - func testCacheKeyCalculationForRootPackageTarget() async throws { let fileSystem = localFileSystem let testingPackagePath = fixturePath.appendingPathComponent("TestingPackage") @@ -141,7 +139,4 @@ final class CacheSystemTests: XCTestCase { XCTAssertEqual(cacheKey.targetName, myTarget.name) XCTAssertEqual(cacheKey.pin.description, "1.1.0") } - - #endif - } From e8448eb8579d1e5e9462763dc816f00271bb9553 Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 17 Oct 2024 10:19:16 +0900 Subject: [PATCH 2/4] Drop Swift 5 support --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 899137a2..e203ae62 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/giginet/Scipio/tests.yml?style=flat-square&logo=github) ![Swift 6.0](https://img.shields.io/badge/Swift-6.0-FA7343?logo=swift&style=flat-square) -![Swift 5.10](https://img.shields.io/badge/Swift-5.10-FA7343?logo=swift&style=flat-square) -![Swift 5.9](https://img.shields.io/badge/Swift-5.9-FA7343?logo=swift&style=flat-square) -[![Xcode 16.0 Beta](https://img.shields.io/badge/Xcode-16.0-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/) -[![Xcode 15.4](https://img.shields.io/badge/Xcode-15.4-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/) -[![Xcode 15.2](https://img.shields.io/badge/Xcode-15.2-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/) +[![Xcode 16.0](https://img.shields.io/badge/Xcode-16.0-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/) [![SwiftPM](https://img.shields.io/badge/SwiftPM-compatible-green?logo=swift&style=flat-square)](https://swift.org/package-manager/) [![Documentation](https://img.shields.io/badge/Documentation-available-green?style=flat-square)](https://giginet.github.io/Scipio/documentation/scipio/) ![Platforms](https://img.shields.io/badge/Platform-iOS%7CmacOS%7CwatchOS%7CtvOS%7CvisionOS-lightgray?logo=apple&style=flat-square) @@ -45,7 +41,7 @@ This mode is called `prepare` mode. See [Prepare All Dependencies for Your Appli #### Define `Package.swift` to describe your application's dependencies ```swift -// swift-tools-version: 5.6 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -136,12 +132,11 @@ See [Convert Single Swift Package to XCFramework](https://giginet.github.io/Scip ## Supported Xcode and Swift version -Currently, we support Swift 5.9, and 5.10. +Currently, we support Swift 6.0. | | Xcode | Swift | |----|------------|-------| -| ✅ | 15.3 | 5.10 | -| ✅ | 15.0<=15.2 | 5.9 | +| ✅ | 16.0 | 6.0 | ## Reliability From 07f94175ba989ffe43717feb44338eb86c752060 Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 17 Oct 2024 10:20:36 +0900 Subject: [PATCH 3/4] Update CI equipment --- .github/workflows/docc.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docc.yml b/.github/workflows/docc.yml index 483b835f..ada030ae 100644 --- a/.github/workflows/docc.yml +++ b/.github/workflows/docc.yml @@ -5,7 +5,7 @@ on: branches: - main env: - DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer" jobs: DocC: runs-on: macos-14 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index af4eb907..fb10205f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: SwiftLint: strategy: matrix: - xcode_version: ["15.4"] + xcode_version: ["16.0"] env: DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" runs-on: macos-14 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18483757..3b49b94b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: name: Upload Artifact Bundle to Release env: - DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer" SCIPIO_DEVELOPMENT: 1 jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77518a4f..36202247 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,8 +12,6 @@ jobs: strategy: matrix: xcode_version: - - "15.2" # 5.9 - - "15.4" # 5.10 - "16.0" # 6.0 env: DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" From 576da58eda9d5cdee508e7753edc8fafb2069f1c Mon Sep 17 00:00:00 2001 From: giginet Date: Mon, 21 Oct 2024 19:02:17 +0900 Subject: [PATCH 4/4] Remove unnecessary implementations --- Plugins/GenerateScipioVersion/plugin.swift | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Plugins/GenerateScipioVersion/plugin.swift b/Plugins/GenerateScipioVersion/plugin.swift index 17fd5e60..e4329144 100644 --- a/Plugins/GenerateScipioVersion/plugin.swift +++ b/Plugins/GenerateScipioVersion/plugin.swift @@ -59,21 +59,3 @@ struct GenerateScipioVersion: BuildToolPlugin { return revision } } - -// Convert Foundation.URL to Path -extension Command { - fileprivate static func prebuildCommand( - displayName: String?, - executable: URL, - arguments: [any CustomStringConvertible], - environment: [String : any CustomStringConvertible] = [:], - outputFilesDirectory: URL - ) -> PackagePlugin.Command { - .prebuildCommand( - displayName: displayName, - executable: Path(executable.path()), - arguments: arguments, - outputFilesDirectory: Path(outputFilesDirectory.path()) - ) - } -}