Update SwiftPM library version to 5.7 (#381)

This commit is contained in:
Yuta Saito 2022-09-25 20:52:39 +09:00 committed by GitHub
parent 734e333a43
commit daf152d93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 32 deletions

View File

@ -113,8 +113,8 @@
"package": "swift-driver",
"repositoryURL": "https://github.com/apple/swift-driver.git",
"state": {
"branch": "release/5.6",
"revision": "9982f32f96a2e0e597d1b4a0af4a7e997dc471be",
"branch": "release/5.7",
"revision": "719426df790661020de657bf38beb2a8b1de5ad3",
"version": null
}
},
@ -122,8 +122,8 @@
"package": "llbuild",
"repositoryURL": "https://github.com/apple/swift-llbuild.git",
"state": {
"branch": "release/5.6",
"revision": "acd686530e56122d916acd49a166beb9198e9b87",
"branch": "release/5.7",
"revision": "564424db5fdb62dcb5d863bdf7212500ef03a87b",
"version": null
}
},
@ -203,17 +203,26 @@
"package": "SwiftPM",
"repositoryURL": "https://github.com/apple/swift-package-manager.git",
"state": {
"branch": "release/5.6",
"revision": "55c1dc785b151cb51a54314ebc30a96d5cbaddf2",
"branch": "release/5.7",
"revision": "63c14b84dc12c943a9d4c102648b7617d8b92f67",
"version": null
}
},
{
"package": "swift-system",
"repositoryURL": "https://github.com/apple/swift-system.git",
"state": {
"branch": null,
"revision": "836bc4557b74fe6d2660218d56e3ce96aff76574",
"version": "1.1.1"
}
},
{
"package": "swift-tools-support-core",
"repositoryURL": "https://github.com/apple/swift-tools-support-core.git",
"state": {
"branch": "release/5.6",
"revision": "f6c8048a76e280d0f14cc378b8b5c3cfb77c61fb",
"branch": "release/5.7",
"revision": "184eba382f6abbb362ffc02942d790ff35019ad4",
"version": null
}
},

View File

