This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Support Swift 5.7 dependencies #73
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import PackageGraph | |
import PackageModel | ||
import TSCBasic | ||
import Workspace | ||
import Basics | ||
|
||
struct Zipper { | ||
|
||
|
@@ -54,7 +55,9 @@ struct Zipper { | |
} | ||
|
||
func checksum (file: Foundation.URL) throws -> Foundation.URL { | ||
#if swift(>=5.6) | ||
#if swift(>=5.7) | ||
let sum = try checksum(forBinaryArtifactAt: AbsolutePath(file.path)) | ||
#elseif swift(>=5.6) | ||
let sum = try self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path)) | ||
#else | ||
let sum = self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path), diagnostics: self.package.diagnostics) | ||
|
@@ -106,6 +109,28 @@ struct Zipper { | |
func clean (file: Foundation.URL) throws { | ||
try FileManager.default.removeItem(at: file) | ||
} | ||
|
||
#if swift(>=5.7) | ||
private func checksum(forBinaryArtifactAt path: AbsolutePath) throws -> String { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So I ported the same implementation from the original SwiftPM codes. |
||
let fileSystem = localFileSystem | ||
let checksumAlgorithm = SHA256() | ||
let archiver = ZipArchiver(fileSystem: fileSystem) | ||
|
||
// Validate the path has a supported extension. | ||
guard let pathExtension = path.extension, archiver.supportedExtensions.contains(pathExtension) else { | ||
let supportedExtensionList = archiver.supportedExtensions.joined(separator: ", ") | ||
throw StringError("unexpected file type; supported extensions are: \(supportedExtensionList)") | ||
} | ||
|
||
// Ensure that the path with the accepted extension is a file. | ||
guard fileSystem.isFile(path) else { | ||
throw StringError("file not found at path: \(path.pathString)") | ||
} | ||
|
||
let contents = try fileSystem.readFileContents(path) | ||
return checksumAlgorithm.hash(contents).hexadecimalRepresentation | ||
} | ||
#endif | ||
} | ||
|
||
#if swift(>=5.6) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This global method is moved to a static method.