Skip to content

Commit

Permalink
build: fix dependencies (#599)
Browse files Browse the repository at this point in the history
* build: fix dependencies

We need this to use the new initialiser `init(url:exact:)` for updating
the standalone build to match the CI build.

When building in CI, we would build against swift-crypto 2.5.0 as per
update-checkout-config.json in apple/swift.  Adjust the standalone
builds to match.

When building on CI, we would build against swift-argument-parser 1.2.2
as per update-checkout-config.json in apple/swift.  Make the standalone
builds match.

* - Update Package.swift for Swift 5.6 minimum (as already required by NIO).
- Remove deprecated usages and bump the dependency version requirements for NIO, ArgumentParser, and SwiftCrypto (most especially the latter so that updates in the 2.x series are available).
- Remove old #if swift conditionals no longer required
- Package.resolved now uses the version 2 format

* The platform-specific handling for conforming Array to LMDBData is still required.

---------

Co-authored-by: Gwynne Raskind <[email protected]>
  • Loading branch information
compnerd and gwynne authored May 30, 2023
1 parent bd1b78a commit b279723
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 117 deletions.
168 changes: 92 additions & 76 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,79 +1,95 @@
{
"object": {
"pins": [
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "e394bf350e38cb100b6bc4172834770ede1b7232",
"version": "1.0.3"
}
},
{
"package": "cmark-gfm",
"repositoryURL": "https://github.com/apple/swift-cmark.git",
"state": {
"branch": "gfm",
"revision": "eb9a6a357b6816c68f4b194eaa5b67f3cd1fa5c3",
"version": null
}
},
{
"package": "swift-crypto",
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version": "1.1.7"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"version": "1.0.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": "main",
"revision": "53e5cb9b18222f66cb8d6fb684d7383e705e0936",
"version": null
}
},
{
"package": "CLMDB",
"repositoryURL": "https://github.com/apple/swift-lmdb.git",
"state": {
"branch": "main",
"revision": "584941b1236b15bad74d8163785d389c028b1ad8",
"version": null
}
},
{
"package": "swift-markdown",
"repositoryURL": "https://github.com/apple/swift-markdown.git",
"state": {
"branch": "main",
"revision": "36b71b380ca9cb7497fc24416f8b77721eaf7330",
"version": null
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "1d425b0851ffa2695d488cce1d68df2539f42500",
"version": "2.31.2"
}
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
}
]
},
"version": 1
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version" : "1.1.0"
}
},
{
"identity" : "swift-cmark",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-cmark.git",
"state" : {
"branch" : "gfm",
"revision" : "eb9a6a357b6816c68f4b194eaa5b67f3cd1fa5c3"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "33a20e650c33f6d72d822d558333f2085effa3dc",
"version" : "2.5.0"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"version" : "1.0.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"branch" : "main",
"revision" : "53e5cb9b18222f66cb8d6fb684d7383e705e0936"
}
},
{
"identity" : "swift-lmdb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-lmdb.git",
"state" : {
"branch" : "main",
"revision" : "584941b1236b15bad74d8163785d389c028b1ad8"
}
},
{
"identity" : "swift-markdown",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-markdown.git",
"state" : {
"branch" : "main",
"revision" : "36b71b380ca9cb7497fc24416f8b77721eaf7330"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "2d8e6ca36fe3e8ed74b0883f593757a45463c34d",
"version" : "2.53.0"
}
}
],
"version" : 2
}
50 changes: 22 additions & 28 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.6
/*
This source file is part of the Swift.org open source project

Expand Down Expand Up @@ -42,17 +42,17 @@ let package = Package(
name: "SwiftDocC",
dependencies: [
.product(name: "Markdown", package: "swift-markdown"),
"SymbolKit",
"CLMDB",
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
.product(name: "CLMDB", package: "swift-lmdb"),
.product(name: "Crypto", package: "swift-crypto"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "SwiftDocCTests",
dependencies: [
"SwiftDocC",
"SwiftDocCTestUtilities",
.target(name: "SwiftDocC"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
Expand All @@ -67,7 +67,7 @@ let package = Package(
.target(
name: "SwiftDocCUtilities",
dependencies: [
"SwiftDocC",
.target(name: "SwiftDocC"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
Expand All @@ -76,9 +76,9 @@ let package = Package(
.testTarget(
name: "SwiftDocCUtilitiesTests",
dependencies: [
"SwiftDocCUtilities",
"SwiftDocC",
"SwiftDocCTestUtilities",
.target(name: "SwiftDocCUtilities"),
.target(name: "SwiftDocC"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
.copy("Test Resources"),
Expand All @@ -90,7 +90,7 @@ let package = Package(
.target(
name: "SwiftDocCTestUtilities",
dependencies: [
"SymbolKit"
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings
),
Expand All @@ -99,7 +99,7 @@ let package = Package(
.executableTarget(
name: "docc",
dependencies: [
"SwiftDocCUtilities",
.target(name: "SwiftDocCUtilities"),
],
swiftSettings: swiftSettings
),
Expand All @@ -108,7 +108,7 @@ let package = Package(
.executableTarget(
name: "signal-test-app",
dependencies: [
"SwiftDocCUtilities",
.target(name: "SwiftDocCUtilities"),
],
path: "Tests/signal-test-app",
swiftSettings: swiftSettings
Expand All @@ -117,8 +117,8 @@ let package = Package(
.executableTarget(
name: "generate-symbol-graph",
dependencies: [
"SwiftDocC",
"SymbolKit",
.target(name: "SwiftDocC"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings
),
Expand All @@ -132,28 +132,22 @@ let package = Package(
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// Building standalone, so fetch all dependencies remotely.
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "2.31.2")),
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
.package(name: "SymbolKit", url: "https://github.com/apple/swift-docc-symbolkit", .branch("main")),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.2")),
]

// SwiftPM command plugins are only supported by Swift version 5.6 and later.
#if swift(>=5.6)
package.dependencies += [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
.package(url: "https://github.com/apple/swift-lmdb.git", branch: "main"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/apple/swift-docc-symbolkit", branch: "main"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "2.5.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
]
#endif
} else {
// Building in the Swift.org CI system, so rely on local versions of dependencies.
package.dependencies += [
.package(path: "../swift-nio"),
.package(path: "../swift-markdown"),
.package(name: "CLMDB", path: "../swift-lmdb"),
.package(path: "../swift-lmdb"),
.package(path: "../swift-argument-parser"),
.package(name: "SymbolKit", path: "../swift-docc-symbolkit"),
.package(path: "../swift-docc-symbolkit"),
.package(path: "../swift-crypto"),
]
}
16 changes: 3 additions & 13 deletions Sources/SwiftDocC/Utility/LMDB/LMDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,11 @@ extension Data: LMDBData {
self = Data.init(bytes: data.baseAddress!, count: data.count)
}

#if swift(>=5.0)
public func read<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R{
return try self.withUnsafeBytes({ (ptr) -> R in
return try body(ptr)
})
}
#else
public func read<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R{
return try self.withUnsafeBytes({ (ptr) -> R in
return try body(UnsafeRawBufferPointer(start: ptr, count: self.count))
})
}
#endif
}

extension String: LMDBData {
Expand All @@ -106,10 +98,10 @@ extension String: LMDBData {
}
}

#if !os(Linux) && !os(Android)
// This is required for macOS and Swift 4.2, for Linux the default implementation works as expected.
// This is required for macOS, for Linux the default implementation works as expected.
extension Array: LMDBData where Element: FixedWidthInteger {

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
public init?(data: UnsafeRawBufferPointer) {
var array = Array<Element>(repeating: 0, count: data.count / MemoryLayout<Element>.stride)
_ = array.withUnsafeMutableBytes { data.copyBytes(to: $0) }
Expand All @@ -120,11 +112,9 @@ extension Array: LMDBData where Element: FixedWidthInteger {
let data = self.withUnsafeBufferPointer { Data(buffer: $0) }
return try data.read(body)
}
#endif

}
#else
extension Array: LMDBData where Element: FixedWidthInteger {}
#endif

extension Bool: LMDBData {}
extension Int: LMDBData {}
Expand Down

0 comments on commit b279723

Please sign in to comment.