@ -27,11 +27,11 @@ let package = Package(
.package(
name: "SwiftPM",
url: "https://github.com/apple/swift-package-manager.git",
.branch("release/5.6")
.branch("release/5.7")
),
.package(
url: "https://github.com/apple/swift-tools-support-core.git",
.branch("release/5.6")
.branch("release/5.7")
),
.package(url: "https://github.com/vapor/vapor.git", from: "4.57.1"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "1.1.0"),
@ -81,6 +81,7 @@ let package = Package(
dependencies: [
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
"Splash",
"WasmTransformer",
]

View File

@ -146,7 +146,7 @@ struct Bundle: AsyncParsableCommand {
wasmOutputFilePath: AbsolutePath,
buildDirectory: AbsolutePath,
bundleDirectory: AbsolutePath,
toolchain: Toolchain,
toolchain: SwiftToolchain.Toolchain,
product: ProductDescription
) throws {
// Rename the final binary to use a part of its hash to bust browsers and CDN caches.

View File

@ -22,7 +22,8 @@ import Workspace
extension Manifest {
static func from(path: AbsolutePath, swiftc: AbsolutePath, fileSystem: FileSystem, terminal: InteractiveWriter) async throws -> Manifest {
terminal.write("\nParsing package manifest: ", inColor: .yellow)
let toolchain = ToolchainConfiguration(swiftCompilerPath: swiftc)
let destination = try Destination.hostDestination(swiftc.parentDirectory)
let toolchain = try UserToolchain(destination: destination)
let loader = ManifestLoader(toolchain: toolchain)
let observability = ObservabilitySystem { _, diagnostic in
terminal.write("\n\(diagnostic)")

View File

@ -351,30 +351,34 @@ public final class Toolchain {
private func basicBuildArguments(flavor: BuildFlavor) -> [String] {
var builderArguments = ["--triple", "wasm32-unknown-wasi"]
// Versions later than 5.3.x have test discovery enabled by default and the explicit flag
// deprecated.
if ["wasm-5.3.0-RELEASE", "wasm-5.3.1-RELEASE"].contains(version) {
builderArguments.append("--enable-test-discovery")
}
if let wasmVersion = try? Version(swiftWasmVersion: version) {
// Versions later than 5.3.x have test discovery enabled by default and the explicit flag
// deprecated.
if wasmVersion.major == 5, wasmVersion.minor == 3 {
builderArguments.append("--enable-test-discovery")
}
// SwiftWasm 5.5 requires explicit linking arguments in certain configurations,
// see https://github.com/swiftwasm/swift/issues/3891
if version.starts(with: "wasm-5.5") {
builderArguments.append(contentsOf: ["-Xlinker", "-licuuc", "-Xlinker", "-licui18n"])
}
// SwiftWasm 5.5 requires explicit linking arguments in certain configurations,
// see https://github.com/swiftwasm/swift/issues/3891
if wasmVersion.major == 5, wasmVersion.minor == 5 {
builderArguments.append(contentsOf: ["-Xlinker", "-licuuc", "-Xlinker", "-licui18n"])
}
// SwiftWasm 5.6 requires reactor model from updated wasi-libc when not building as a command
// see https://github.com/WebAssembly/WASI/issues/13
if version.starts(with: "wasm-5.6") && flavor.environment != .wasmer {
builderArguments.append(contentsOf: [
"-Xswiftc", "-Xclang-linker", "-Xswiftc", "-mexec-model=reactor",
"-Xlinker", "--export=main",
])
// SwiftWasm 5.6 and up requires reactor model from updated wasi-libc when not building as a command
// see https://github.com/WebAssembly/WASI/issues/13
if wasmVersion >= Version(5, 6, 0) && flavor.environment != .wasmer {
builderArguments.append(contentsOf: [
"-Xswiftc", "-Xclang-linker", "-Xswiftc", "-mexec-model=reactor",
"-Xlinker", "--export=main",
])
}
}
builderArguments.append(contentsOf: flavor.swiftCompilerFlags.flatMap {
["-Xswiftc", $0]
})
return builderArguments
}
@ -405,3 +409,22 @@ extension Result where Failure == Error {
}
}
}
extension Version {
/// Initialize a numeric version from a SwiftWasm Toolchain version string, e.g.:
/// "wasm-5.3.1-RELEASE", "wasm-5.7-SNAPSHOT-2022-07-14-a",
/// **discarding all identifiers**.
/// Note: input toolchain name already has "swift-" prefix stripped.
init(swiftWasmVersion: String) throws {
let prefix = "wasm-"
guard swiftWasmVersion.hasPrefix(prefix) else {
throw ToolchainError.invalidVersion(version: swiftWasmVersion)
}
var swiftWasmVersion = swiftWasmVersion
swiftWasmVersion.removeFirst(prefix.count)
let version = try Version(versionString: swiftWasmVersion, usesLenientParsing: true)
// Strip prereleaseIdentifiers
self.init(version.major, version.minor, version.patch)
}
}

View File

@ -325,7 +325,8 @@ public extension XCTest {
if expectedContains {
XCTAssertTrue(
finalString.contains(expected),
"The final string \(finalString) does not contain \(expected)"
"The final string \(finalString) does not contain \(expected)",
file: file, line: line
)
} else {
AssertEqualStringsIgnoringTrailingWhitespace(

View File

@ -15,13 +15,14 @@
import CartonHelpers
@testable import CartonKit
import class Foundation.Bundle
import SwiftToolchain
@testable import SwiftToolchain
import TSCBasic
import TSCUtility
import XCTest
final class CartonTests: XCTestCase {
/// Returns path to the built products directory.
var productsDirectory: URL {
var productsDirectory: Foundation.URL {
#if os(macOS)
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
return bundle.bundleURL.deletingLastPathComponent()
@ -143,4 +144,20 @@ final class CartonTests: XCTestCase {
nil
)
}
func testSwiftWasmVersionParsing() throws {
let v5_6 = try Version(swiftWasmVersion: "wasm-5.6.0-RELEASE")
XCTAssertEqual(v5_6.major, 5)
XCTAssertEqual(v5_6.minor, 6)
XCTAssertEqual(v5_6.patch, 0)
XCTAssert(v5_6.prereleaseIdentifiers.isEmpty)
XCTAssert(v5_6 >= Version(5, 6, 0))
let v5_7_snapshot = try Version(swiftWasmVersion: "wasm-5.7-SNAPSHOT-2022-07-14-a")
XCTAssertEqual(v5_7_snapshot.major, 5)
XCTAssertEqual(v5_7_snapshot.minor, 7)
XCTAssertEqual(v5_7_snapshot.patch, 0)
XCTAssert(v5_7_snapshot.prereleaseIdentifiers.isEmpty)
XCTAssert(v5_7_snapshot >= Version(5, 6, 0))
}
}