Skip to content

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

Protect the adjustable-clock fix from the sync, and check PR scope (issue #29)

LNPANDYbcb2e0ea6532
diff --git a/.github/workflows/pr-scope.yml b/.github/workflows/pr-scope.yml
new file mode 100644
index 00000000..e31fa238
--- /dev/null
+++ b/.github/workflows/pr-scope.yml
@@ -0,0 +1,68 @@
+# Guard the sync: fail a PR that edits a vendored file outside the fork's protection.
+#
+# The sync takes dm/, scripts/, docs/, AGENTS.md and ref/ from upstream file by file. Three kinds
+# of file keep the fork's changes: OURS (fork-only files), PATCHED (carriers whose patcher
+# re-applies them), and fork-only paths the sync never takes (frontend/, frontend-qt/,
+# .github/workflows/). A PR that edits any other vendored file will be silently reverted the next
+# time upstream touches it — issue #29 (v0lumehi reading the sync script) is what made this a
+# check instead of a note in CONTRIBUTING.
+#
+# What a PR author sees on failure: the list of files at risk, and the two ways out (propose the
+# change upstream first, or ask a maintainer to add a patcher entry).
+name: PR scope (sync safety)
+
+on:
+ pull_request:
+ paths: ['dm/**', 'scripts/**', 'docs/**', 'ref/**', 'AGENTS.md']
+
+permissions:
+ contents: read
+
+jobs:
+ check:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Files the sync protects or never overwrites
+ id: known
+ run: |
+ python3 - <<'PY' >> "$GITHUB_OUTPUT"
+ import sys
+ sys.path.insert(0, 'scripts')
+ import sync_upstream as su
+ ours = sorted(su.OURS)
+ patched = sorted(su.PATCHED)
+ print(f'ours={",".join(ours)}')
+ print(f'patched={",".join(patched)}')
+ PY
+
+ - name: Check the PR's changed files
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ OURS: ${{ steps.known.outputs.ours }}
+ PATCHED: ${{ steps.known.outputs.patched }}
+ run: |
+ # changed files = base...head, minus deletions (nothing to protect there)
+ BASE="${{ github.event.pull_request.base.sha }}"
+ HEAD="${{ github.event.pull_request.head.sha }}"
+ git fetch --no-tags origin "$BASE" "$HEAD" 2>/dev/null || true
+ CHANGED=$(git diff --name-only --diff-filter=d "$BASE" "$HEAD" | sort -u)
+ at_risk=""
+ for f in $CHANGED; do
+ case "$f" in
+ frontend/*|frontend-qt/*|.github/*) continue ;; # fork-only, never taken from upstream
+ esac
+ case ",$OURS," in *",$f,"*) continue ;; esac
+ case ",$PATCHED," in *",$f,"*) continue ;; esac
+ at_risk="$at_risk$f\n"
+ done
+ if [ -n "$at_risk" ]; then
+ echo "::error::These vendored files would be reverted by the next sync (they are not in OURS or PATCHED):"
+ echo -e "$at_risk"
+ echo ""
+ echo "Send the change to seedds/nxnative first (it comes back with the daily sync), or ask a"
+ echo "maintainer to add a patcher entry in scripts/sync_upstream.py for it."
+ exit 1
+ fi
+ echo "PR touches no unprotected vendored files."
diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.py
index 98f7f849..dd32bad0 100644
--- a/scripts/sync_upstream.py
+++ b/scripts/sync_upstream.py
@@ -35,6 +35,11 @@ OURS = {'dm/host/romfs_arc.c', 'dm/host/romfs_arc.h', 'dm/tools/romfs_arc.py',
# BC decode for GPUs without BC support (from d2r-mobile's bcdec line; tex_bc_cpu profiles)
'dm/third_party/bcdec/bcdec.h', 'dm/third_party/bcdec/LICENSE',
'dm/gfx/tex/nvn_bcdec.c', 'dm/gfx/tex/nvn_bcdec.h',
+ # The adjustable clock entry (PR #26) and its test are fork-only for now: upstream does not
+ # have CreateWithAdjustableSystemClock, so a sync would otherwise replace these files and
+ # silently drop the fix (issue #29, found by v0lumehi reading the sync script). If upstream
+ # takes seedds PR for it, these leave OURS and come back with the sync instead.
+ 'dm/host/hle_time.c', 'dm/host/tests/t_time.c',
'dm/gfx/tex/tests/t_bcdec.c'}
# Vendored files that carry fork patches: taken fresh from upstream, then patched below.
PATCHED = ('dm/host/hle_fs.c', 'dm/host/Makefile', 'dm/host/tests/Makefile', 'dm/ios/tools/build_ipa.sh',