Skip to content

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

CI and release app: run on engine/, carry the pinned engine in the app

v0lumehi2168094ee05c
diff --git a/.github/ISSUE_TEMPLATE/build_problem.yml b/.github/ISSUE_TEMPLATE/build_problem.yml
index 5a8814a4..56f38833 100644
--- a/.github/ISSUE_TEMPLATE/build_problem.yml
+++ b/.github/ISSUE_TEMPLATE/build_problem.yml
@@ -92,7 +92,7 @@ body:
id: fork-patches
attributes:
label: Fork patches line
- description: "The patches your build carries beyond upstream's engine: the first line of the game app's log (`fork patches: ...`), or the contents of `dm/fork_patches.txt` in the NX2Apple folder you built from. Optional."
+ description: "The patches your build carries beyond upstream's engine: the first line of the game app's log (`fork patches: ...`), or the contents of `engine/dm/fork_patches.txt` (`dm/fork_patches.txt` in an older copy) in the NX2Apple folder you built from. Optional."
placeholder: "fork patches: runtime-profile, ios-game-data-folder, ..."
validations:
required: false
diff --git a/.github/workflows/build-mac-app.yml b/.github/workflows/build-mac-app.yml
index 042c3e0f..4eb171cd 100644
--- a/.github/workflows/build-mac-app.yml
+++ b/.github/workflows/build-mac-app.yml
@@ -8,7 +8,7 @@
# "up to date" — a silent failure of the update path for every existing install. Copies from before
# the app was renamed (NS Port Builder) look for NS-Port-Builder-macOS-arm64.zip, so that one goes up too.
#
-# The app also carries its build tools (zstd, glslangValidator, spirv-cross, xcodegen) and a Python with the packages the build scripts import,
+# The app also carries the pinned engine as a seed for `tools/engine.py sync` (Resources/engine.git, issue #214), and its build tools (zstd, glslangValidator, spirv-cross, xcodegen) and a Python with the packages the build scripts import,
# so a player installs neither Homebrew nor Python (frontend/tools/bundle_tools.sh builds them from pinned, checksummed sources; check_bundle.sh
# runs each from the assembled bundle with a clean PATH, checks the load paths and the signature).
#
@@ -21,7 +21,7 @@ on:
push:
tags: ['v*']
pull_request:
- paths: ['frontend/**', '.github/workflows/build-mac-app.yml']
+ paths: ['frontend/**', 'tools/engine.py', '.github/workflows/build-mac-app.yml']
workflow_dispatch:
permissions:
@@ -73,6 +73,18 @@ jobs:
# The build tools and the Python go into Resources before the bundle is signed (bundle_tools.sh signs each nested Mach-O file
# itself: --deep below does not reach code that sits in Resources).
tools/bundle_tools.sh "$APP/Contents/Resources" "$RUNNER_TEMP/bundle-tools-work"
+ # The engine (issue #214): the pinned seedds/nxnative commit as a bare one-commit repository, about 80 MB. The launcher passes
+ # it to `tools/engine.py sync --seed`, so the player's checkout builds engine/ without a download while its pin is this one,
+ # and fetches only what changed once the pin moved. The patches come from the checkout, so they always match its pin.
+ python3 ../tools/engine.py sync
+ SEED="$APP/Contents/Resources/engine.git"
+ PIN=$(cat ../.upstream-ref)
+ git init -q --bare "$SEED"
+ git -C "$SEED" fetch -q --no-tags --depth 1 "file://$PWD/../engine" "$PIN"
+ git -C "$SEED" update-ref refs/heads/main "$PIN"
+ git -C "$SEED" symbolic-ref HEAD refs/heads/main
+ rm -rf "$SEED/hooks"
+ du -sh "$SEED"
V="${{ steps.ver.outputs.version }}"
cat > "$APP/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
diff --git a/.github/workflows/daily-health.yml b/.github/workflows/daily-health.yml
index 03496009..e050e0d5 100644
--- a/.github/workflows/daily-health.yml
+++ b/.github/workflows/daily-health.yml
@@ -54,24 +54,26 @@ jobs:
fi
echo
- echo "=== patch queue (check: the series reproduces the vendored tree) ==="
- python3 scripts/patches.py check 2>&1 | tail -40
+ echo "=== patch queue (check: the series applies to the pin and reproduces the committed vendored tree) ==="
+ python3 tools/engine.py check --tree 2>&1 | tail -40
CHECK_RC=${PIPESTATUS[0]}
echo
echo "=== patch queue (dry bump to seedds/main: which patches would conflict) ==="
- python3 scripts/patches.py bump --dry --to "$NEW" 2>&1 | tail -80 || true
- [ "$CHECK_RC" -eq 0 ] || echo "PROBLEM: patches.py check failed"
+ python3 tools/engine.py bump --dry --to "$NEW" 2>&1 | tail -80 || true
+ [ "$CHECK_RC" -eq 0 ] || echo "PROBLEM: engine.py check failed"
[ "$CHECK_RC" -eq 0 ] # the group's status: a failed check fails the step (the dry bump only reports)
} 2>&1 | tee check.log
- name: Host build and unit tests
run: |
set -o pipefail
- GAME=$(ls dm/games | grep '^0100' | head -1)
+ echo "=== engine (tools/engine.py sync, issue #214) ===" | tee -a check.log
+ python3 tools/engine.py sync 2>&1 | tail -5 | tee -a check.log
+ GAME=$(ls engine/dm/games | grep '^0100' | head -1)
echo "=== host build ($GAME) ===" | tee -a check.log
- make -C dm/host GAME=$GAME dmhost -j4 2>&1 | tail -20 | tee -a check.log
+ make -C engine/dm/host GAME=$GAME dmhost -j4 2>&1 | tail -20 | tee -a check.log
echo "=== host unit tests ===" | tee -a check.log
- make -C dm/host/tests GAME=$GAME run -j4 2>&1 | tail -30 | tee -a check.log
+ make -C engine/dm/host/tests GAME=$GAME run -j4 2>&1 | tail -30 | tee -a check.log
- name: Report a problem
if: failure()
diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml
index 9b9ae3c7..1d24efaf 100644
--- a/.github/workflows/issue-triage.yml
+++ b/.github/workflows/issue-triage.yml
@@ -58,7 +58,11 @@ jobs:
id: prepare
env:
GH_TOKEN: ${{ github.token }}
- run: python3 -I .github/scripts/triage_prepare.py --repo "$GITHUB_REPOSITORY" --issue "$ISSUE" --out "$RUNNER_TEMP/triage"
+ # The symptom index comes from engine/ (tools/engine.py sync, issue #214), or from the committed docs/ while the repository has them
+ run: |
+ python3 -I tools/engine.py sync || true
+ docs=docs; [ -f engine/docs/agents/symptoms.md ] && docs=engine/docs
+ python3 -I .github/scripts/triage_prepare.py --repo "$GITHUB_REPOSITORY" --issue "$ISSUE" --out "$RUNNER_TEMP/triage" --docs "$docs"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: steps.prepare.outputs.skip == 'false'
with:
diff --git a/.github/workflows/pr-scope.yml b/.github/workflows/pr-scope.yml
index b794f54c..ccada58e 100644
--- a/.github/workflows/pr-scope.yml
+++ b/.github/workflows/pr-scope.yml
@@ -1,17 +1,18 @@
-# Guard the patch queue: fail a PR that edits a vendored file without a patch.
+# Guard the patch queue: fail a PR whose patches do not apply to the pin, or that edits a committed vendored file without a patch.
#
-# dm/, scripts/, docs/, ref/ and AGENTS.md are upstream (seedds/nxnative, pinned in .upstream-ref) plus the patches in
-# patches/. A PR that edits one of those files directly would be reverted by the next bump, so `scripts/patches.py check`
-# (the series applied to the pin must give the committed tree) fails it. What a PR author sees: the files that differ, and the
-# way out (commit the change, `scripts/patches.py export <commit>`, fill in the header; patches/README.md).
-# A sync PR (branch sync/upstream-*) is checked too, on purpose: it must reproduce its own tree. The old per-file guard
-# and its skip for sync branches are gone with the anchor patchers.
-# The same check is a job in tests.yml; this one starts on the vendored paths only, and says so in its own name.
+# The engine is seedds/nxnative at the commit in .upstream-ref plus the patches in patches/. Since issue #214 it is built into engine/
+# by `tools/engine.py sync`, and engine work is a commit in engine/ that `tools/engine.py export` turns into a patch. While the
+# repository still commits the same tree in dm/, scripts/, docs/, ref/ and AGENTS.md (step 1 of #214), a PR that edits one of those
+# files directly would be reverted by the next bump, so `tools/engine.py check --tree` also compares that tree with pin + series. What a
+# PR author sees: the files that differ, and the way out (patches/README.md). In step 2 the committed tree goes, and this guard keeps
+# only the first half: the series applies cleanly to the pin.
+# A sync PR (branch sync/upstream-*) is checked too, on purpose: it must reproduce its own tree.
+# The same check is a job in tests.yml; this one starts on the engine's paths only, and says so in its own name.
name: PR scope (sync safety)
on:
pull_request:
- paths: ['dm/**', 'scripts/**', 'docs/**', 'ref/**', 'AGENTS.md', 'patches/**', '.upstream-ref']
+ paths: ['dm/**', 'scripts/**', 'docs/**', 'ref/**', 'AGENTS.md', 'patches/**', '.upstream-ref', 'tools/**']
permissions:
contents: read
@@ -22,15 +23,10 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- fetch-depth: 0
persist-credentials: false
- - name: Fetch the pinned upstream commit
+ - name: The series applies to the pin, and the committed tree is pin + series
run: |
- git remote add seedds https://github.com/seedds/nxnative.git
- git fetch --no-tags seedds "$(cat .upstream-ref)"
- - name: The series reproduces the vendored tree
- run: |
- python3 scripts/patches.py check || {
- echo "::error title=Patch queue::Patch queue out of sync: vendored files differ from pin + patches. Fix: python3 scripts/patches.py absorb <the files listed above> (a new file may need --into <patch>), then commit patches/. See patches/README.md."
+ python3 tools/engine.py check --tree || {
+ echo "::error title=Patch queue::The series does not apply to the pin, or a committed vendored file differs from pin + patches. Fix: work in engine/ (python3 tools/engine.py sync), commit there, then python3 tools/engine.py export. A direct edit of a committed file folds in with python3 tools/patches.py absorb <files>. See patches/README.md."
exit 1
}
diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml
index 8dd643ee..f73a9ce3 100644
--- a/.github/workflows/sync-upstream.yml
+++ b/.github/workflows/sync-upstream.yml
@@ -1,7 +1,10 @@
# Daily: follow upstream seedds/nxnative as a patch queue (issue #123, patches/README.md). The vendored
-# paths are upstream at a pinned commit (.upstream-ref) plus the patches in patches/; scripts/patches.py
+# paths are upstream at a pinned commit (.upstream-ref) plus the patches in patches/; tools/patches.py
# bump moves the pin, re-applies the series, drops the patches that landed upstream, and leaves the rest
-# for review. Nothing is pushed to main (it is protected): the result is a pull request from the branch
+# for review. While the repository still commits the vendored tree (step 1 of issue #214), the bump
+# rewrites it too; in step 2 this becomes `tools/engine.py bump`, and the PR touches only .upstream-ref
+# and patches/. The checks run on engine/ (tools/engine.py sync) either way.
+# Nothing is pushed to main (it is protected): the result is a pull request from the branch
# sync/upstream-<short sha> (or, when a patch no longer applies, an issue naming it).
#
# A PR opened with the default GITHUB_TOKEN does not start other workflows (GitHub's rule), so this job
@@ -42,7 +45,7 @@ jobs:
run: |
if [ "$OLD" = "$NEW" ]; then echo "Already at $NEW"; echo "changed=no" >> "$GITHUB_OUTPUT"; exit 0; fi
set +e
- python3 scripts/patches.py bump --to "$NEW" 2>&1 | tee bump.log
+ python3 tools/patches.py bump --to "$NEW" 2>&1 | tee bump.log
rc=${PIPESTATUS[0]}
if [ $rc -eq 0 ]; then echo "changed=yes" >> "$GITHUB_OUTPUT"
elif [ $rc -eq 1 ]; then echo "changed=conflict" >> "$GITHUB_OUTPUT"
@@ -51,13 +54,14 @@ jobs:
- name: Check the patch queue
if: steps.bump.outputs.changed == 'yes'
run: |
- python3 scripts/patches.py check
- python3 -m unittest discover scripts/tests
+ python3 tools/engine.py check --tree
+ python3 -m unittest discover tools/tests
+ python3 tools/engine.py sync
# every .py parses on the Python this fork supports as its floor, the iOS build script survives bash -n
- python3 -m compileall -q scripts dm/tools dm/games dm/mac > /dev/null
- bash -n dm/ios/tools/build_ipa.sh
- GAME=$(ls dm/games | grep '^0100' | head -1)
- make -C dm/host GAME=$GAME dmhost -j4 2>&1 | tail -20
+ python3 -m compileall -q engine/scripts engine/dm/tools engine/dm/games engine/dm/mac > /dev/null
+ bash -n engine/dm/ios/tools/build_ipa.sh
+ GAME=$(ls engine/dm/games | grep '^0100' | head -1)
+ make -C engine/dm/host GAME=$GAME dmhost -j4 2>&1 | tail -20
- name: Commit to a sync branch and open a pull request
if: steps.bump.outputs.changed == 'yes'
@@ -76,7 +80,7 @@ jobs:
git commit -m "Sync upstream $SHORT"
git push -u origin "sync/upstream-$SHORT"
{
- echo "The patch queue re-applied on upstream \`${NEW:0:12}\` (was \`${OLD:0:12}\`): every patch applied, and \`scripts/patches.py check\`, the tests and a macOS host build passed. Merging brings seedds/nxnative to \`$NEW\`."
+ echo "The patch queue re-applied on upstream \`${NEW:0:12}\` (was \`${OLD:0:12}\`): every patch applied, and \`tools/engine.py check --tree\`, the tests and a macOS host build passed. Merging brings seedds/nxnative to \`$NEW\`."
echo
echo "Upstream: https://github.com/seedds/nxnative/compare/${OLD:0:12}...${NEW:0:12}"
echo
@@ -84,7 +88,7 @@ jobs:
tail -40 bump.log
echo '```'
echo
- echo "Patches listed under dropped landed upstream; their files are deleted from patches/. \`scripts/patches.py status\` lists what is still carried."
+ echo "Patches listed under dropped landed upstream; their files are deleted from patches/. \`tools/engine.py status\` lists what is still carried."
} > body.md
gh pr create -R "${{ github.repository }}" --base main --head "sync/upstream-$SHORT" \
--title "Sync upstream $SHORT" --body-file body.md || echo "PR creation failed; the branch is pushed"
@@ -97,7 +101,7 @@ jobs:
TITLE="Upstream sync blocked at ${NEW:0:7}"
{
echo "The nightly bump to \`${NEW:0:12}\` stopped at a patch that no longer applies. main is untouched. Whoever owns the patch refreshes it:"
- echo "run \`scripts/patches.py bump --to ${NEW:0:12}\` locally, resolve the conflict in the worktree it names, \`git am --continue\`, then \`scripts/patches.py refresh <worktree> --to ${NEW:0:12}\` (patches/README.md)."
+ echo "run \`tools/patches.py bump --to ${NEW:0:12}\` locally, resolve the conflict in the worktree it names, \`git am --continue\`, then \`tools/patches.py refresh <worktree> --to ${NEW:0:12}\` (patches/README.md)."
echo
echo '```'
cat tail.log
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d8f0948f..c08f3f18 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -3,6 +3,8 @@
# Tests that need no game files, keys or GPU. GitHub's macOS runners are virtual Macs without Metal 4 (issue #112), so the tests that go through mtl_init
# (t_nvn, t_mip_extent, t_rt_range and the rest of dm/gfx/tests' run list) stay local: run `make -C dm/gfx/tests GAME=<id> run` on an Apple-silicon Mac.
# `profile_guess.py --check` stays local too: it compares the guesses with the extractions of the games (it needs their files).
+# The engine jobs run in engine/: seedds/nxnative at .upstream-ref plus patches/, made by `tools/engine.py sync` (issue #214). While the
+# repository still commits the same tree (step 1 of #214), the patch-queue job checks that both are equal.
name: tests
on:
@@ -34,10 +36,16 @@ jobs:
name: Host unit tests and CPU-only gfx tests
runs-on: xcode-27
timeout-minutes: 20
+ defaults:
+ run:
+ working-directory: engine
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Engine (tools/engine.py sync, issue #214)
+ working-directory: .
+ run: python3 tools/engine.py sync
- name: Host unit tests (dm/host/tests)
run: |
mkdir -p logs
@@ -75,17 +83,23 @@ jobs:
if: failure()
with:
name: logs-host-tests
- path: logs
+ path: engine/logs
retention-days: 7
tool-tests:
name: Tool tests
runs-on: xcode-27
timeout-minutes: 15
+ defaults:
+ run:
+ working-directory: engine
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Engine (tools/engine.py sync, issue #214)
+ working-directory: .
+ run: python3 tools/engine.py sync
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.14'
@@ -106,7 +120,7 @@ jobs:
- name: Run the test files
env:
DM_GAME: ${{ env.GAME }} # test_tbdr_budget runs a tool that needs a profile
- DMSH_TEST_XLATE: ${{ github.workspace }}/dm/gfx/tools/dmsh_xlate_bin/dmsh_xlate
+ DMSH_TEST_XLATE: ${{ github.workspace }}/engine/dm/gfx/tools/dmsh_xlate_bin/dmsh_xlate
run: |
mkdir -p logs
failed=0
@@ -120,48 +134,51 @@ jobs:
if: failure()
with:
name: logs-tool-tests
- path: logs
+ path: engine/logs
retention-days: 7
patch-queue:
- name: Patch queue (check, dry bump against seedds main, issue #123)
+ name: Patch queue (series applies to the pin, committed tree matches, dry bump against seedds main, issues #123 and #214)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- fetch-depth: 0
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.14'
- # scripts/patches.py check: the series applies to the pinned upstream (.upstream-ref) and reproduces the committed vendored tree. A vendored
- # file edited without a patch, a patch whose header is incomplete and a patch that touches the shader chain fail here. The dry bump to
- # seedds main only reports (the nightly sync opens the PR or the issue); it lists the patches that would conflict.
- - name: Fetch seedds main and the pinned base
- run: |
- git remote add seedds https://github.com/seedds/nxnative.git
- git fetch --no-tags seedds main
- git fetch --no-tags seedds "$(cat .upstream-ref)"
+ # tools/engine.py check --tree: the headers are complete, no patch touches the shader chain or the generated files, the series applies
+ # cleanly to the pinned upstream (.upstream-ref) with no empty patch, and, while the repository still commits the vendored tree (step 1
+ # of #214), that tree equals pin + series. engine.py fetches the pinned commit itself. The dry bump to seedds main only reports (the
+ # nightly sync opens the PR or the issue); it lists the patches that would conflict.
- name: Patch queue check
run: |
- python scripts/patches.py check || {
- echo "::error title=Patch queue::Patch queue out of sync: vendored files differ from pin + patches. Fix: python3 scripts/patches.py absorb <the files listed above> (a new file may need --into <patch>), then commit patches/. See patches/README.md."
+ python tools/engine.py check --tree || {
+ echo "::error title=Patch queue::The series does not apply to the pin, or the committed vendored tree differs from pin + patches. Fix: work in engine/ (python3 tools/engine.py sync), commit there, python3 tools/engine.py export, or fold a direct edit with python3 tools/patches.py absorb <files>. See patches/README.md."
exit 1
}
- - name: Patch queue tests
- run: python -m unittest -v scripts/tests/test_patches.py
+ - name: Install ripgrep (the engine/ search test)
+ run: sudo apt-get install -y -qq ripgrep > /dev/null
+ - name: Patch tool tests
+ run: python -m unittest -v tools/tests/test_patches.py tools/tests/test_engine.py
- name: Dry bump to seedds main (report only)
- run: python scripts/patches.py bump --dry --to "$(git rev-parse seedds/main)" || true
+ run: python tools/engine.py bump --dry --to main || true
build:
name: Build check (Mac host, gfx tests, iOS sources)
runs-on: xcode-27
timeout-minutes: 40
+ defaults:
+ run:
+ working-directory: engine
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Engine (tools/engine.py sync, issue #214)
+ working-directory: .
+ run: python3 tools/engine.py sync
- name: Mac host for three profiles (Vulkan, NVN, OpenGL)
run: |
mkdir -p logs
@@ -185,7 +202,7 @@ jobs:
if: failure()
with:
name: logs-build
- path: logs
+ path: engine/logs
retention-days: 7
launcher:
@@ -255,10 +272,16 @@ jobs:
name: Unsigned iOS app (synthetic modules, Swift and link)
runs-on: xcode-27
timeout-minutes: 40
+ defaults:
+ run:
+ working-directory: engine
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Engine (tools/engine.py sync, issue #214)
+ working-directory: .
+ run: python3 tools/engine.py sync
- name: Install XcodeGen
run: command -v xcodegen || brew install xcodegen
- name: Build the production iOS project with synthetic inputs
@@ -269,5 +292,5 @@ jobs:
if: failure()
with:
name: logs-ios-build
- path: logs
+ path: engine/logs
retention-days: 7