-
Notifications
You must be signed in to change notification settings - Fork 18
Cache DownloadableArtifacts
with GeneratorEngine
#34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4db7eaf
3ea95f4
73c1f4e
a5e5254
c525ec9
09201ea
80a4173
b5304e8
c96bda6
2d677b5
5ccecd4
aef9fcb
996fd27
e477ac5
6ca73f1
a9d1054
6385163
105e809
b4de18f
49255cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
import struct Foundation.URL | ||
import GeneratorEngine | ||
import struct SystemPackage.FilePath | ||
|
||
/// Information about the OS for which the artifact is built, if it's downloaded as prebuilt. | ||
|
@@ -45,74 +46,26 @@ enum ArtifactOS: Hashable { | |
|
||
typealias CPUMapping = [Triple.CPU: String] | ||
|
||
/// SHA256 hashes of binary LLVM artifacts known to the generator. | ||
private let knownLLVMBinariesVersions: [ArtifactOS: [String: CPUMapping]] = [ | ||
.macOS: [ | ||
"15.0.7": [ | ||
Triple.CPU.arm64: "867c6afd41158c132ef05a8f1ddaecf476a26b91c85def8e124414f9a9ba188d", | ||
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. A side effect of using these hashes was that we also verified that the upstream tarballs hadn't changed from the known versions. LLVM signs its binaries using GPG, so in future we could have an option to verify those signatures. This would require the user to download and validate LLVM's public key. 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. I agree, checking signatures is the right way to do it. But code on |
||
], | ||
"16.0.0": [ | ||
Triple.CPU.arm64: "2041587b90626a4a87f0de14a5842c14c6c3374f42c8ed12726ef017416409d9", | ||
], | ||
"16.0.1": [ | ||
Triple.CPU.arm64: "cb487fa991f047dc79ae36430cbb9ef14621c1262075373955b1d97215c75879", | ||
], | ||
"16.0.4": [ | ||
Triple.CPU.arm64: "429b8061d620108fee636313df55a0602ea0d14458c6d3873989e6b130a074bd", | ||
], | ||
"16.0.5": [ | ||
Triple.CPU.arm64: "1aed0787417dd915f0101503ce1d2719c8820a2c92d4a517bfc4044f72035bcc", | ||
], | ||
], | ||
] | ||
|
||
/// SHA256 hashes of binary Swift artifacts known to the generator. | ||
private let knownSwiftBinariesVersions: [ArtifactOS: [String: CPUMapping]] = [ | ||
.linux(.ubuntu(.jammy)): [ | ||
"5.7.3-RELEASE": [ | ||
.arm64: "75003d5a995292ae3f858b767fbb89bc3edee99488f4574468a0e44341aec55b", | ||
], | ||
"5.8-RELEASE": [ | ||
.arm64: "12ea2df36f9af0aefa74f0989009683600978f62223e7dd73b627c90c7fe9273", | ||
], | ||
"5.9-RELEASE": [ | ||
.arm64: "30b289e02f7e03c380744ea97fdf0e96985dff504b0f09de23e098fdaf6513f3", | ||
.x86_64: "bca015e9d727ca39385d7e5b5399f46302d54a02218d40d1c3063662ffc6b42f", | ||
], | ||
], | ||
.macOS: [ | ||
"5.7.3-RELEASE": [ | ||
.arm64: "ba3516845eb8f4469a8bb06a273687f05791187324a3843996af32a73a2a687d", | ||
.x86_64: "ba3516845eb8f4469a8bb06a273687f05791187324a3843996af32a73a2a687d", | ||
], | ||
"5.8-RELEASE": [ | ||
.arm64: "9b6cc56993652ca222c86a2d6b7b66abbd50bb92cc526efc2b23d47d40002097", | ||
.x86_64: "9b6cc56993652ca222c86a2d6b7b66abbd50bb92cc526efc2b23d47d40002097", | ||
], | ||
"5.9-RELEASE": [ | ||
.arm64: "3cf7a4b2f3efcfcb4fef42b6588a7b1c54f7b0f2d0a479f41c3e1620b045f48e", | ||
.x86_64: "3cf7a4b2f3efcfcb4fef42b6588a7b1c54f7b0f2d0a479f41c3e1620b045f48e", | ||
], | ||
], | ||
] | ||
|
||
private let knownLLVMSourcesVersions: [String: String] = [ | ||
"16.0.5": "37f540124b9cfd4680666e649f557077f9937c9178489cea285a672e714b2863", | ||
] | ||
|
||
public struct DownloadableArtifacts: Sendable { | ||
public struct Item: Sendable { | ||
struct DownloadableArtifacts: Sendable { | ||
@CacheKey | ||
struct Item: Sendable { | ||
let remoteURL: URL | ||
var localPath: FilePath | ||
let checksum: String? | ||
let isPrebuilt: Bool | ||
} | ||
|
||
let hostSwift: Item | ||
private(set) var hostLLVM: Item | ||
let targetSwift: Item | ||
|
||
let allItems: [Item] | ||
private let shouldUseDocker: Bool | ||
var allItems: [Item] { | ||
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. Fixing a bug here, where |
||
if self.shouldUseDocker { | ||
[self.hostSwift, self.hostLLVM] | ||
} else { | ||
[self.hostSwift, self.hostLLVM, self.targetSwift] | ||
} | ||
} | ||
|
||
private let versions: VersionsConfiguration | ||
private let paths: PathsConfiguration | ||
|
@@ -136,7 +89,6 @@ public struct DownloadableArtifacts: Sendable { | |
), | ||
localPath: paths.artifactsCachePath | ||
.appending("host_swift_\(versions.swiftVersion)_\(hostTriple).pkg"), | ||
checksum: knownSwiftBinariesVersions[hostArtifactsOS]?[versions.swiftVersion]?[hostTriple.cpu], | ||
isPrebuilt: true | ||
) | ||
|
||
|
@@ -152,7 +104,6 @@ public struct DownloadableArtifacts: Sendable { | |
)!, | ||
localPath: paths.artifactsCachePath | ||
.appending("host_llvm_\(versions.lldVersion)_\(hostTriple).tar.xz"), | ||
checksum: knownLLVMBinariesVersions[hostArtifactsOS]?[versions.lldVersion]?[hostTriple.cpu], | ||
isPrebuilt: true | ||
) | ||
|
||
|
@@ -161,15 +112,10 @@ public struct DownloadableArtifacts: Sendable { | |
remoteURL: versions.swiftDownloadURL(), | ||
localPath: paths.artifactsCachePath | ||
.appending("target_swift_\(versions.swiftVersion)_\(targetTriple).tar.gz"), | ||
checksum: knownSwiftBinariesVersions[targetArtifactsOS]?[versions.swiftVersion]?[targetTriple.cpu], | ||
isPrebuilt: true | ||
) | ||
|
||
self.allItems = if shouldUseDocker { | ||
[self.hostSwift, self.hostLLVM] | ||
} else { | ||
[self.hostSwift, self.hostLLVM, self.targetSwift] | ||
} | ||
self.shouldUseDocker = shouldUseDocker | ||
} | ||
|
||
mutating func useLLVMSources() { | ||
|
@@ -185,7 +131,6 @@ public struct DownloadableArtifacts: Sendable { | |
)!, | ||
localPath: self.paths.artifactsCachePath | ||
.appending("llvm_\(self.versions.lldVersion).src.tar.xz"), | ||
checksum: knownLLVMSourcesVersions[self.versions.lldVersion], | ||
isPrebuilt: false | ||
) | ||
} | ||
|
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.
It would be nice add a
withGenerator
wrapper which could take care of shutting down and rethrowing if necessary.