feat(builder): the profile's mods' ExeFS patches are built in, and a start builds again when they change #2607

Merged
HumanBean merged 2 commits from HumanBean/Longshot:feat/mods-exefs-rebuild into main 2026-11-26 07:50:29 +00:00
Owner

Summary

Mods' ExeFS patches (.ips, .pchtxt) never reach the game with the Rust builder. Two stubs were left for the Mod API (#2434):

  • build_driver::read::manifest_mods always returned no mods, so a build applied no patch.
  • The play check's mods stamp never changed, so a patch added after a build never started a rebuild.

The game's Mods tab keeps saying "1 ExeFS patch file is not in the game yet: build the game again".

This fills both:

  • manifest_mods finds the profile's manifest mods the way the game does (game/mods.c, docs/dev/reference/mods.md "Discovery and order"):
    • a folder with mod.json one to four levels below mods/, and nothing below a mod is searched;
    • folders named -… or _… are off, along with everything below them, and .… folders are skipped;
    • each mod is named by its path under mods/, which is the name the game looks for in exefs_patches.txt;
    • the order and the on/off switches come from the profile's mods.json: the mods it names first, then the others, on, sorted by path ignoring case.
  • Stamp.patches (play::patches_stamp) is a hash of each enabled mod's patch files: their names and SHA-256s, in order. It's recorded with each build. When it differs at a start, the game is built again (Stale::Mods) in the same game folder. Only the functions the patches change are lifted and compiled again.

mods_stamp, which names a separate game folder per code-mod set, stays the Mod API's.

Testing

