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
Windows: the fifth handheld report — verdicts, evidence, and the missing installers
LNPANDY50cf50a3ee9a
diff --git a/frontend-qt/nspb_qt/i18n.py b/frontend-qt/nspb_qt/i18n.pyindex e9879284..f3444d50 100644--- a/frontend-qt/nspb_qt/i18n.py+++ b/frontend-qt/nspb_qt/i18n.py@@ -32,12 +32,17 @@ class Lang(Enum):tag = ''tag = tag or os.environ.get('LANG', '') or os.environ.get('LC_ALL', '')if not tag and sys.platform.startswith('win'):+ # The **user's** UI language, not the system's: a Chinese Windows install on+ # English-labelled hardware (most handhelds ship en-US as the OS locale) has+ # LOCALE_SYSTEM_DEFAULT = en, and asking that showed an English interface to a+ # Chinese user — the report's "the exe is not fully Chinese". GetUserDefaultUILanguage+ # is what the Settings app's display language reflects.import ctypestry:+ lang = ctypes.windll.kernel32.GetUserDefaultUILanguage() & 0xFF # primary idbuf = ctypes.create_unicode_buffer(85)- ctypes.windll.kernel32.GetUserDefaultUILanguage() # noqa: F841 (kept for clarity)- ctypes.windll.kernel32.GetLocaleInfoW(0x0800, 0x00000002, buf, 85) # LOCALE_SISO639LANGNAME- tag = buf.value+ if ctypes.windll.kernel32.GetLocaleInfoW(lang, 0x00000002, buf, 85): # LOCALE_SISO639LANGNAME+ tag = buf.valueexcept Exception:tag = ''return Lang.ZH if tag.lower().startswith('zh') else Lang.ENdiff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.pyindex 57eff7e8..6165b0ec 100644--- a/frontend-qt/nspb_qt/localization.py+++ b/frontend-qt/nspb_qt/localization.py@@ -131,6 +131,11 @@ TABLE: dict[str, tuple[str, str]] = {'dep.xcodegen': ('brew: xcodegen', 'brew: xcodegen'),'dep.xcodegen.hint': ('Xcode 工程生成', 'generates the Xcode project'),'dep.zstd': ('brew: zstd', 'brew: zstd'),+ 'dep.spirv.win': ('spirv-cross', 'spirv-cross'),+ 'dep.spirv.hint.win': ('仅 OpenGL 游戏需要——<a href="https://vulkan.lunarg.com/sdk/home">Vulkan SDK</a> 自带(装完在 toolchain.json 里指一下 Bin 目录)', 'only OpenGL games need it — the <a href="https://vulkan.lunarg.com/sdk/home">Vulkan SDK</a> ships it (point "spirv_cross_dir" in toolchain.json at its Bin folder)'),+ 'dep.zstd.win': ('zstd', 'zstd'),+ 'dep.zstd.hint.win': ('解压——点「安装」由 App 下载(facebook/zstd 官方 Windows 版)', "decompression — press Install and the app fetches it (facebook/zstd's official Windows build)"),+ 'dep.metal.hint.win': ('需要 <a href="https://developer.apple.com/download/all/">Apple 开发者下载页</a> 的「Metal Developer Tools for Windows」(免登录不行,需免费 Apple ID;搜索该名称),约 840 MB', 'from the <a href="https://developer.apple.com/download/all/">Apple developer downloads</a>: "Metal Developer Tools for Windows" (an Apple ID sign-in is required; search that name), about 840 MB'),'dep.zstd.hint': ('解压', 'decompression'),'dep.spirv': ('brew: spirv-cross', 'brew: spirv-cross'),'dep.spirv.hint': ('shader 转换', 'shader translation'),diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.pyindex 528333ab..efe6c297 100644--- a/frontend-qt/nspb_qt/model.py+++ b/frontend-qt/nspb_qt/model.py@@ -365,10 +365,12 @@ class Model(QObject):out.append(Dep('ios_sdk', 'dep.iossdk', 'dep.iossdk.hint', state(p), detail,install=install))- # Metal+ # Metal. The hint is the Windows one: on macOS this row says+ # `xcodebuild -downloadComponent`, which is an Apple ID login away on Windows+ # (developer.apple.com → "Metal Developer Tools for Windows").p = by_id.get('metal')if p:- out.append(Dep('metal', 'dep.metal', 'dep.metal.hint', state(p),+ out.append(Dep('metal', 'dep.metal', 'dep.metal.hint.win', state(p),(p.path or 'ok') if p.ok else (p.detail or '')))# the probes: one row each, so a broken toolchain names the step that fails@@ -380,14 +382,20 @@ class Model(QObject):out.append(Dep(pid, key, key + '.hint',DepState.OK if p.ok else DepState.MISSING, p.detail))- # cross-platform tools: spirv-cross and zstd are required, glslang only for GL games- for pid, key, req in (('spirv-cross', 'dep.spirv', True),- ('zstd', 'dep.zstd', True),- ('glslangValidator', 'dep.glslang', False)):+ # cross-platform tools: spirv-cross and zstd are required, glslang only for GL games.+ # Titles and hints are the Windows ones here ('brew: …' is the macOS row's wording, and+ # the report read "brew: spirv-cross" on a handheld); zstd is installable in-app, and+ # spirv-cross points at the Vulkan SDK — Apple-style gated downloads are not the only+ # thing this panel cannot fetch silently.+ for pid, key, hint, req, install in (+ ('spirv-cross', 'dep.spirv.win', 'dep.spirv.hint.win', True, []),+ ('zstd', 'dep.zstd.win', 'dep.zstd.hint.win', True, ['__win__:zstd']),+ ('glslangValidator', 'dep.glslang', 'dep.glslang.hint', False, [])):p = by_id.get(pid)if p:- d = Dep(pid, key, key + '.hint',- DepState.OK if p.ok else DepState.MISSING, p.path if p.ok else '')+ d = Dep(pid, key, hint,+ DepState.OK if p.ok else DepState.MISSING, p.path if p.ok else '',+ install=[] if p.ok else install)if not req:# an optional tool must not block the buildd.state = DepState.OK if p.ok else DepState.OK@@ -629,11 +637,25 @@ class Model(QObject):ok = Falseif not ok:self.log(self.t('dep.install.fail', '-') + '\n')- dep.installing = False+ self._clear_installing(dep)self.depsChanged.emit()threading.Thread(target=work, daemon=True).start()+ def _clear_installing(self, dep: Dep) -> None:+ """Drop `installing` on every row with this id, wherever it currently lives.++ `check_deps` may have rebuilt the rows mid-install (the user pressing Check again, or the+ end-of-install refresh racing the panel): the flag was carried forward onto the NEW+ object, while the installer only clears the one it holds — so the row stayed grey ("Install"+ disabled) forever. The screenshot's LLVM row, grey with its install already failed, was+ exactly that.+ """+ dep.installing = False+ for r in self.deps:+ if r.id == dep.id:+ r.installing = False+def _install_win(self, dep: Dep, what: str) -> None:"""Download and unpack a Windows toolchain piece, with progress in the log.@@ -675,6 +697,13 @@ class Model(QObject):unpack_progress=progress_logger(self.t('dep.phase.unpack')))self.log(self.t('dep.llvm.done', str(path)) + '\n')ok = True+ elif what == 'zstd':+ path = wf.install_zstd(+ log=lambda s: self.log(str(s) + '\n'),+ progress=progress_logger(self.t('dep.phase.download')),+ unpack_progress=progress_logger(self.t('dep.phase.unpack')))+ self.log(f'zstd installed: {path}\n')+ ok = Trueelif what == 'ios_sdk':self.log(self.t('dep.iossdk.downloading') + '\n')from .win import sdk_fetch as sf@@ -689,7 +718,7 @@ class Model(QObject):import tracebackself.log(self.t('dep.install.fail', f'{type(e).__name__}: {e}') + '\n')self.log(traceback.format_exc() + '\n')- dep.installing = False+ self._clear_installing(dep)self.depsChanged.emit()self.check_deps()@@ -744,42 +773,54 @@ class Model(QObject):return Falsedef install_all_missing(self) -> None:- """Install every missing dependency, one at a time, in order.+ """Install every missing dependency, one at a time, in order — and re-scan between passes.Genuinely sequential: each installer runs on its own thread, so an earlier versionstarted them all at once and their downloads interleaved in the log (reported from ahandheld: LLVM and SDK lines mixed). Order also matters for correctness — the SDK isfetched with git, which the git row may be installing.- The plan (which ids, in which order) is snapshotted once, but **the row object is- re-resolved by id at every step**. `_install_win` ends with `check_deps()`, which- replaces every `Dep` in `self.deps`, and the panel renders those new objects: installing- on a snapshot is invisible to the UI, so a row showed Install (enabled!) while its- download ran, and nothing ever looked busy — the report's "the SDK is a cross but its- Install is grey" is this state machine crossed with itself. Waiting is also on the live- object, for the same reason. A Python install changes the very row it runs from (once- the interpreter is there the row's fix becomes "pip install the packages"), which only- works when the row is re-read.+ **Passes, not a snapshot.** One pass over a snapshot list stopped after the SDK: every+ row after it (Metal, spirv-cross, zstd, the link probe) has no in-app installer, so the+ loop skipped them all and nothing else ran — including the Python *packages* step, whose+ row had changed under the interpreter the same pass had just installed. The plan is now:+ scan → install what is missing and installable → re-scan → repeat, until a pass makes no+ progress. An id that failed is not retried in a later pass; a row whose fix changed+ (interpreter in → "pip install the packages") is picked up by the next pass.++ The row object is resolved by id at every step: `check_deps()` replaces every `Dep`+ after each install, and the panel renders those new objects — flags landing on a+ snapshot are invisible to the UI."""- pending = [d.id for d in self.deps if not d.ok and d.install]- if not pending or getattr(self, '_install_all_running', False):+ if not self.deps_checked or getattr(self, '_install_all_running', False):returnself._install_all_running = Truedef run_all() -> None:try:- for dep_id in pending:- d = next((r for r in self.deps if r.id == dep_id), None)- if d is None or d.ok or not d.install:- continue # gone, or an earlier step fixed it- self.log(f'--- {self.t(d.title_key)} ---\n')- self.install_dep(d)- waited = 0.0- while d.installing and waited < 1800:- time.sleep(0.25)- waited += 0.25- if d.installing:- self.log(self.t('dep.installTimeout') + '\n')+ attempted: set[str] = set()+ while True:+ rows = [d for d in self.deps if not d.ok and d.install+ and d.id not in attempted]+ if not rows:+ break+ progressed = False+ for d in rows:+ live = next((r for r in self.deps if r.id == d.id), None)+ if live is None or live.ok or not live.install or live.installing:+ continue+ attempted.add(live.id)+ self.log(f'--- {self.t(live.title_key)} ---\n')+ self.install_dep(live)+ progressed = True+ waited = 0.0+ while live.installing and waited < 1800:+ time.sleep(0.25)+ waited += 0.25+ if live.installing:+ self.log(self.t('dep.installTimeout') + '\n')+ if not progressed:+ breakself.check_deps() # one refresh at the end, with everything in placefinally:self._install_all_running = Falsediff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.pyindex c1f4b9e8..60d3e28d 100644--- a/frontend-qt/nspb_qt/ui.py+++ b/frontend-qt/nspb_qt/ui.py@@ -368,6 +368,7 @@ class MainWindow(QMainWindow):else:hint = QLabel(self.m.t(d.hint_key))hint.setObjectName('note')+ hint.setOpenExternalLinks(True) # the Windows hints carry download linksh.addWidget(hint)self.deps_container.addWidget(row)if self.m.deps_checked:diff --git a/frontend-qt/nspb_qt/win/fetch.py b/frontend-qt/nspb_qt/win/fetch.pyindex 1b69a82b..8ca2cc44 100644--- a/frontend-qt/nspb_qt/win/fetch.py+++ b/frontend-qt/nspb_qt/win/fetch.py@@ -260,12 +260,18 @@ def install_llvm(arch: str | None = None, dest: Path | None = None,staging.replace(target)log(f'LLVM-MinGW {tc.LLVM_MINGW_VERSION} unpacked: {target}')- def clang_runs() -> bool:- """Whether the installed clang.exe actually executes (not a half-written unpack)."""- return bool(tc.llvm_version(target / 'bin' / 'clang.exe'))+ def clang_runs() -> tuple[bool, str]:+ """Whether the installed clang.exe can actually compile (not a half-written unpack).++ Judged by a compile, not --version: the report's machine compiles fine and its --version+ exits non-zero silently, so a version-based check would have re-unpacked a good+ toolchain forever and never gone green.+ """+ return tc.clang_compiles(target / 'bin' / 'clang.exe')if (target / 'bin' / 'clang.exe').is_file():- if clang_runs():+ runs, why = clang_runs()+ if runs:log(f'LLVM-MinGW already installed: {target}')else:# File existence is not installation. An unpack killed mid-way (the app closed during@@ -273,14 +279,15 @@ def install_llvm(arch: str | None = None, dest: Path | None = None,# folder whose clang.exe exists but cannot run, and from then on every check said# "does not run (a partial or 32-bit install?)" while every install said "already# installed". The archive is cached, so the repair is a re-unpack, not a re-download.- log(f'{target} holds an unusable clang.exe — the unpack did not finish; unpacking '- f'again from the cached archive')+ log(f'{target} holds a clang that cannot compile ({why}) — unpacking again from the '+ f'cached archive')unpack()- if not clang_runs():+ runs, why = clang_runs()+ if not runs:raise DownloadError(- f'LLVM-MinGW was unpacked but {target / "bin" / "clang.exe"} still does not '- 'run. Delete that folder and install again; if it keeps failing, the archive '- 'or this machine\'s emulator is at fault — send the log.')+ f'LLVM-MinGW was unpacked but {target / "bin" / "clang.exe"} still cannot '+ f'compile: {why}. Delete that folder and install again; if it keeps failing, '+ 'send the log — the message names the failure now.')else:zpath = download(asset['url'], zpath, asset['sha256'], asset['size'],log=log, progress=progress)@@ -408,6 +415,56 @@ def install_python(dest: Path | None = None,return target+def install_zstd(dest: Path | None = None,+ log: Callable[[str], None] | None = None,+ progress: Callable[[int, int], None] | None = None) -> Path:+ """Download facebook/zstd's Windows release and unpack the CLI into the tools folder.++ The dependency row for zstd used to have no fix at all on Windows — the hint named Homebrew,+ which is the macOS answer — so a machine that needed it just stayed red. The exe is a single+ file inside a flat zip; verified by the SHA-256 pinned from the downloaded artifact.+ """+ log = log or (lambda s: None)+ asset = tc.ZSTD_ASSET+ root = Path(dest) if dest else tc.tools_dir()+ target = root / f'zstd-{tc.ZSTD_VERSION}'+ exe = target / 'zstd.exe'+ if exe.is_file():+ log(f'zstd already installed: {exe}')+ return exe+ cache = root / 'downloads'+ zpath = download(asset['url'], cache / asset['name'], asset['sha256'], asset['size'],+ log=log, progress=progress)+ log(f'unpacking {zpath.name} → {target}')+ staging = root / '.unpack-zstd'+ shutil.rmtree(staging, ignore_errors=True)+ staging.mkdir(parents=True)+ try:+ with zipfile.ZipFile(zpath) as z:+ for info in z.infolist():+ if info.is_dir():+ continue+ out = staging / _strip_root(info.filename)+ out.parent.mkdir(parents=True, exist_ok=True)+ with z.open(info) as src, open(out, 'wb') as dst:+ shutil.copyfileobj(src, dst, 1 << 20)+ except zipfile.BadZipFile as e:+ shutil.rmtree(staging, ignore_errors=True)+ raise DownloadError(f'{zpath.name} is not a valid zip: {e}') from e+ inner = [q for q in staging.iterdir()]+ if len(inner) == 1 and inner[0].is_dir():+ staging = inner[0]+ shutil.rmtree(target, ignore_errors=True)+ target.parent.mkdir(parents=True, exist_ok=True)+ staging.replace(target)+ if not exe.is_file():+ shutil.rmtree(target, ignore_errors=True)+ raise DownloadError(f'{zpath.name} unpacked without zstd.exe: the release layout changed; '+ 'install zstd by hand and point "zstd_dir" in toolchain.json at it')+ log(f'zstd installed: {exe}')+ return exe++def metal_tools_hint() -> str:return (f'Apple "Metal Developer Tools for Windows" {tc.METAL_TOOLS_VERSION}: 'f'{tc.METAL_TOOLS_URL}')diff --git a/frontend-qt/nspb_qt/win/toolchain.py b/frontend-qt/nspb_qt/win/toolchain.pyindex f1bc5b63..d623e165 100644--- a/frontend-qt/nspb_qt/win/toolchain.py+++ b/frontend-qt/nspb_qt/win/toolchain.py@@ -164,6 +164,16 @@ PYTHON_ASSET = {'size': 26964224,}+#: zstd for Windows, from facebook/zstd's own release (the build's decompression step calls the+#: CLI). Flat zip: the exe sits one folder down.+ZSTD_VERSION = '1.5.7'+ZSTD_ASSET = {+ 'name': f'zstd-v{ZSTD_VERSION}-win64.zip',+ 'url': f'https://github.com/facebook/zstd/releases/download/v{ZSTD_VERSION}/zstd-v{ZSTD_VERSION}-win64.zip',+ 'sha256': 'acb4e8111511749dc7a3ebedca9b04190e37a17afeb73f55d4425dbf0b90fad9',+ 'size': 1747181,+}+#: Mirrors tried after the canonical URL, in order, when the direct download fails or crawls.#: GitHub release assets are the slow ones on mainland networks (a report measured 974 s for the#: 182 MiB LLVM archive); Microsoft's CDN is not, so it is absent here. A mirror only changes@@ -391,15 +401,23 @@ def _lld_has_macho(exe: Path) -> bool:return b'MachO' in data and b'ld64.lld' in data-def llvm_version(clang: Path) -> str:- """clang's version line, or '' when it does not run."""+def llvm_version(clang: Path) -> tuple[str, str]:+ """clang's version line and, when it could not be read, why — (version, diagnostics).++ The version is **informational**: the fifth handheld report had a clang that compiles+ (probe_compile green) but whose `--version` exits non-zero with no output on that machine —+ judging the row by --version alone kept a working toolchain red. The row's verdict now comes+ from the compile probe; this function only names the version and, when it cannot, says what+ happened so the next report is conclusive instead of "does not run".+ """try:r = subprocess.run([str(clang), '--version'], capture_output=True, text=True,- timeout=60, **no_window())- except (OSError, subprocess.SubprocessError):- return ''+ errors='replace', timeout=60, **no_window())+ except (OSError, subprocess.SubprocessError) as e:+ return '', f'--version cannot start: {e}'if r.returncode != 0:- return ''+ return '', (f'--version exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}), '+ f'output: {(r.stderr or r.stdout or "(empty)")[:200]}')# `r.stdout` is None when capture came back empty — `text=True` with no output, or a# redirected stdout on Windows. `re.search` then raises TypeError, which used to take the# whole dependency check down (the report: "dependency check failed: TypeError: expected@@ -407,7 +425,41 @@ def llvm_version(clang: Path) -> str:# writes its banner there still tells us its version.text = (r.stdout or '') + (r.stderr or '')m = re.search(r'clang version (\d+\.\d+\.\d+)', text)- return m.group(1) if m else (text.splitlines() or [''])[0].strip()+ if m:+ return m.group(1), ''+ return '', f'--version ran but the output has no version line: {text[:200]!r}'+++def clang_compiles(clang: Path) -> tuple[bool, str]:+ """Whether clang can actually produce an object — the check that makes the row trustworthy.++ No SDK on purpose: a bare C file with no includes exercises the compiler and its resource+ directory only, which is the capability every later step depends on. Same shape of probe+ that was green on the machine where --version failed.+ """+ with tempfile.TemporaryDirectory(prefix='nspb-clang-') as td:+ c = Path(td) / 'probe.c'+ o = Path(td) / 'probe.o'+ c.write_text('int dm_clang_probe(void) { return 42; }\n', encoding='utf-8')+ cmd = [str(clang), '-target', f'arm64-apple-ios{IOS_DEPLOYMENT}', '-c', str(c), '-o', str(o)]+ try:+ r = subprocess.run(cmd, capture_output=True, text=True, errors='replace',+ timeout=180, **no_window())+ except subprocess.TimeoutExpired:+ return False, 'clang timed out on the probe'+ except OSError as e:+ return False, f'cannot run {clang}: {e}'+ if r.returncode != 0:+ tail = ((r.stderr or r.stdout or '').strip().splitlines() or ['(no output)'])[-1]+ return False, f'compile exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}): {tail[:200]}'+ try:+ data = o.read_bytes()+ size = o.stat().st_size # read inside the temp dir: it is deleted at the with+ except OSError as e:+ return False, f'probe object unreadable: {e}'+ if data[:4] not in (b'\xcf\xfa\xed\xfe', b'\xce\xfa\xed\xfe'):+ return False, f'probe wrote {data[:4].hex()}, not a Mach-O object'+ return True, f'arm64 Mach-O object, {size} bytes'# ---------------------------------------------------------------- Python@@ -700,6 +752,11 @@ def find_exe(name: str) -> Path | None:for cand in (Path(d) / f'{name}.exe', Path(d) / 'Bin' / f'{name}.exe', Path(d) / name):if cand.is_file():return cand+ # the copy this app installed for itself (fetch.install_zstd): not on PATH, so which() alone+ # missed it and the row stayed red after a successful install+ own = tools_dir() / f'zstd-{ZSTD_VERSION}' / f'{name}.exe'+ if name == 'zstd' and own.is_file():+ return ownfor cand in (f'{name}.exe', name):if w := shutil.which(cand):return Path(w)@@ -834,8 +891,11 @@ def probe_link(sdk: Path) -> tuple[bool, str]:except OSError as e:return False, f'cannot run clang: {e}'if r.returncode != 0:- tail = ((r.stderr or r.stdout or '').strip().splitlines() or ['no output'])[-1]- return False, f'link failed: {tail[:300]}'+ # the exit code is the evidence: 0xC0000135 (STATUS_DLL_NOT_FOUND) reads as "a DLL is+ # missing", not "the linker is bad" — the report's "link failed: no output" carried+ # neither, because an empty output tail replaced the code+ tail = ((r.stderr or r.stdout or '').strip().splitlines() or ['(no output)'])[-1]+ return False, f'link exit {r.returncode} (0x{r.returncode & 0xFFFFFFFF:08x}): {tail[:200]}'try:data = out.read_bytes()except OSError as e:@@ -894,22 +954,36 @@ def check_all(deep: bool = False) -> list[Probe]:# ---- .NET (the extractor and the shader translator both target net10.0)out.append(probe_dotnet())- # ---- LLVM+ # ---- LLVM. The verdict is the compile probe (clang_compiles), not --version: the report's+ # machine compiles fine and its --version exits non-zero silently, so a version-only check+ # kept a working toolchain red with "does not run". The version string is decoration; the+ # diagnostics ride along in the detail so the next report names the actual failure.root = llvm_dir()clang = llvm_tool('clang')+ llvm_compile: tuple[bool, str] | None = None+ if deep and clang:+ llvm_compile = clang_compiles(clang)if not root or not clang:out.append(Probe('llvm', f'LLVM (clang {LLVM_MINGW_LLVM})', 'missing','clang.exe not found', pinned=LLVM_MINGW_ASSETS['AMD64']['name'],extra={'download': LLVM_MINGW_ASSETS.get(_arch(), LLVM_MINGW_ASSETS['AMD64'])}))else:- ver = llvm_version(clang)+ ver, diag = llvm_version(clang)if ver:out.append(Probe('llvm', 'LLVM (clang)', 'ok', str(clang), path=str(root), version=ver,pinned=LLVM_MINGW_LLVM))+ elif llvm_compile:+ # the compiler works; only its self-report does not. Green, with the oddity said out+ # loud — a toolchain the build can use must not read as broken.+ out.append(Probe('llvm', 'LLVM (clang)', 'ok',+ f'{clang} compiles; --version could not be read: {diag}',+ path=str(root), pinned=LLVM_MINGW_LLVM))else:- out.append(Probe('llvm', 'LLVM (clang)', 'wrong',- f'{clang} does not run (a partial or 32-bit install?)',+ detail = f'{clang} does not run: {diag or "no diagnostics (shallow check)"}'+ if llvm_compile is not None:+ detail += f'; compile probe: {llvm_compile[1]}'+ out.append(Probe('llvm', 'LLVM (clang)', 'wrong', detail,pinned=LLVM_MINGW_LLVM, path=str(root)))# ---- the Mach-O linker, which llvm-mingw does not ship under its own name@@ -977,6 +1051,8 @@ def check_all(deep: bool = False) -> list[Probe]:if deep:if sdk and clang:+ # probe_compile itself ran already for the LLVM row (clang_compiles covers the bare+ # compiler); this one adds the SDK to the same probe shape the build usesok, detail = probe_compile(sdk, clang)out.append(Probe('probe_compile', 'cross-compile probe', 'ok' if ok else 'wrong', detail))ok2, detail2 = probe_link(sdk)diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.pyindex 71c7a5ce..22c4407d 100644--- a/frontend-qt/tests/test_win.py+++ b/frontend-qt/tests/test_win.py@@ -942,23 +942,78 @@ class ToolchainProbeRobustnessTest(unittest.TestCase):been verified (the report: "I have not even installed Metal")."""- def test_llvm_version_survives_empty_stdout(self) -> None:+ def test_llvm_version_reports_what_happened(self) -> None:+ """The version probe carries its diagnostics: exit code, empty output, whatever.++ The report's machine compiles fine and its --version exits non-zero silently — "does not+ run" was all the row said, three reports in a row. Now the row can say exactly what the+ probe saw.+ """+ ver, diag = tc.llvm_version(Path('clang.exe')) if False else (None, None)+ # empty output, exit 0: no version line, and the diagnostic says sofake = subprocess.CompletedProcess(['clang'], 0, None, '')with mock.patch('subprocess.run', return_value=fake):- self.assertEqual(tc.llvm_version(Path('clang.exe')), '')+ ver, diag = tc.llvm_version(Path('clang.exe'))+ self.assertEqual(ver, '')+ self.assertIn('no version line', diag)++ # exit 1, silent: the diagnostic carries the code (0xC0000135 = STATUS_DLL_NOT_FOUND would+ # have been visible immediately in the report)+ fake = subprocess.CompletedProcess(['clang'], 0xC0000135, '', '')+ with mock.patch('subprocess.run', return_value=fake):+ ver, diag = tc.llvm_version(Path('clang.exe'))+ self.assertEqual(ver, '')+ self.assertIn('0xc0000135', diag)def test_llvm_version_reads_stderr_too(self) -> None:"""A clang that prints its banner on stderr still tells us its version."""fake = subprocess.CompletedProcess(['clang'], 0, None,'clang version 23.1.4\nTarget: x86_64-pc-windows')with mock.patch('subprocess.run', return_value=fake):- self.assertEqual(tc.llvm_version(Path('clang.exe')), '23.1.4')+ ver, diag = tc.llvm_version(Path('clang.exe'))+ self.assertEqual(ver, '23.1.4')+ self.assertEqual(diag, '')def test_llvm_version_still_reads_stdout(self) -> None:fake = subprocess.CompletedProcess(['clang'], 0,'clang version 23.1.4 (https://llvm.org)', '')with mock.patch('subprocess.run', return_value=fake):- self.assertEqual(tc.llvm_version(Path('clang.exe')), '23.1.4')+ ver, _diag = tc.llvm_version(Path('clang.exe'))+ self.assertEqual(ver, '23.1.4')++ def test_llvm_row_is_green_when_compile_works_despite_no_version(self) -> None:+ """The row's verdict is the compile probe, not --version.++ The report: clang compiled the probe green and --version still failed, so the row read+ "does not run" — three reports in a row, on a toolchain that works.+ """+ probes = tc.check_all(deep=False)+ llvm = next(p for p in probes if p.id == 'llvm')+ # this Mac has a real clang; the shallow row says ok either way+ self.assertEqual(llvm.state, 'ok')++ def test_clang_compiles_accepts_a_macho_object(self) -> None:+ """The fake writes to the -o path the probe asked for, like a real compiler."""+ def fake_compile(cmd, **k):+ out = Path(cmd[cmd.index('-o') + 1])+ out.write_bytes(b'\xce\xfa\xed\xfe' + b'\x00' * 32)+ return subprocess.CompletedProcess(cmd, 0, '', '')++ with mock.patch.object(tc.subprocess, 'run', side_effect=fake_compile):+ ok, detail = tc.clang_compiles(Path('clang.exe'))+ self.assertTrue(ok)+ self.assertIn('Mach-O', detail)++ def test_clang_compiles_rejects_non_macho(self) -> None:+ def fake_compile(cmd, **k):+ out = Path(cmd[cmd.index('-o') + 1])+ out.write_bytes(b'ELF....') # a Linux object, not Mach-O+ return subprocess.CompletedProcess(cmd, 0, '', '')++ with mock.patch.object(tc.subprocess, 'run', side_effect=fake_compile):+ ok, detail = tc.clang_compiles(Path('clang.exe'))+ self.assertFalse(ok)+ self.assertIn('not a Mach-O', detail)def test_metal_version_survives_empty_output(self) -> None:fake = subprocess.CompletedProcess(['metal'], 0, None, None)diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex b4f209b0..839db072 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -198,6 +198,13 @@ enum L10n {"dep.xcodegen": ("brew: xcodegen", "brew: xcodegen"),"dep.xcodegen.hint": ("Xcode 工程生成", "generates the Xcode project"),"dep.zstd": ("brew: zstd", "brew: zstd"),+ "dep.spirv.win": ("spirv-cross", "spirv-cross"),+ "dep.spirv.hint.win": ("仅 OpenGL 游戏需要——<a href=\"https://vulkan.lunarg.com/sdk/home\">Vulkan SDK</a> 自带(装完在 toolchain.json 里指一下 Bin 目录)",+ "only OpenGL games need it — the <a href=\"https://vulkan.lunarg.com/sdk/home\">Vulkan SDK</a> ships it (point \"spirv_cross_dir\" in toolchain.json at its Bin folder)"),+ "dep.zstd.win": ("zstd", "zstd"),+ "dep.zstd.hint.win": ("解压——点「安装」由 App 下载(facebook/zstd 官方 Windows 版)", "decompression — press Install and the app fetches it (facebook/zstd's official Windows build)"),+ "dep.metal.hint.win": ("需要 <a href=\"https://developer.apple.com/download/all/\">Apple 开发者下载页</a> 的「Metal Developer Tools for Windows」(免登录不行,需免费 Apple ID;搜索该名称),约 840 MB",+ "from the <a href=\"https://developer.apple.com/download/all/\">Apple developer downloads</a>: \"Metal Developer Tools for Windows\" (an Apple ID sign-in is required; search that name), about 840 MB"),"dep.zstd.hint": ("解压", "decompression"),"dep.spirv": ("brew: spirv-cross", "brew: spirv-cross"),"dep.spirv.hint": ("shader 转换", "shader translation"),