Skip to content

Commit

Permalink
Update to Swift 6.0.2 (#18)
Browse files Browse the repository at this point in the history
* Update swift testing

* Swift concurrency fixes and workarounds

* Dont run formatting on gha

* More fixes

* Fix build

* More fixes

* More
  • Loading branch information
modmuss50 authored Dec 9, 2024
1 parent 99bc856 commit 97e561d
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 74 deletions.
39 changes: 6 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ jobs:
msbuild-architecture: x64
- uses: compnerd/gha-setup-swift@main
with:
github-repo: thebrowsercompany/swift-build
github-token: ${{ secrets.GITHUB_TOKEN }}
release-tag-name: 20240422.2
release-asset-name: installer-amd64.exe
branch: swift-6.0.2-release
tag: 6.0.2-RELEASE
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
Expand All @@ -37,43 +35,18 @@ jobs:
msbuild-architecture: x64
- uses: compnerd/gha-setup-swift@main
with:
github-repo: thebrowsercompany/swift-build
github-token: ${{ secrets.GITHUB_TOKEN }}
release-tag-name: 20240422.2
release-asset-name: installer-amd64.exe
branch: swift-6.0.2-release
tag: 6.0.2-RELEASE
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- run: ./gradlew :windows:copyJniHeaders
# Patch to fix building Foundation on Windows with c++ interop, remove in Swift 6.1
- run: (Get-Content -Raw -Path "$env:LOCALAPPDATA\Programs\Swift\Platforms\6.0.2\Windows.platform\Developer\SDKs\Windows.sdk\usr\share\ucrt.modulemap") -replace "module complex \{[\s\S]*?\}", "module complex {`n }" | Set-Content -Path "$env:LOCALAPPDATA\Programs\Swift\Platforms\6.0.2\Windows.platform\Developer\SDKs\Windows.sdk\usr\share\ucrt.modulemap"
- name: Swift build
working-directory: ./windows
run: swift build
- name: Swift test
working-directory: ./windows
run: swift test --disable-xctest

format:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: microsoft/[email protected]
with:
msbuild-architecture: x64
- uses: compnerd/gha-setup-swift@main
with:
github-repo: thebrowsercompany/swift-build
github-token: ${{ secrets.GITHUB_TOKEN }}
release-tag-name: 20240422.2
release-asset-name: installer-amd64.exe
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- run: ./gradlew :windows:copyJniHeaders
- name: Swift format
working-directory: ./windows
run: swift run swift-format format -r -p Sources/ Tests/
- name: Swift lint
working-directory: ./windows
run: swift run swift-format lint -r -p Sources/ Tests/
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ jobs:
msbuild-architecture: x64
- uses: compnerd/gha-setup-swift@main
with:
github-repo: thebrowsercompany/swift-build
github-token: ${{ secrets.GITHUB_TOKEN }}
release-tag-name: 20240422.2
release-asset-name: installer-amd64.exe
branch: swift-6.0.2-release
tag: 6.0.2-RELEASE
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
Expand Down
3 changes: 2 additions & 1 deletion windows/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Sources/Jni
Sources/Hook/include/Runtime-Swift.h
Sources/Hook/include/Runtime-Swift.h
.index-build
18 changes: 9 additions & 9 deletions windows/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-format",
"state" : {
"branch" : "58c2ef5",
"revision" : "58c2ef514d5b8b3766d2d0957b816a8387b01fed"
"revision" : "65f9da9aad84adb7e2028eb32ca95164aa590e3b",
"version" : "600.0.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
"version" : "1.6.2"
}
},
{
Expand All @@ -57,19 +57,19 @@
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"branch" : "main",
"revision" : "4824d4d0ee6b733f8fb87016b165e55c37127190"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
"identity" : "swift-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-testing",
"state" : {
"revision" : "8097dd8bcf7f2ed85f8aa8883635ce413012f53b",
"version" : "0.6.0"
"branch" : "399f76",
"revision" : "399f76dcd91e4c688ca2301fa24a8cc6d9927211"
}
}
],
Expand Down
6 changes: 3 additions & 3 deletions windows/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ let package = Package(
.executable(name: "Packager", targets: ["Packager"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-format", revision: "58c2ef5"),
.package(url: "https://github.com/apple/swift-testing", .upToNextMinor(from: "0.6.0")),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-format", from: "600.0.0"),
.package(url: "https://github.com/apple/swift-testing", revision: "399f76"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.2"),
.package(url: "https://github.com/modmuss50/Detours", revision: "23deb11"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/FabricSandbox/FabricSandbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Logging

/// TODO: Add support for LPAC (Less Privileged AppContainer)

private var lpac = false
private let lpac = false

var logger = Logger(label: "net.fabricmc.sandbox")

Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/Packager/SwiftRedistributables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SwiftRedistributables {

let redistributables = try swiftRedistributables()
let archName = arch == .arm64 ? "arm64" : "amd64"
let rtl = redistributables.child("0.0.0").child("rtl.\(archName).msm")
let rtl = redistributables.child("6.0.2").child("rtl.\(archName).msm")

guard rtl.exists() else {
throw PackagerError("Could not find \(rtl)")
Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/Packager/VisualStudio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import WinSDK
import WindowsUtils

struct VisualStudio {
static var dumpBin: File = {
static let dumpBin: File = {
let dumpBin = try! find(
"**/Host\(compileArchitecture.name)/\(compileArchitecture.name)/dumpbin.exe")
return dumpBin
Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/Runtime/Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Shared
import WinSDK
import WindowsUtils

private var pipeClient: NamedPipeClient? = nil
nonisolated(unsafe) private var pipeClient: NamedPipeClient? = nil

public func processAttach() {
// TODO fix me
Expand Down
20 changes: 10 additions & 10 deletions windows/Sources/SandboxTest/SandboxTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import WindowsUtils

@main
class SandboxTest {
static let commands: [String: Command] = [
"smoke": SmokeCommand(),
"readFile": ReadFileCommand(),
"registry": RegistryCommand(),
"namedPipe": NamedPipeCommand(),
"nameMax": NameMaxCommand(),
"mouseMovements": MouseMovementsCommand(),
"speech": SpeechCommand(),
]

static func main() throws {
let commands: [String: Command] = [
"smoke": SmokeCommand(),
"readFile": ReadFileCommand(),
"registry": RegistryCommand(),
"namedPipe": NamedPipeCommand(),
"nameMax": NameMaxCommand(),
"mouseMovements": MouseMovementsCommand(),
"speech": SpeechCommand(),
]

if CommandLine.arguments.count < 2 {
throw SandboxTestError("No arguments")
}
Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/WindowsUtils/Architecture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#elseif arch(arm64)
public let compileArchitecture = Architecture.arm64
#endif
public enum Architecture {
public enum Architecture: Sendable {
case x64
case arm64

Expand Down
2 changes: 1 addition & 1 deletion windows/Sources/WindowsUtils/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import WinSDK

// A file API implementation using Win32 without using the swift foundation library.

public class File: CustomStringConvertible {
public final class File: CustomStringConvertible, Sendable {
static let pathSeparators: [Character] = ["/", "\\"]

let parts: [String]
Expand Down
4 changes: 2 additions & 2 deletions windows/Tests/AppContainerTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Sandbox
@_spi(Experimental) import Testing
import Testing
import WinSDK

@testable import FabricSandbox

@Suite(.serial) struct AppContainerTests {
@Suite(.serialized) struct AppContainerTests {
@Test func testCreateAppContainerNoCapabilities() throws {
let _ = try AppContainer.create(
name: "TestContainer", description: "Test Container", capabilities: [])
Expand Down
4 changes: 2 additions & 2 deletions windows/Tests/IntergrationTests.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Sandbox
@_spi(Experimental) import Testing
import Testing
import WinSDK
import WindowsUtils

@testable import FabricSandbox

/// Run SandboxTest.exe with the given options in a sandbox, returning the exit code and command line output

@Suite(.serial) struct IntergrationTests {
@Suite(.serialized) struct IntergrationTests {
@Test func testRunSmoke() throws {
let (exitCode, output) = try runIntergration(["smoke"])
#expect(exitCode == 0)
Expand Down
4 changes: 2 additions & 2 deletions windows/Tests/JavaTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Sandbox
@_spi(Experimental) import Testing
import Testing
import WindowsUtils

@Suite(.serial) struct JavaTests {
@Suite(.serialized) struct JavaTests {
@Test func testHelloWorld() throws {
let output = try runJava(
"""
Expand Down
4 changes: 2 additions & 2 deletions windows/Tests/MountedDiskTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@_spi(Experimental) import Testing
import Testing
import WinSDK
import WindowsUtils

@testable import FabricSandbox
@testable import Sandbox

@Suite(.serial) struct MountedDiskTests {
@Suite(.serialized) struct MountedDiskTests {
@Test func testGetUsedDriveLetters() throws {
let drives = MountedDisk.getUsedDriveLetters()
#expect(drives.contains("C"))
Expand Down

0 comments on commit 97e561d

Please sign in to comment.