Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Engine update: re-run wineboot only when the Wine build changed
Gauthier Piarrette62da55647b8c
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex 3092574..d48a5c5 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -283,12 +283,17 @@ final class AppState {}}await MainActor.run { self.appendLog("engine \(fresh.id) installed") }+ let refresh = EngineManifest.needsPrefixRefresh(from: old.manifest, to: fresh.manifest)for var bottle in try bottleStore.list() where bottle.settings.engineID != fresh.id {let runnerOld = WineRunner(paths: paths, engine: old, bottle: bottle)try? runnerOld.kill()try? await Task.sleep(for: .seconds(2))bottle.settings.engineID = fresh.idtry bottle.save()+ guard refresh else {+ await MainActor.run { self.appendLog("bottle '\(bottle.name)' moved to \(fresh.id) (same Wine, no prefix refresh needed)") }+ continue+ }await MainActor.run { self.stage = String(format: L("Refreshing bottle '%@'"), bottle.name) }let runner = WineRunner(paths: paths, engine: fresh, bottle: bottle)let r = try await runner.wineboot()diff --git a/Sources/HighballKit/Manifest.swift b/Sources/HighballKit/Manifest.swiftindex 1f75d83..c544755 100644--- a/Sources/HighballKit/Manifest.swift+++ b/Sources/HighballKit/Manifest.swift@@ -68,6 +68,15 @@ public struct EngineManifest: Codable, Sendable, Identifiable {}/// Components in a deterministic install order: required first, then optional.+ /// Whether moving bottles from `old` to `new` needs `wineboot -u`: only when the Wine build+ /// itself changed. A component-only update (a patched MoltenVK on the same Wine) leaves the+ /// prefix as it is, and skipping the boot matters: a prefix with a real .NET install wedged+ /// in wineboot's 32-bit step on both engines during the r1 rollout test.+ public static func needsPrefixRefresh(from old: EngineManifest, to new: EngineManifest) -> Bool {+ guard let a = old.components["wine"]?.sha256, let b = new.components["wine"]?.sha256 else { return true }+ return a != b+ }+public var orderedComponents: [(name: String, component: Component)] {components.sorted { a, b inif a.value.isOptional != b.value.isOptional { return !a.value.isOptional }diff --git a/Sources/highball/main.swift b/Sources/highball/main.swiftindex f2da6b6..a221d88 100644--- a/Sources/highball/main.swift+++ b/Sources/highball/main.swift@@ -138,8 +138,8 @@ struct Bottle: AsyncParsableCommand {var b = try bs.get(name)switch setting {case "engine":- // Point the bottle at another installed engine; run `bottle repair` afterwards so- // the prefix's Windows environment matches it.+ // Point the bottle at another installed engine. Run `bottle repair` afterwards only+ // if the Wine build changed (a component-only engine, like r1's MoltenVK, needs none).guard let eng = try? EngineStore().engine(value) else { fail("engine '\(value)' is not installed") }b.settings.engineID = eng.idcase "renderer":diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 0a385c1..e12516a 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -699,6 +699,21 @@ extension RegressionTests {XCTAssertNil(EngineStore.defaultEngine(installed: [], bundledID: new.id))}+ // An engine update only re-runs wineboot on each bottle when the Wine build changed. r1 is+ // r0 plus a MoltenVK component; booting every prefix for it is pure risk (a bottle with a real+ // .NET install wedged in wineboot's 32-bit step on both engines when this was tried).+ func testPrefixRefreshOnlyWhenWineChanges() throws {+ func manifest(_ wineSha: String?, id: String) throws -> EngineManifest {+ let wine = wineSha.map { #","wine":{"kind":"engine","url":"https://x/w.tar.xz","sha256":"\#($0)","extract":{"into":"engine"}}"# } ?? ""+ let json = #"{"id":"\#(id)","displayName":"e","arch":"x86_64","minMacOS":"14.0","components":{"runtime":{"kind":"frameworks","url":"https://x/r.tar.xz","sha256":"r","extract":{"into":"frameworks"}}\#(wine)}}"#+ return try JSONDecoder().decode(EngineManifest.self, from: Data(json.utf8))+ }+ let r0 = try manifest("aaa", id: "r0"), r1 = try manifest("aaa", id: "r1"), r2 = try manifest("bbb", id: "r2")+ XCTAssertFalse(EngineManifest.needsPrefixRefresh(from: r0, to: r1), "same Wine: no wineboot")+ XCTAssertTrue(EngineManifest.needsPrefixRefresh(from: r0, to: r2), "Wine changed: wineboot")+ XCTAssertTrue(EngineManifest.needsPrefixRefresh(from: try manifest(nil, id: "x"), to: r1), "unknown: be safe, boot")+ }+// extract() with a single-file `into` replaces that file and nothing else in the directory.// The old code treated every target as a directory, so a file target would have removed// the whole frameworks tree on the way in.