Skip to content

Commit 28325a1

Browse files
authored
ContainerRegistry: Unconditionally depend on swift-crypto (#33)
### Motivation `swift-crypto` provides a common cryptography interface on macOS and Linux. On macOS it defers to CryptoKit, and although the files in the library must all be processed the compilation time is minimal. In the past, on slower machines, avoiding processing `swift-crypto` on macOS seemed to improve build times by a few seconds. Currently the cost of processing these files is negligible, and using `swift-crypto` on Linux and macOS allows conditional includes to be removed. ### Modifications Always depend on `swift-crypto` in `Package.swift` Replace conditional imports of `CryptoKit` with unconditional imports of `Crypto`. ### Result No functional change. ### Test Plan Automated tests continue to pass.
1 parent 6a94854 commit 28325a1

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

Package.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,16 @@ let package = Package(
3232
.target(
3333
name: "ContainerRegistry",
3434
dependencies: [
35-
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux])),
35+
.target(name: "Basics"), .product(name: "Crypto", package: "swift-crypto"),
3636
.product(name: "HTTPTypes", package: "swift-http-types"),
3737
.product(name: "HTTPTypesFoundation", package: "swift-http-types"),
38-
.target(
39-
name: "Basics" // AuthorizationProvider
40-
),
4138
]
4239
),
4340
.executableTarget(
4441
name: "containertool",
4542
dependencies: [
46-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
47-
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux])),
4843
.target(name: "ContainerRegistry"), .target(name: "VendorCNIOExtrasZlib"),
44+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
4945
],
5046
swiftSettings: [.swiftLanguageMode(.v5)]
5147
),

Sources/ContainerRegistry/Blobs.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@
1414

1515
import Foundation
1616
import HTTPTypes
17-
18-
#if canImport(CryptoKit)
19-
import CryptoKit
20-
#else
2117
import Crypto
22-
#endif
2318

2419
/// Calculates the digest of a blob of data.
2520
/// - Parameter data: Blob of data to digest.

Sources/ContainerRegistry/ImageManifest+Digest.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Foundation
16-
17-
#if canImport(CryptoKit)
18-
import CryptoKit
19-
#else
2016
import Crypto
21-
#endif
2217

2318
public extension ImageManifest {
2419
var digest: String {

0 commit comments

Comments
 (0)