Tested (Linux, RTX 3090, this branch's longshot-builder, all through the job queue):

  • cargo clippy -p build-driver --all-targets -D warnings is clean.
  • New game-free tests (second commit), passing: manifest_mods_are_found_and_ordered_as_the_game_does (no profile and no mods folder give none; four levels down found, five not; nothing below a mod; -/_/. folders skipped; mods.json order first with enabled: false kept as off, unknown and non-local/ ids ignored, the rest on and after by path ignoring case; a bad mods.json leaves every mod on) and patches_stamp_follows_the_enabled_mods_patch_files (empty with no patches; ignores files other than .ips/.pchtxt; changes when a patch's bytes change, when the order changes and when a mod is switched off).
  • With the game: a profile whose game folder was a copy of a main base build, update --profile and info --profile --output json between steps:
    • before: stale, "built for no profile"; first update 263 s (all 906 units compiled again: a different builder than the base's); then up to date.
    • one manifest mod added with a harmless exefs/test.pchtxt (a write of the bytes already there): stale, "the mods that need a build changed". The update took 6 s, 0 of 906 units compiled again; exefs_patches.txt lists patchtest test.pchtxt ... empty; up to date after it.
    • the mod switched off in mods.json: stale again with the same reason. The update took 5 s and the mod's line left exefs_patches.txt; up to date after it.

Still to test:

  • A patch that changes code (kind code): only the units it touches are lifted and compiled again.
  • The Mods tab's text, in the game or the launcher.

Measurements

Nothing to measure yet: a rebuild after a patch change lifts and compiles only the functions the patches touch.

Risks

Builds made before this record no patches key, so they read as empty: a profile with no ExeFS mods doesn't rebuild. A profile that already has some rebuilds once at its next start. Revert to undo.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (not yet: the user asked for the PR first)
  • mise run test passes (any failure that also fails on main is named). (this PR's CI runs it)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (to add)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec

## Summary Mods' ExeFS patches (`.ips`, `.pchtxt`) never reach the game with the Rust builder. Two stubs were left for the Mod API ([#2434](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2434)): - `build_driver::read::manifest_mods` always returned no mods, so a build applied no patch. - The play check's mods stamp never changed, so a patch added after a build never started a rebuild. The game's Mods tab keeps saying "1 ExeFS patch file is not in the game yet: build the game again". This fills both: - **`manifest_mods`** finds the profile's manifest mods the way the game does (`game/mods.c`, `docs/dev/reference/mods.md` "Discovery and order"): - a folder with `mod.json` one to four levels below `mods/`, and nothing below a mod is searched; - folders named `-…` or `_…` are off, along with everything below them, and `.…` folders are skipped; - each mod is named by its path under `mods/`, which is the name the game looks for in `exefs_patches.txt`; - the order and the on/off switches come from the profile's `mods.json`: the mods it names first, then the others, on, sorted by path ignoring case. - **`Stamp.patches`** (`play::patches_stamp`) is a hash of each enabled mod's patch files: their names and SHA-256s, in order. It's recorded with each build. When it differs at a start, the game is built again (`Stale::Mods`) in the same game folder. Only the functions the patches change are lifted and compiled again. `mods_stamp`, which names a separate game folder per code-mod set, stays the Mod API's. ## Testing **Tested** (Linux, RTX 3090, this branch's `longshot-builder`, all through the job queue): - `cargo clippy -p build-driver --all-targets -D warnings` is clean. - New game-free tests (second commit), passing: `manifest_mods_are_found_and_ordered_as_the_game_does` (no profile and no mods folder give none; four levels down found, five not; nothing below a mod; `-`/`_`/`.` folders skipped; `mods.json` order first with `enabled: false` kept as off, unknown and non-`local/` ids ignored, the rest on and after by path ignoring case; a bad `mods.json` leaves every mod on) and `patches_stamp_follows_the_enabled_mods_patch_files` (empty with no patches; ignores files other than .ips/.pchtxt; changes when a patch's bytes change, when the order changes and when a mod is switched off). - With the game: a profile whose game folder was a copy of a main base build, `update --profile` and `info --profile --output json` between steps: - before: stale, "built for no profile"; first update 263 s (all 906 units compiled again: a different builder than the base's); then up to date. - one manifest mod added with a harmless `exefs/test.pchtxt` (a write of the bytes already there): stale, "the mods that need a build changed". The update took 6 s, 0 of 906 units compiled again; `exefs_patches.txt` lists `patchtest test.pchtxt ... empty`; up to date after it. - the mod switched off in `mods.json`: stale again with the same reason. The update took 5 s and the mod's line left `exefs_patches.txt`; up to date after it. **Still to test:** - A patch that changes code (kind `code`): only the units it touches are lifted and compiled again. - The Mods tab's text, in the game or the launcher. ## Measurements Nothing to measure yet: a rebuild after a patch change lifts and compiles only the functions the patches touch. ## Risks Builds made before this record no `patches` key, so they read as empty: a profile with no ExeFS mods doesn't rebuild. A profile that already has some rebuilds once at its next start. Revert to undo. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (not yet: the user asked for the PR first) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (this PR's CI runs it) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A fix: a game-free test that fails on `main` and passes here. (to add) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
feat(builder): the profile's mods' ExeFS patches are built in, and a start builds again when they change
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Successful in 25s
CI / What the change needs (pull_request) Successful in 31s
CI / Third-party parts and guide screenshots (pull_request) Successful in 45s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 4m15s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
27e770eb51
manifest_mods and the play check's mods stamp were stubs left for the Mod API: the builder built no mod's ExeFS
patch, and nothing rebuilt when one was added, so the Mods tab kept saying it was not in the game yet.
manifest_mods now finds a profile's manifest mods as the game does (mod.json one to four levels below mods/, -/_
off, . skipped), in mods.json's order and switches. The stamp a build records gains patches: the enabled mods'
patch files (names and SHA-256s); when it differs at a start, the game is built again (Stale::Mods) in the same
game folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
Member

Possibly related, for context:

  • issue #2497 Mods that ship extra ExeFS modules (subsdkN) are not loaded: the .ips applies but its code is missing — Reports ExeFS patches applied but mod-provided code modules missing; adjacent limitation, not directly fixed here
  • PR #984 WIP: feat(mods): a mod's code module (exefs/subsdk*) is built in with the game — Open PR covers building mods' extra ExeFS code modules, distinct from patch discovery and rebuild stamps
Possibly related, for context: - issue #2497 Mods that ship extra ExeFS modules (subsdkN) are not loaded: the .ips applies but its code is missing — Reports ExeFS patches applied but mod-provided code modules missing; adjacent limitation, not directly fixed here - PR #984 WIP: feat(mods): a mod's code module (exefs/subsdk*) is built in with the game — Open PR covers building mods' extra ExeFS code modules, distinct from patch discovery and rebuild stamps
test(builder): manifest_mods and patches_stamp
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / What the change needs (pull_request) Successful in 21s
CI / Third-party parts and guide screenshots (pull_request) Successful in 35s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 2m34s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m48s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m14s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Successful in 4m29s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m0s
CI / Website build and checks (pull_request) Successful in 2m41s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 4m37s
PR description / Title and description (pull_request_target) Failing after 20s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Successful in 31m37s
3d93f8f0f3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
Author
Owner

Builder end-to-end test of this branch (27e770eb plus the tests commit; Linux, RTX 3090, job queue). The game folder was a copy of a main base build, driven with longshot-builder update --profile and info --profile --output json:

Step info says Update
Profile, no mods stale: built for no profile 263 s, 906/906 units compiled (a different builder than the base's)
After it up to date
One manifest mod added (exefs/test.pchtxt, a write of the bytes already there) stale: the mods that need a build changed 6 s, 0/906 compiled; exefs_patches.txt: patchtest test.pchtxt ... empty
After it up to date
Mod switched off in mods.json stale: the mods that need a build changed 5 s; the mod's line left exefs_patches.txt
After it up to date

The game wasn't started. The new unit tests for manifest_mods and patches_stamp pass. A patch of kind code, which would lift and compile units again, wasn't tried.

Builder end-to-end test of this branch (27e770eb plus the tests commit; Linux, RTX 3090, job queue). The game folder was a copy of a main base build, driven with `longshot-builder update --profile` and `info --profile --output json`: | Step | `info` says | Update | |---|---|---| | Profile, no mods | stale: built for no profile | 263 s, 906/906 units compiled (a different builder than the base's) | | After it | up to date | | | One manifest mod added (`exefs/test.pchtxt`, a write of the bytes already there) | stale: the mods that need a build changed | 6 s, 0/906 compiled; `exefs_patches.txt`: `patchtest test.pchtxt ... empty` | | After it | up to date | | | Mod switched off in `mods.json` | stale: the mods that need a build changed | 5 s; the mod's line left `exefs_patches.txt` | | After it | up to date | | The game wasn't started. The new unit tests for `manifest_mods` and `patches_stamp` pass. A patch of kind `code`, which would lift and compile units again, wasn't tried.
HumanBean changed title from WIP: feat(builder): the profile's mods' ExeFS patches are built in, and a start builds again when they change to feat(builder): the profile's mods' ExeFS patches are built in, and a start builds again when they change 2026-11-26 07:50:20 +00:00
HumanBean deleted branch feat/mods-exefs-rebuild 2026-11-26 07:50:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2607
No description provided.