Skip to content

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

Windows: bundle the engine tree in the Qt build, so a player needs no git or repo

LNPANDYc0b6cdebf6dc
diff --git a/.github/workflows/build-qt.yml b/.github/workflows/build-qt.yml
index 2cd44b42..91fbb55d 100644
--- a/.github/workflows/build-qt.yml
+++ b/.github/workflows/build-qt.yml
@@ -44,6 +44,16 @@ jobs:
- name: Download the venv wheels
run: "python -m pip download --only-binary=:all: lz4==4.4.5 capstone==5.0.9 fonttools==4.68.0 zbic==1.0.1.post1 backports.zstd==1.8.0 nsz==5.0.0 -d frontend-qt/wheels"
+ - name: Build the engine tree
+ shell: bash
+ run: |
+ # The engine tree (upstream at the pin plus the patch series) goes into the zip beside
+ # the app, so a Windows player needs no git, no repository download and no sync. The
+ # Mac release does the same (build-mac-app.yml, the engine tree step).
+ python tools/engine.py -q sync
+ python tools/engine.py tree --out engine-tree
+ du -sh engine-tree
+
- name: Build
working-directory: frontend-qt
shell: bash
@@ -137,6 +147,9 @@ jobs:
run: |
cd frontend-qt/dist
cp -r ../wheels "NS Port Builder/wheels"
+ # The engine tree goes beside the app folder: the launcher finds it at
+ # <exe_dir>/../engine and skips the repo/sync route entirely.
+ cp -r ../../engine-tree "NS Port Builder/engine"
powershell -Command "Compress-Archive -Path 'NS Port Builder' -DestinationPath '../NS-Port-Builder-qt-windows-x64.zip'"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
diff --git a/frontend-qt/nspb_qt/engine.py b/frontend-qt/nspb_qt/engine.py
index 89ef6814..5ecc9982 100644
--- a/frontend-qt/nspb_qt/engine.py
+++ b/frontend-qt/nspb_qt/engine.py
@@ -18,6 +18,7 @@ from __future__ import annotations
import hashlib
import subprocess
+import sys
from pathlib import Path
from typing import Callable
@@ -74,6 +75,8 @@ def _head(eng: Path) -> str:
def is_stale(repo: str) -> bool:
"""True when the checkout can make engine/ and engine/ is missing or not built from the current pin and series."""
+ if bundled_engine():
+ return False # a bundled engine never needs a sync
if not has_engine_tool(repo):
return False
eng = Path(repo, 'engine')
@@ -84,8 +87,24 @@ def is_stale(repo: str) -> bool:
return True
+def bundled_engine() -> str:
+ """The engine tree the Actions zip puts beside the app folder (`<exe_dir>/../engine/`).
+ None when it is not there or does not look like an engine tree."""
+ if not getattr(sys, 'frozen', False):
+ return '' # a PyInstaller bundle sets sys.frozen; a python -m run never does
+ exe = Path(sys.executable).resolve()
+ for base in (exe.parent, exe.parent.parent):
+ cand = base / 'engine'
+ if cand.joinpath('dm', 'games').is_dir() and cand.joinpath('scripts', 'build_ipa_from_nsp.py').is_file():
+ return str(cand)
+ return ''
+
+
def engine_root(repo: str) -> str:
"""The folder holding dm/ and scripts/ for this checkout (see the module's rule)."""
+ bundled = bundled_engine()
+ if bundled:
+ return bundled
if not repo:
return repo
eng = Path(repo, 'engine')
@@ -97,8 +116,8 @@ def engine_root(repo: str) -> str:
def is_checkout(d: str) -> bool:
- """A folder the launcher can build from: a checkout with tools/engine.py to make engine/, a synced engine/, or an engine tree."""
- return bool(d) and (Path(d, *MARKER).is_file() or Path(d, 'engine', *MARKER).is_file() or has_engine_tool(d))
+ """A folder the launcher can build from: a checkout with tools/engine.py to make engine/, a synced engine/, an engine tree, or a bundled engine beside the app."""
+ return bool(bundled_engine()) or (bool(d) and (Path(d, *MARKER).is_file() or Path(d, 'engine', *MARKER).is_file() or has_engine_tool(d)))
def needs_sync_before_build(repo: str) -> bool: