Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Show the shader popup on upstream's note, drop patch 0006 (#320)
Daniel Johnsona565eeac3f07
diff --git a/frontend-qt/nspb_qt/build_notes.py b/frontend-qt/nspb_qt/build_notes.pyindex 1583c0e5..8fa21c34 100644--- a/frontend-qt/nspb_qt/build_notes.py+++ b/frontend-qt/nspb_qt/build_notes.py@@ -1,14 +1,14 @@"""Build-script notes that the Qt window shows as popups. No Qt in here, so the tests run anywhere.-The Mac app reads the same news from the script's events, which `--progress lines` does not send.+The Mac app matches the same text (`NXCore/BuildNotes.swift`)."""from __future__ import annotations# Printed by build_ipa_from_nsp.py before it rebuilds the shader libraries (with the `shaders_stale` event), then its reasonSTALE_SHADERS = '[NOTE] cached shader libraries cannot be reused'-CHAIN_CHANGED = 'the translation chain changed' # the reason the popup's text describes: a new shader translator+CHAIN_REASON = 'the translation chain changed' # the reason the popup's text describes: a new shader translatordef chain_changed(text: str) -> bool:"""Whether text holds the note for a changed shader translator."""- return STALE_SHADERS in text and CHAIN_CHANGED in text+ return STALE_SHADERS in text and CHAIN_REASON in textdiff --git a/frontend-qt/tests/test_build_notes.py b/frontend-qt/tests/test_build_notes.pyindex db217c7a..7418ac95 100644--- a/frontend-qt/tests/test_build_notes.py+++ b/frontend-qt/tests/test_build_notes.py@@ -33,7 +33,7 @@ class BuildNotesTest(unittest.TestCase):"""An engine update that rewords the note fails here, instead of losing the popup."""text = SCRIPT.read_text(encoding='utf-8')self.assertIn(bn.STALE_SHADERS, text)- self.assertIn(bn.CHAIN_CHANGED, text)+ self.assertIn(bn.CHAIN_REASON, text)if __name__ == '__main__':diff --git a/frontend/Sources/NXCore/BuildNotes.swift b/frontend/Sources/NXCore/BuildNotes.swiftnew file mode 100644index 00000000..18c168ef--- /dev/null+++ b/frontend/Sources/NXCore/BuildNotes.swift@@ -0,0 +1,14 @@+import Foundation++/// LNPANDY/NX2Apple#320: build-script notes the launcher shows as popups. The Qt window matches the same text (`nspb_qt/build_notes.py`).+package enum BuildNotes {+ /// Printed by build_ipa_from_nsp.py before it rebuilds the shader libraries (with the `shaders_stale` event), then its reason.+ package static let staleShaders = "[NOTE] cached shader libraries cannot be reused"+ /// The reason the popup's text describes: a new shader translator.+ package static let chainReason = "the translation chain changed"++ /// Whether text holds the note for a changed shader translator.+ package static func chainChanged(_ text: String) -> Bool {+ text.contains(staleShaders) && text.contains(chainReason)+ }+}diff --git a/frontend/Sources/NXModel/BuildStore.swift b/frontend/Sources/NXModel/BuildStore.swiftindex 615bbad3..7ba17c54 100644--- a/frontend/Sources/NXModel/BuildStore.swift+++ b/frontend/Sources/NXModel/BuildStore.swift@@ -275,13 +275,13 @@ func hop(_ body: @escaping @MainActor () -> Void) {}}- /// The script marks a shader-chain bump with this tag: the cached libraries cannot be- /// reused and this build recompiles them. An alert, not a log line — the report's question+ /// The script notes a shader-chain bump: the cached libraries cannot be reused and this+ /// build recompiles them. An alert, not a log line — the report's question/// ("why is it building shaders again, the artifacts are on the drive") came from exactly/// this moment passing unnoticed. Once per build: the pipe delivers arbitrary chunks./// (A plain line, or the message of a `say` event in `--progress json`.)package func noteChainChange(_ text: String) {- guard text.contains("[NOTE] chain-changed"), !chainNoteShown else { return }+ guard BuildNotes.chainChanged(text), !chainNoteShown else { return }chainNoteShown = trueshowNotice(t("msg.chainChanged"))}diff --git a/frontend/Tests/NXCoreTests/BuildNotesTests.swift b/frontend/Tests/NXCoreTests/BuildNotesTests.swiftnew file mode 100644index 00000000..10594628--- /dev/null+++ b/frontend/Tests/NXCoreTests/BuildNotesTests.swift@@ -0,0 +1,18 @@+import XCTest+@testable import NXCore++/// LNPANDY/NX2Apple#320: the shader popup opens on upstream's note, not on patch 0006's. The Qt tests check the same lines.+final class BuildNotesTests: XCTestCase {+ func testANewTranslatorShowsThePopup() {+ XCTAssertTrue(BuildNotes.chainChanged("[NOTE] cached shader libraries cannot be reused (b-4e0dd2535996 -> b-b7cd656abd7c): "+ + "the translation chain changed; 65 base libraries scheduled"))+ }++ func testOtherLinesDoNot() {+ for line in ["[NOTE] cached shader libraries cannot be reused (3f1c -> 9a20): the game profile's shader inputs changed",+ "[NOTE] chain-changed: b-4e0dd2535996 -> b-b7cd656abd7c: the upstream update changed the shader translator",+ "[5/9] shaders"] {+ XCTAssertFalse(BuildNotes.chainChanged(line), line)+ }+ }+}diff --git a/frontend/Tests/NXModelTests/BuildStoreTests.swift b/frontend/Tests/NXModelTests/BuildStoreTests.swiftindex 24ba6971..112c41c0 100644--- a/frontend/Tests/NXModelTests/BuildStoreTests.swift+++ b/frontend/Tests/NXModelTests/BuildStoreTests.swift@@ -200,8 +200,9 @@ import XCTestlet store = makeStore()var notices: [String] = []store.showNotice = { notices.append($0) }- store.ingest("{\"ev\":\"say\",\"msg\":\"[NOTE] chain-changed: recompiling\"}\n")- store.ingest("[NOTE] chain-changed again\n")+ let note = "[NOTE] cached shader libraries cannot be reused (b-4e0dd2535996 -> b-b7cd656abd7c): the translation chain changed"+ store.ingest("{\"ev\":\"say\",\"msg\":\"\(note)\"}\n")+ store.ingest(note + " again\n")XCTAssertEqual(notices, [store.t("msg.chainChanged")])}