Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit efbe96f

Browse files
authored
Merge pull request #73 from giginet/support5.7
Support Swift 5.7 dependencies
2 parents a456989 + f22ec56 commit efbe96f

File tree

5 files changed

+69
-11
lines changed

5 files changed

+69
-11
lines changed

Package.resolved

Lines changed: 26 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
import PackageDescription
55

66
let dependencies: [Package.Dependency]
7-
#if swift(>=5.6)
7+
#if swift(>=5.7)
8+
dependencies = [
9+
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
10+
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.7")),
11+
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("release/5.7")),
12+
]
13+
#elseif swift(>=5.6)
814
dependencies = [
915
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
1016
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.6")),

Sources/CreateXCFramework/PackageInfo.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ struct PackageInfo {
8888

8989
self.toolchain = try UserToolchain(destination: try .hostDestination())
9090

91-
#if swift(>=5.6)
91+
#if swift(>=5.7)
92+
let loader = ManifestLoader(toolchain: self.toolchain)
93+
self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader)
94+
#elseif swift(>=5.6)
9295
let resources = ToolchainConfiguration(swiftCompilerPath: self.toolchain.swiftCompilerPath)
9396
let loader = ManifestLoader(toolchain: resources)
9497
self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader)

Sources/CreateXCFramework/ProjectGenerator.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ struct ProjectGenerator {
2323

2424
var projectPath: AbsolutePath {
2525
let dir = AbsolutePath(self.package.projectBuildDirectory.path)
26+
#if swift(>=5.7)
27+
return XcodeProject.makePath(outputDir: dir, projectName: self.package.manifest.displayName)
28+
#else
2629
return buildXcodeprojPath(outputDir: dir, projectName: self.package.manifest.displayName)
30+
#endif
2731
}
2832

2933

Sources/CreateXCFramework/Zipper.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Created by Rob Amos on 13/5/20.
66
//
77

8+
#if canImport(Basics)
9+
import Basics
10+
#endif
811
import Foundation
912
#if swift(>=5.6)
1013
import PackageGraph
@@ -54,7 +57,9 @@ struct Zipper {
5457
}
5558

5659
func checksum (file: Foundation.URL) throws -> Foundation.URL {
57-
#if swift(>=5.6)
60+
#if swift(>=5.7)
61+
let sum = try checksum(forBinaryArtifactAt: AbsolutePath(file.path))
62+
#elseif swift(>=5.6)
5863
let sum = try self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path))
5964
#else
6065
let sum = self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path), diagnostics: self.package.diagnostics)
@@ -106,6 +111,28 @@ struct Zipper {
106111
func clean (file: Foundation.URL) throws {
107112
try FileManager.default.removeItem(at: file)
108113
}
114+
115+
#if swift(>=5.7)
116+
private func checksum(forBinaryArtifactAt path: AbsolutePath) throws -> String {
117+
let fileSystem = localFileSystem
118+
let checksumAlgorithm = SHA256()
119+
let archiver = ZipArchiver(fileSystem: fileSystem)
120+
121+
// Validate the path has a supported extension.
122+
guard let pathExtension = path.extension, archiver.supportedExtensions.contains(pathExtension) else {
123+
let supportedExtensionList = archiver.supportedExtensions.joined(separator: ", ")
124+
throw StringError("unexpected file type; supported extensions are: \(supportedExtensionList)")
125+
}
126+
127+
// Ensure that the path with the accepted extension is a file.
128+
guard fileSystem.isFile(path) else {
129+
throw StringError("file not found at path: \(path.pathString)")
130+
}
131+
132+
let contents = try fileSystem.readFileContents(path)
133+
return checksumAlgorithm.hash(contents).hexadecimalRepresentation
134+
}
135+
#endif
109136
}
110137

111138
#if swift(>=5.6)

0 commit comments

Comments
 (0)