Skip to content

Commit 9babfea

Browse files
committed
Require Swift 6
1 parent ab8166a commit 9babfea

File tree

3 files changed

+32
-110
lines changed

3 files changed

+32
-110
lines changed

Package.swift

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

55
let package = Package(
66
name: "swift-aws-lambda-runtime",
77
platforms: [
8-
.macOS(.v12),
9-
.iOS(.v15),
10-
.tvOS(.v15),
11-
.watchOS(.v8),
8+
.macOS(.v15)
129
],
1310
products: [
1411
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
1512
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
1613
// this has all the main functionality for lambda and it does not link Foundation
1714
.library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]),
1815
// plugin to package the lambda, creating an archive that can be uploaded to AWS
16+
// requires Linux or at least macOS v15
1917
.plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]),
2018
// for testing only
2119
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
2220
],
2321
dependencies: [
2422
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.67.0")),
2523
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.5.4")),
26-
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.3.0"),
24+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
2725
],
2826
targets: [
2927
.target(
@@ -32,7 +30,8 @@ let package = Package(
3230
.byName(name: "AWSLambdaRuntimeCore"),
3331
.product(name: "NIOCore", package: "swift-nio"),
3432
.product(name: "NIOFoundationCompat", package: "swift-nio"),
35-
]
33+
],
34+
swiftSettings: [.swiftLanguageMode(.v5)]
3635
),
3736
.target(
3837
name: "AWSLambdaRuntimeCore",
@@ -42,15 +41,15 @@ let package = Package(
4241
.product(name: "NIOCore", package: "swift-nio"),
4342
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
4443
.product(name: "NIOPosix", package: "swift-nio"),
45-
]
44+
],
45+
swiftSettings: [.swiftLanguageMode(.v5)]
4646
),
4747
.plugin(
4848
name: "AWSLambdaPackager",
4949
capability: .command(
5050
intent: .custom(
5151
verb: "archive",
52-
description:
53-
"Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions."
52+
description: "Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions."
5453
)
5554
)
5655
),
@@ -60,31 +59,39 @@ let package = Package(
6059
.byName(name: "AWSLambdaRuntimeCore"),
6160
.product(name: "NIOTestUtils", package: "swift-nio"),
6261
.product(name: "NIOFoundationCompat", package: "swift-nio"),
63-
]
62+
],
63+
swiftSettings: [.swiftLanguageMode(.v5)]
6464
),
6565
.testTarget(
6666
name: "AWSLambdaRuntimeTests",
6767
dependencies: [
6868
.byName(name: "AWSLambdaRuntimeCore"),
6969
.byName(name: "AWSLambdaRuntime"),
70-
]
70+
],
71+
swiftSettings: [.swiftLanguageMode(.v5)]
7172
),
7273
// testing helper
7374
.target(
7475
name: "AWSLambdaTesting",
7576
dependencies: [
7677
.byName(name: "AWSLambdaRuntime"),
7778
.product(name: "NIO", package: "swift-nio"),
78-
]
79+
],
80+
swiftSettings: [.swiftLanguageMode(.v5)]
81+
),
82+
.testTarget(
83+
name: "AWSLambdaTestingTests",
84+
dependencies: ["AWSLambdaTesting"],
85+
swiftSettings: [.swiftLanguageMode(.v5)]
7986
),
80-
.testTarget(name: "AWSLambdaTestingTests", dependencies: ["AWSLambdaTesting"]),
8187
// for perf testing
8288
.executableTarget(
8389
name: "MockServer",
8490
dependencies: [
8591
.product(name: "NIOHTTP1", package: "swift-nio"),
8692
.product(name: "NIO", package: "swift-nio"),
87-
]
93+
],
94+
swiftSettings: [.swiftLanguageMode(.v5)]
8895
),
8996
]
9097
)

[email protected]

Lines changed: 0 additions & 92 deletions
This file was deleted.

Plugins/AWSLambdaPackager/Plugin.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import Dispatch
1616
import Foundation
1717
import PackagePlugin
18+
import Synchronization
1819

1920
#if os(macOS)
2021
import Darwin
@@ -28,6 +29,7 @@ import ucrt
2829
#error("Unsupported platform")
2930
#endif
3031

32+
@available(macOS 15.0, *)
3133
@main
3234
struct AWSLambdaPackager: CommandPlugin {
3335
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws {
@@ -282,10 +284,10 @@ struct AWSLambdaPackager: CommandPlugin {
282284
print("\(executable.string) \(arguments.joined(separator: " "))")
283285
}
284286

285-
var output = ""
287+
let outputMutex = Mutex("")
286288
let outputSync = DispatchGroup()
287289
let outputQueue = DispatchQueue(label: "AWSLambdaPackager.output")
288-
let outputHandler = { (data: Data?) in
290+
let outputHandler = { @Sendable (data: Data?) in
289291
dispatchPrecondition(condition: .onQueue(outputQueue))
290292

291293
outputSync.enter()
@@ -299,7 +301,9 @@ struct AWSLambdaPackager: CommandPlugin {
299301
return
300302
}
301303

302-
output += _output + "\n"
304+
outputMutex.withLock { output in
305+
output += _output + "\n"
306+
}
303307

304308
switch logLevel {
305309
case .silent:
@@ -336,6 +340,8 @@ struct AWSLambdaPackager: CommandPlugin {
336340
// wait for output to be full processed
337341
outputSync.wait()
338342

343+
let output = outputMutex.withLock { $0 }
344+
339345
if process.terminationStatus != 0 {
340346
// print output on failure and if not already printed
341347
if logLevel < .output {
@@ -359,6 +365,7 @@ struct AWSLambdaPackager: CommandPlugin {
359365
}
360366
}
361367

368+
@available(macOS 15.0, *)
362369
private struct Configuration: CustomStringConvertible {
363370
public let outputDirectory: Path
364371
public let products: [Product]

0 commit comments

Comments
 (0)