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
Fingerprint the selected SPIRV-Cross in the shader stage key
seeddsecdc92e09a90
diff --git a/frontend-qt/nspb_qt/win/driver.py b/frontend-qt/nspb_qt/win/driver.pyindex 8fbfe990..f31b0290 100644--- a/frontend-qt/nspb_qt/win/driver.py+++ b/frontend-qt/nspb_qt/win/driver.py@@ -231,15 +231,21 @@ def patch(mod: ModuleType, repo: Path, *, j: int | None = None) -> None:def toolchain_probe(repo_=None, env=None):"""What the shader-stage cache keys record as "the compilers".- Upstream records `xcodebuild -version` and `spirv-cross --revision`. Here the Metal- compiler's own version is what actually changes the output, so it is recorded instead;- a Metal Tools upgrade then invalidates the cache, which is the behaviour we want.+ Upstream records `xcodebuild -version` and fingerprints the SPIRV-Cross+ executable returned by `spirv_cross(repo, env)`. Here the Metal compiler's+ own version is what actually changes the output, so it is recorded instead;+ a Metal Tools upgrade then invalidates the cache, which is the behaviour+ we want. The SPIRV-Cross entry uses the upstream resolver as well, so the+ cache follows `SPIRV_CROSS` (an explicit path or an executable on PATH),+ not whichever `spirv-cross` happens to be found by a separate lookup."""xc = [sys.executable, str(Path(__file__).resolve().parent / 'xcrun_shim.py')]probes = [('cmd', [*xc, '-sdk', 'iphoneos', 'metal', '--version'])]if os.environ.get('NSPB_MAC_METAL'):probes.append(('cmd', [*xc, '-sdk', 'macosx', 'metal', '--version']))- probes.append(('cmd', ['spirv-cross', '--revision']))+ if repo_ is None:+ repo_ = Path(__file__).resolve().parents[3]+ probes.append(('files', [mod.spirv_cross(repo_, env)]))return tuple(probes)mod.toolchain = toolchain_probediff --git a/frontend-qt/nspb_qt/win/toolchain.py b/frontend-qt/nspb_qt/win/toolchain.pyindex 508f650a..00c5a0c0 100644--- a/frontend-qt/nspb_qt/win/toolchain.py+++ b/frontend-qt/nspb_qt/win/toolchain.py@@ -955,8 +955,11 @@ def probe_link(sdk: Path) -> tuple[bool, str]:# Step 0: run the linker by itself. A silent clang failure (the report: exit 1, no output on# either stream) cannot say whether the linker is broken or clang's drive of it is, and the# two have different fixes. lld --version is the smallest probe that separates them.- v = subprocess.run([str(lld), '--version'], capture_output=True, text=True, timeout=60,- **no_window())+ try:+ v = subprocess.run([str(lld), '--version'], capture_output=True, text=True, timeout=60,+ **no_window())+ except OSError as e:+ return False, f'cannot run {lld.name}: {e}'lld_self = (v.stdout or v.stderr or '').strip().splitlines()lld_line = lld_self[0] if lld_self else f'exit {v.returncode}, no output'if v.returncode != 0:diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.pyindex c7fd2418..e89ba38f 100644--- a/frontend-qt/tests/test_win.py+++ b/frontend-qt/tests/test_win.py@@ -692,6 +692,29 @@ class DriverPatchTest(unittest.TestCase):self.assertIn('metal', joined)self.assertNotIn('xcodebuild', joined)+ def test_stage_key_fingerprints_the_selected_spirv_cross(self) -> None:+ """Switching SPIRV_CROSS must invalidate the shader-stage key."""+ with tempfile.TemporaryDirectory() as td:+ a = Path(td) / 'cross-a.exe'+ b = Path(td) / 'cross-b.exe'+ a.write_bytes(b'first')+ b.write_bytes(b'second')++ def files(probes):+ return [p for kind, values in probes if kind == 'files' for p in values]++ first = self.mod.toolchain(self.repo, {'SPIRV_CROSS': str(a), 'PATH': ''})+ second = self.mod.toolchain(self.repo, {'SPIRV_CROSS': str(b), 'PATH': ''})+ self.assertIn(a, files(first))+ self.assertIn(b, files(second))+ self.assertNotEqual(self.mod.fingerprint(('files', [a])),+ self.mod.fingerprint(('files', [b])))+ # The same selected path with changed executable contents must also+ # change the key, or a rebuilt compiler would reuse the old library.+ before = self.mod.fingerprint(('files', [a]))+ a.write_bytes(b'changed')+ self.assertNotEqual(before, self.mod.fingerprint(('files', [a])))+def test_tool_paths_are_replaced_not_extended(self) -> None:"""On Windows the upstream macOS list must be gone.@@ -1277,7 +1300,8 @@ class PythonInstallTest(unittest.TestCase):shim.parent.mkdir(parents=True)shim.write_text('#!/bin/sh\n')with mock.patch.object(pu, 'IS_WIN', False), \- mock.patch.dict(os.environ, {'UV_PYTHON_INSTALL_DIR': str(store), 'HOME': td}):+ mock.patch.dict(os.environ, {'UV_PYTHON_INSTALL_DIR': str(store), 'HOME': td,+ 'USERPROFILE': td}):cands = pu.uv_pythons()self.assertIn(str(exe), cands, "uv's store holds the real interpreter")self.assertIn(str(shim), cands, "uv links a python3 shim in ~/.local/bin")@@ -1727,7 +1751,7 @@ class LinkProbeStrategyTest(unittest.TestCase):"""def test_the_strategy_order_is_build_style_first(self) -> None:- src = (QT / 'nspb_qt' / 'win' / 'toolchain.py').read_text()+ src = (QT / 'nspb_qt' / 'win' / 'toolchain.py').read_text(encoding='utf-8')body = src[src.index('def probe_link'):]self.assertLess(body.index("'-fuse-ld=lld'"), body.index('f\'--ld-path={lld}\''),'the build\'s own invocation must be tried before --ld-path')@@ -1750,7 +1774,7 @@ class InstallFailureHintTest(unittest.TestCase):classify = M.Model._classify_install_failureexcept ImportError:import ast- src = (HERE.parent / 'nspb_qt' / 'model.py').read_text()+ src = (HERE.parent / 'nspb_qt' / 'model.py').read_text(encoding='utf-8')tree = ast.parse(src)fn = next(n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)and n.name == '_classify_install_failure')