Create work/image before the standalone lift saves its chunk boundaries #1947

Merged
d1dac0 merged 1 commit from fix/lift-standalone-image-folder into main 2026-11-11 02:31:48 +00:00
d1dac0 commented 2026-11-10 21:27:46 +00:00 (Migrated from github.com)

The documented source-build steps run python -I nx2/lift.py --standalone --write on a fresh checkout, and on a new work/ folder that command translates the whole game and then stops at its last step:

FileNotFoundError: [Errno 2] No such file or directory:
'...\work\image\chunks.txt'

The chunk boundaries are saved under <work>/image while the image itself goes to <work>/sa/image, and only make_game.py made the first folder. Anyone following docs/development.md without the builder hits it after ~10 minutes of translation.

What changed

  • nx2/chunks.py: save() makes the folder it writes chunks.txt into, so every caller can save into a folder that does not exist yet.
  • tests/test_chunks_save_folder.py: saves into a missing <work>/image, reads the boundaries back, and saves again to check the file is replaced rather than appended.

How it was tested

  • Reproduced on a fresh work folder: the lift stopped with the FileNotFoundError above after translating 294,523 functions.
  • With the patch, work/image removed and the same command re-run: exit 0 after 512 s, 294,523 functions, 17,646,456 instructions, 100.0000% translated, and work/image/chunks.txt written (75 code files).
  • Full build and in-game run on the same tree: build.py --standalone --jobs 8 compiled 465 files with 0 failures; the game ran on Vulkan (RTX 3080 Laptop, driver 32.0.15.9159) from the title screen through the intro to Kokiri Forest at 60 fps in the light scenes.
  • python -I -B tests/run_all.py on this branch: 313 passed, 21 skipped; the checks that failed under 8-way load time out on fixture compiles on this PC and pass when run alone (verified for four of them).

No issue to link; found while building the game from source on Windows.

The documented source-build steps run `python -I nx2/lift.py --standalone --write` on a fresh checkout, and on a new `work/` folder that command translates the whole game and then stops at its last step: ``` FileNotFoundError: [Errno 2] No such file or directory: '...\work\image\chunks.txt' ``` The chunk boundaries are saved under `<work>/image` while the image itself goes to `<work>/sa/image`, and only `make_game.py` made the first folder. Anyone following docs/development.md without the builder hits it after ~10 minutes of translation. ## What changed - `nx2/chunks.py`: `save()` makes the folder it writes `chunks.txt` into, so every caller can save into a folder that does not exist yet. - `tests/test_chunks_save_folder.py`: saves into a missing `<work>/image`, reads the boundaries back, and saves again to check the file is replaced rather than appended. ## How it was tested - Reproduced on a fresh work folder: the lift stopped with the `FileNotFoundError` above after translating 294,523 functions. - With the patch, `work/image` removed and the same command re-run: exit 0 after 512 s, 294,523 functions, 17,646,456 instructions, 100.0000% translated, and `work/image/chunks.txt` written (75 code files). - Full build and in-game run on the same tree: `build.py --standalone --jobs 8` compiled 465 files with 0 failures; the game ran on Vulkan (RTX 3080 Laptop, driver 32.0.15.9159) from the title screen through the intro to Kokiri Forest at 60 fps in the light scenes. - `python -I -B tests/run_all.py` on this branch: 313 passed, 21 skipped; the checks that failed under 8-way load time out on fixture compiles on this PC and pass when run alone (verified for four of them). No issue to link; found while building the game from source on Windows.
hckrman101 (Migrated from github.com) approved these changes 2026-11-11 02:18:21 +00:00
hckrman101 (Migrated from github.com) left a comment

Looks good. The one call to chunks.save (via chunks.write, lift.py line ~184) passes <work>/image, which nothing creates on a standalone lift, so the os.makedirs(img_dir, exist_ok=True) in save() is the right place to fix it: every caller is covered, and it is a no-op when make_game.py already made the folder.

The test follows the test_chunk_split.py conventions (kit import, python -I -B header), needs no dump, and checks both the missing-folder case and that a second save replaces the file. run_all.py discovers tests/test_*.py, so no registration is needed.

No prior discussion on the PR. No CI checks are reported for the branch, so I only read the diff; I did not build or run it. The lift and in-game runs in the description are consistent with the change.

Looks good. The one call to `chunks.save` (via `chunks.write`, `lift.py` line ~184) passes `<work>/image`, which nothing creates on a standalone lift, so the `os.makedirs(img_dir, exist_ok=True)` in `save()` is the right place to fix it: every caller is covered, and it is a no-op when `make_game.py` already made the folder. The test follows the `test_chunk_split.py` conventions (`kit` import, `python -I -B` header), needs no dump, and checks both the missing-folder case and that a second save replaces the file. `run_all.py` discovers `tests/test_*.py`, so no registration is needed. No prior discussion on the PR. No CI checks are reported for the branch, so I only read the diff; I did not build or run it. The lift and in-game runs in the description are consistent with the change.
Commenting is not possible because the repository is archived.
No description provided.