Skip to content

Commit b79fe9a

Browse files
Update SwiftPM branch to 5.8 and fix build errors (#395)
* Update SwiftPM branch to 5.8 and fix build errors * Make swift-format 5.8 happy :) * Make swift-format 5.8 happy for Tests * Fix wrong formatting * Resolve AbsolutePath(validating:) rename warnings * Fix wrong formatting * Resolve remaining deprecation warnings * Fix Linux build failure
1 parent f2a83a2 commit b79fe9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+916
-729
lines changed

Package.resolved

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ let package = Package(
2727
.package(
2828
name: "SwiftPM",
2929
url: "https://github.com/apple/swift-package-manager.git",
30-
.branch("release/5.7")
30+
.branch("release/5.8")
3131
),
3232
.package(
3333
url: "https://github.com/apple/swift-tools-support-core.git",
34-
.branch("release/5.7")
34+
.branch("release/5.8")
3535
),
3636
.package(url: "https://github.com/vapor/vapor.git", from: "4.57.1"),
37-
.package(url: "https://github.com/apple/swift-crypto.git", from: "1.1.0"),
37+
.package(url: "https://github.com/apple/swift-crypto.git", from: "2.2.0"),
3838
.package(url: "https://github.com/JohnSundell/Splash.git", from: "0.16.0"),
3939
.package(
4040
url: "https://github.com/swiftwasm/WasmTransformer",

Sources/CartonCLI/Commands/Bundle.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ struct Bundle: AsyncParsableCommand {
4949
@Option(
5050
name: .long,
5151
help: """
52-
Which optimizations to apply to the .wasm binary output.
53-
Available values: \(
52+
Which optimizations to apply to the .wasm binary output.
53+
Available values: \(
5454
WasmOptimizations.allCases.map(\.rawValue).joined(separator: ", ")
55-
)
56-
"""
55+
)
56+
"""
5757
)
5858
var wasmOptimizations: WasmOptimizations = .size
5959

@@ -122,7 +122,9 @@ struct Bundle: AsyncParsableCommand {
122122
terminal.write("Bundle generation finished successfully\n", inColor: .green, bold: true)
123123
}
124124

125-
func optimize(_ inputPath: AbsolutePath, outputPath: AbsolutePath, terminal: InteractiveWriter) async throws {
125+
func optimize(_ inputPath: AbsolutePath, outputPath: AbsolutePath, terminal: InteractiveWriter)
126+
async throws
127+
{
126128
var wasmOptArgs = ["wasm-opt", "-Os", inputPath.pathString, "-o", outputPath.pathString]
127129
if debugInfo {
128130
wasmOptArgs.append("--debuginfo")
@@ -156,7 +158,7 @@ struct Bundle: AsyncParsableCommand {
156158
try localFileSystem.move(from: wasmOutputFilePath, to: mainModulePath)
157159

158160
// Copy the bundle entrypoint, point to the binary, and give it a cachebuster name.
159-
let (_, _, entrypointPath) = dependency.paths(on: localFileSystem)
161+
let (_, _, entrypointPath) = try dependency.paths(on: localFileSystem)
160162
let entrypoint = try ByteString(
161163
encodingAsUTF8: localFileSystem.readFileContents(entrypointPath)
162164
.description
@@ -173,10 +175,11 @@ struct Bundle: AsyncParsableCommand {
173175

174176
try localFileSystem.writeFileContents(
175177
AbsolutePath(bundleDirectory, "index.html"),
176-
bytes: ByteString(encodingAsUTF8: HTML.indexPage(
177-
customContent: HTML.readCustomIndexPage(at: customIndexPage, on: localFileSystem),
178-
entrypointName: entrypointName
179-
))
178+
bytes: ByteString(
179+
encodingAsUTF8: HTML.indexPage(
180+
customContent: HTML.readCustomIndexPage(at: customIndexPage, on: localFileSystem),
181+
entrypointName: entrypointName
182+
))
180183
)
181184

182185
let manifest = try toolchain.manifest.get()

Sources/CartonCLI/Commands/Dev.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ struct Dev: AsyncParsableCommand {
126126
verbose: verbose,
127127
port: port,
128128
host: host,
129-
customIndexPath: customIndexPage.map { AbsolutePath($0, relativeTo: localFileSystem.currentWorkingDirectory!) },
129+
customIndexPath: customIndexPage.map {
130+
try AbsolutePath(validating: $0, relativeTo: localFileSystem.currentWorkingDirectory!)
131+
},
130132
// swiftlint:disable:next force_try
131133
manifest: try! toolchain.manifest.get(),
132134
product: build.product,

Sources/CartonCLI/Commands/Init.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ struct Init: AsyncParsableCommand {
2525
subcommands: [ListTemplates.self]
2626
)
2727

28-
@Option(name: .long,
29-
help: "The template to base the project on.",
30-
transform: { Templates(rawValue: $0.lowercased()) })
28+
@Option(
29+
name: .long,
30+
help: "The template to base the project on.",
31+
transform: { Templates(rawValue: $0.lowercased()) })
3132
var template: Templates?
3233

33-
@Option(name: .long,
34-
help: "The name of the project") var name: String?
34+
@Option(
35+
name: .long,
36+
help: "The name of the project") var name: String?
3537

3638
func run() async throws {
3739
let terminal = InteractiveWriter.stdout
@@ -50,9 +52,10 @@ struct Init: AsyncParsableCommand {
5052
terminal.write(" in ")
5153
terminal.write("\(name)\n", inColor: .cyan)
5254

53-
guard let packagePath = self.name == nil ?
54-
localFileSystem.currentWorkingDirectory :
55-
AbsolutePath(name, relativeTo: currentDir)
55+
guard
56+
let packagePath = try self.name == nil
57+
? localFileSystem.currentWorkingDirectory
58+
: AbsolutePath(validating: name, relativeTo: currentDir)
5659
else {
5760
terminal.write("Path to project could be created.\n", inColor: .red)
5861
return

Sources/CartonCLI/Commands/Options.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
import ArgumentParser
1616

1717
struct BuildOptions: ParsableArguments {
18-
@Option(name: .customLong("Xswiftc", withSingleDash: true),
19-
parsing: .unconditionalSingleValue,
20-
help: "Pass flag through to all Swift compiler invocations")
18+
@Option(
19+
name: .customLong("Xswiftc", withSingleDash: true),
20+
parsing: .unconditionalSingleValue,
21+
help: "Pass flag through to all Swift compiler invocations")
2122
var swiftCompilerFlags: [String] = []
2223

2324
init() {}

Sources/CartonCLI/Commands/Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import TSCBasic
2020

2121
/// Proxy swift-package command to locally pinned toolchain version.
2222
struct Package: AsyncParsableCommand {
23-
static let configuration = CommandConfiguration(abstract: """
24-
Perform operations on Swift packages.
25-
""")
23+
static let configuration = CommandConfiguration(
24+
abstract: """
25+
Perform operations on Swift packages.
26+
""")
2627

2728
@Argument(wrappedValue: [], parsing: .remaining)
2829
var arguments: [String]

Sources/CartonCLI/Commands/SDK/Local.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ import SwiftToolchain
1818
import TSCBasic
1919

2020
struct Local: ParsableCommand {
21-
static let configuration = CommandConfiguration(abstract: """
22-
Prints SDK version used for the current project or saves it \
23-
in the `.swift-version` file if a version is passed as an argument.
24-
""")
21+
static let configuration = CommandConfiguration(
22+
abstract: """
23+
Prints SDK version used for the current project or saves it \
24+
in the `.swift-version` file if a version is passed as an argument.
25+
""")
2526

2627
@Argument() var version: String?
2728

2829
func run() throws {
2930
let terminal = InteractiveWriter.stdout
30-
let toolchainSystem = ToolchainSystem(fileSystem: localFileSystem)
31-
31+
let toolchainSystem = try ToolchainSystem(fileSystem: localFileSystem)
32+
3233
if let version = version {
3334
let versions = try toolchainSystem.fetchAllSwiftVersions()
3435
if versions.contains(version) {

Sources/CartonCLI/Commands/SDK/Versions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Versions: ParsableCommand {
2525
func run() throws {
2626
let terminal = InteractiveWriter.stdout
2727

28-
let toolchainSystem = ToolchainSystem(fileSystem: localFileSystem)
28+
let toolchainSystem = try ToolchainSystem(fileSystem: localFileSystem)
2929
let versions = try toolchainSystem.fetchAllSwiftVersions()
3030
let localVersion = try toolchainSystem.fetchLocalSwiftVersion()
3131
if versions.count > 0 {

Sources/CartonCLI/Commands/Test.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct Test: AsyncParsableCommand {
4646
private var environment = Environment.wasmer
4747

4848
/// It is implemented as a separate flag instead of a `--environment` variant because `--environment`
49-
/// is designed to accept specific browser names in the future like `--environment firefox`.
49+
/// is designed to accept specific browser names in the future like `--environment firefox`.
5050
/// Then `--headless` should be able to be used with `defaultBrowser` and other browser values.
5151
@Flag(help: "When running browser tests, run the browser in headless mode")
5252
var headless: Bool = false
@@ -83,7 +83,8 @@ struct Test: AsyncParsableCommand {
8383

8484
func validate() throws {
8585
if headless && environment != .defaultBrowser {
86-
throw TestError(description: "The `--headless` flag can be applied only for browser environments")
86+
throw TestError(
87+
description: "The `--headless` flag can be applied only for browser environments")
8788
}
8889
}
8990

@@ -92,7 +93,8 @@ struct Test: AsyncParsableCommand {
9293
let toolchain = try await Toolchain(localFileSystem, terminal)
9394
let bundlePath: AbsolutePath
9495
if let preBundlePath = self.prebuiltTestBundlePath {
95-
bundlePath = AbsolutePath(preBundlePath, relativeTo: localFileSystem.currentWorkingDirectory!)
96+
bundlePath = try AbsolutePath(
97+
validating: preBundlePath, relativeTo: localFileSystem.currentWorkingDirectory!)
9698
guard localFileSystem.exists(bundlePath) else {
9799
terminal.write(
98100
"No prebuilt binary found at \(bundlePath)\n",

0 commit comments

Comments
 (0)