Skip to content

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

2.6 KB
Raw Blame
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: seedds <[email protected]>
Date: Fri, 30 Oct 2026 16:14:10 +0800
Subject: [PATCH] NSP script: verify DOTNET_ROOT by running the shader
 translator

Upstream-Status: pending
Reason: configure_dotnet takes the first listed root without checking that the shader translator runs with it; the build stops at the iOS shader step with an empty fingerprint (fork commit d0ed53df). Not sent to seedds/nxnative yet
Issue: LNPANDY/NX2Apple#123
---
 scripts/build_ipa_from_nsp.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.py
index 771182e..6923691 100755
--- a/scripts/build_ipa_from_nsp.py
+++ b/scripts/build_ipa_from_nsp.py
@@ -2971,6 +2971,29 @@ def main(args=None):
     env.setdefault('DOTNET_CLI_TELEMETRY_OPTOUT', '1')
     env.setdefault('DOTNET_NOLOGO', '1')
     configure_dotnet(env)
+    xlate_bin = repo / 'dm/gfx/tools/dmsh_xlate_bin/dmsh_xlate'   # the fork's check of the root configure_dotnet chose (fork commit d0ed53df; the fork patch nsp-dotnet-root-verify)
+    def xlate_answers(root):
+        e = dict(env)
+        if root: e['DOTNET_ROOT'] = str(root)
+        else: e.pop('DOTNET_ROOT', None)
+        try:
+            r = subprocess.run([str(xlate_bin), '--source-sha'], capture_output=True, text=True, env=e, timeout=120)
+            return r.returncode == 0 and bool(r.stdout.strip())
+        except Exception:
+            return False
+    if xlate_bin.exists() and not xlate_answers(env.get('DOTNET_ROOT')):
+        cands = []
+        if dn := shutil.which('dotnet', path=env['PATH']):
+            real = Path(dn).resolve()
+            for base in (real.parent.parent, real.parent.parent.parent):
+                cands += [base / 'libexec', base]   # Homebrew's bin/../libexec; share/dotnet and aliases
+        cands += [Path.home() / '.dotnet', Path('/usr/local/share/dotnet'), Path('/opt/homebrew/opt/dotnet/libexec')]
+        if hit := next((c for c in cands if c.is_dir() and xlate_answers(c)), None):
+            env['DOTNET_ROOT'] = os.environ['DOTNET_ROOT'] = str(hit)
+            say(f'DOTNET_ROOT: {hit} (verified — the shader translator runs)')
+        elif env.get('DOTNET_ROOT'):
+            del env['DOTNET_ROOT']; os.environ.pop('DOTNET_ROOT', None)
+            say('DOTNET_ROOT: removed (none verified — the apphost searches its default locations)')
     env.setdefault('J', str(os.cpu_count() or 8))   # shader_split.py's and dmsh_build.py's workers (their default is 8)
     py = sys.executable
     want = args.title_id or TITLE_ID