Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Show the Qt shader-rebuild popup for upstream's note and drop patch 0006 (#320)

Daniel Johnsonad80a857d3e3
diff --git a/frontend-qt/nspb_qt/build_notes.py b/frontend-qt/nspb_qt/build_notes.py
new file mode 100644
index 00000000..1583c0e5
--- /dev/null
+++ b/frontend-qt/nspb_qt/build_notes.py
@@ -0,0 +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.
+"""
+from __future__ import annotations
+
+# Printed by build_ipa_from_nsp.py before it rebuilds the shader libraries (with the `shaders_stale` event), then its reason
+STALE_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
+
+
+def 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
diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.py
index a6823d68..3b3be16b 100644
--- a/frontend-qt/nspb_qt/ui.py
+++ b/frontend-qt/nspb_qt/ui.py
@@ -15,6 +15,7 @@ from PySide6.QtWidgets import (
)
from . import platform_util as pu
+from .build_notes import chain_changed
from .model import DepState, Model
from .style import CARD_EDGE, GREEN, MUTED, ORANGE, RED
@@ -685,11 +686,9 @@ class MainWindow(QMainWindow):
self.log.moveCursor(self.log.textCursor().MoveOperation.End)
self.log.insertPlainText(s)
self.log.moveCursor(self.log.textCursor().MoveOperation.End)
- # The script marks a shader-chain bump with this tag: the cached libraries cannot be
- # reused and this build recompiles them. A popup, 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 log chunks arrive in pieces.
- if '[NOTE] chain-changed' in s and not getattr(self, '_chain_note_shown', False):
+ # A new shader translator: show a popup, once per build.
+ # Why a popup: a report asked why the shaders were building again, because the log line went unnoticed.
+ if chain_changed(s) and not getattr(self, '_chain_note_shown', False):
self._chain_note_shown = True
from PySide6.QtWidgets import QMessageBox
QMessageBox.information(self, 'NS Port Builder', self.m.t('msg.chainChanged'))
@@ -728,6 +727,7 @@ class MainWindow(QMainWindow):
self.footer.setText('')
self.footer.setStyleSheet('')
self._failed = False
+ self._chain_note_shown = False
self.failure_box.hide()
self.m.start_build()
diff --git a/frontend-qt/tests/test_build_notes.py b/frontend-qt/tests/test_build_notes.py
new file mode 100644
index 00000000..db217c7a
--- /dev/null
+++ b/frontend-qt/tests/test_build_notes.py
@@ -0,0 +1,40 @@
+"""Issue #320: the Qt popup for a new shader translator reads upstream's note, not patch 0006's.
+
+ python3 -m unittest frontend-qt/tests/test_build_notes.py -v
+"""
+from __future__ import annotations
+
+import sys
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+sys.path.insert(0, str(ROOT / 'frontend-qt'))
+
+from nspb_qt import build_notes as bn # noqa: E402
+
+SCRIPT = ROOT / 'engine/scripts/build_ipa_from_nsp.py'
+
+
+class BuildNotesTest(unittest.TestCase):
+ def test_a_new_translator_shows_the_popup(self):
+ self.assertTrue(bn.chain_changed('[NOTE] cached shader libraries cannot be reused (b-4e0dd2535996 -> b-b7cd656abd7c): '
+ 'the translation chain changed; 65 base libraries scheduled'))
+
+ def test_other_lines_do_not(self):
+ 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'):
+ with self.subTest(line=line):
+ self.assertFalse(bn.chain_changed(line))
+
+ @unittest.skipUnless(SCRIPT.is_file(), 'engine/ is not synced (python3 tools/engine.py sync)')
+ def test_the_engines_script_still_prints_the_note(self):
+ """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)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/patches/0006-nsp-chain-changed-note.patch b/patches/0006-nsp-chain-changed-note.patch
deleted file mode 100644
index b68ba482..00000000
--- a/patches/0006-nsp-chain-changed-note.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: v0lumehi <[email protected]>
-Date: Wed, 28 Oct 2026 13:33:54 +0100
-Subject: [PATCH] NSP script: a [NOTE] chain-changed line when cached libraries
- are stale
-
-Printed before the shader step when b-<chain> differs from the cached libraries.
-
-Upstream-Status: fork-only (seedds/nxnative#490 landed as the shaders_stale event, not this text note)
-Reason: The front ends turn the [NOTE] chain-changed marker into a notice when cached shader libraries are from an older chain; upstream's shaders_stale event (seedds/nxnative#490) does not carry that marker, so the launcher keeps this note until it reads the event
-Issue: LNPANDY/NX2Apple#123
----
- scripts/build_ipa_from_nsp.py | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.py
-index 50e040e..f869f4e 100755
---- a/scripts/build_ipa_from_nsp.py
-+++ b/scripts/build_ipa_from_nsp.py
-@@ -1989,6 +1989,11 @@ def build_shaders(py, repo, sh, xlate, env, logs, g, pkg_key=None, mac=False):
- ios, log = sh / 'ios', logs / 'dmsh_build.log'
- PROG.stage('Mac shaders' if mac else 'iOS shaders')
- chain = chain_of(repo)
-+ stale = sorted(d.name for d in (sh / 'cache').glob('b-*') if d.name != f'b-{chain}' and any(d.glob('*_b.metallib'))
-+ ) + sorted(d.name for d in ios.glob('b-*') if d.name != f'b-{chain}' and any(d.glob('*_b.metallib')))
-+ if stale: say(f'[NOTE] chain-changed: {", ".join(stale)} -> b-{chain}: the upstream update changed the shader '
-+ 'translator, so the cached libraries cannot be reused and this build rebuilds them with it '
-+ '(once per update; later builds reuse as before)')
- out = sh / 'cache' if mac else ios
- libs, kf, kmac = out / f'b-{chain}', ios / f'b-{chain}.key', sh / f'mac-b-{chain}.key'
- pso_pairs = g.table('pso_pairs.tsv')
diff --git a/patches/series b/patches/series
index 113e7925..85445213 100644
--- a/patches/series
+++ b/patches/series
@@ -3,7 +3,6 @@
0003-ios-game-data-folder.patch
0004-ios-slim-ipa.patch
0005-nsp-dotnet-home.patch
-0006-nsp-chain-changed-note.patch
0008-bc-cpu-decode.patch
0009-mac-keymap.patch
0010-mac-library-folder.patch