make_game: a run without the LEONIDA board still writes <work>/logs/<stage>.log (MAKE-GAME-PLAIN-LOG) #1378

Open
github-bot wants to merge 1 commit from github-bot/gh-1378 into main AGit
Owner

@⁠Diegobecker07 on GitHub · 2026-11-24 22:56 UTC · original
Diegobecker07:make-game-plain-log → main · +287 −8 · 3 files · 1 commits · open

Claimed in the coordination issue as: MAKE-GAME-PLAIN-LOG (#14)

What and why

Only the LEONIDA board wrote the stage logs (make_game.py, the LeonidaBoard(build_stages, log_dir) branch of main()), so a build with --no-tui, or with stdout redirected, left nothing in <work>/logs to read afterwards. With a multi-hour build that is the run you most want a log of.

PlainStageLogs (in make_game.py) is active while the build stages run without the board:

  • log() and fail() lines go to the console as before, and to the running stage's <work>/logs/<stage>.log, the files the board writes (opened in append mode, as there).
  • A command run() starts for a build stage has its stdout and stderr through one pipe. Every byte goes on to the console as it arrives (read1, so a \r progress line still redraws in place), and every \r- or \n-ended piece to the stage's log, with the same split as leonida_tui.pump_process.
  • The child keeps the console (no CREATE_NO_WINDOW), so Ctrl+C reaches it as before. On Ctrl+C it gets 0.25 s to stop and is then killed, as subprocess.run does.
  • A caller that sets its own pipes, and a command outside a build stage (check, preflight), keep subprocess.run unchanged.
  • A stage's file is opened with its first line. An unwritable folder gives one note on stderr, and the build goes on without the logs (tests/test_make_game_paths.py builds into a work folder on a volume that does not exist).

tools/leonida_tui.py is not touched: the class reuses its StageConsole, so this does not overlap #1305.

What changes on the console in plain mode: a child now writes to a pipe instead of the console, as it already does under the board. Ninja, for example, prints its status one line per step instead of redrawing one line. A tool that writes straight to the console handle (WriteConsole) still shows there but is not in the log.

The module docstring, the --no-tui help and the README say where the logs are in both modes.

Tested

  • tests/test_make_game_plain_logs.py (new, 9 tests, real child processes, 4 runs): log()/fail() lines per stage, bytes mirrored unchanged (a \r progress line, a \r\n, stderr after stdout, an unended last piece) and the pieces logged, a failing command's exit code and its ERROR: line, caller pipes and unlogged stages kept on subprocess.run, cwd/env reaching the child, Ctrl+C stopping the child, an unwritable log folder, append across two runs, nothing written without a build stage.
  • All 24 tests/test_make_game_*.py, tests/test_leonida_tui.py, tests/test_text_write_line_endings.py: OK. test_make_game_paths.py caught the first version, which created the folder up front.
  • python -m compileall -q make_game.py tools tests, python -I make_game.py --help, scripts/check_no_game_data.py on the changed files: OK.
  • End to end on Windows: make_game.py --stages runtime --runtime-build <a built runtime> --no-tui into a scratch --out/--work: exit 0, the console unchanged, and work/logs/runtime.log holds the stage's lines.

GPUs tested: n/a (no GPU code)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)
**@⁠Diegobecker07** on GitHub · 2026-11-24 22:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1378) `Diegobecker07:make-game-plain-log` → `main` · +287 −8 · 3 files · 1 commits · open Claimed in the coordination issue as: MAKE-GAME-PLAIN-LOG (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Only the LEONIDA board wrote the stage logs (`make_game.py`, the `LeonidaBoard(build_stages, log_dir)` branch of `main()`), so a build with `--no-tui`, or with stdout redirected, left nothing in `<work>/logs` to read afterwards. With a multi-hour build that is the run you most want a log of. `PlainStageLogs` (in `make_game.py`) is active while the build stages run without the board: - `log()` and `fail()` lines go to the console as before, and to the running stage's `<work>/logs/<stage>.log`, the files the board writes (opened in append mode, as there). - A command `run()` starts for a build stage has its stdout and stderr through one pipe. Every byte goes on to the console as it arrives (`read1`, so a `\r` progress line still redraws in place), and every `\r`- or `\n`-ended piece to the stage's log, with the same split as `leonida_tui.pump_process`. - The child keeps the console (no `CREATE_NO_WINDOW`), so Ctrl+C reaches it as before. On Ctrl+C it gets 0.25 s to stop and is then killed, as `subprocess.run` does. - A caller that sets its own pipes, and a command outside a build stage (`check`, preflight), keep `subprocess.run` unchanged. - A stage's file is opened with its first line. An unwritable folder gives one note on stderr, and the build goes on without the logs (`tests/test_make_game_paths.py` builds into a work folder on a volume that does not exist). `tools/leonida_tui.py` is not touched: the class reuses its `StageConsole`, so this does not overlap #1305. What changes on the console in plain mode: a child now writes to a pipe instead of the console, as it already does under the board. Ninja, for example, prints its status one line per step instead of redrawing one line. A tool that writes straight to the console handle (`WriteConsole`) still shows there but is not in the log. The module docstring, the `--no-tui` help and the README say where the logs are in both modes. ### Tested - `tests/test_make_game_plain_logs.py` (new, 9 tests, real child processes, 4 runs): `log()`/`fail()` lines per stage, bytes mirrored unchanged (a `\r` progress line, a `\r\n`, stderr after stdout, an unended last piece) and the pieces logged, a failing command's exit code and its `ERROR:` line, caller pipes and unlogged stages kept on `subprocess.run`, `cwd`/`env` reaching the child, Ctrl+C stopping the child, an unwritable log folder, append across two runs, nothing written without a build stage. - All 24 `tests/test_make_game_*.py`, `tests/test_leonida_tui.py`, `tests/test_text_write_line_endings.py`: OK. `test_make_game_paths.py` caught the first version, which created the folder up front. - `python -m compileall -q make_game.py tools tests`, `python -I make_game.py --help`, `scripts/check_no_game_data.py` on the changed files: OK. - End to end on Windows: `make_game.py --stages runtime --runtime-build <a built runtime> --no-tui` into a scratch `--out`/`--work`: exit 0, the console unchanged, and `work/logs/runtime.log` holds the stage's lines. GPUs tested: n/a (no GPU code) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
Only the board wrote the stage logs, so a build with --no-tui (or with stdout redirected) left nothing in
<work>/logs to read afterwards. PlainStageLogs now covers that case while the build stages run:

- log() and fail() lines go to the console as before and to the running stage's log;
- a command run() starts for a build stage has its stdout and stderr through one pipe: every byte goes on to
  the console as it arrives (a \r progress line still redraws) and every \r- or \n-ended piece to the stage's
  log, the same split the board uses. The child keeps the console, so Ctrl+C reaches it as before; on Ctrl+C it
  gets 0.25 s to stop and is then killed, as subprocess.run does;
- a caller that sets its own pipes, and commands outside a build stage, keep subprocess.run;
- a stage's file is opened with its first line; an unwritable folder gives one note on stderr and the build
  goes on without the logs.

The module docstring, the --no-tui help and the README say where the logs are in both modes.
tests/test_make_game_plain_logs.py covers the cases above with real child processes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:49:23 +00:00
Author
Owner

@⁠Diegobecker07 on GitHub · 2026-11-25 13:13 UTC · original

Re-checked against current main (0d80bc5df). Main changed make_game.py and README.md in other places and the PR still merges cleanly, so I did not rebase it. On the merged tree, all 25 tests/test_make_game_*.py files pass (including this PR's test_make_game_plain_logs.py), along with test_text_write_line_endings.py, compileall and make_game.py --help.

The three open PRs that touch make_game.py (#1013, #1378, #1407) also merge with each other without conflicts. The same tests pass with all three merged on main (27 files).

CI is waiting for workflow approval (first-time contributor).

AI-assisted.

**@⁠Diegobecker07** on GitHub · 2026-11-25 13:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1378#issuecomment-7163470403) Re-checked against current main (0d80bc5df). Main changed `make_game.py` and `README.md` in other places and the PR still merges cleanly, so I did not rebase it. On the merged tree, all 25 `tests/test_make_game_*.py` files pass (including this PR's `test_make_game_plain_logs.py`), along with `test_text_write_line_endings.py`, `compileall` and `make_game.py --help`. The three open PRs that touch `make_game.py` (#1013, #1378, #1407) also merge with each other without conflicts. The same tests pass with all three merged on main (27 files). CI is waiting for workflow approval (first-time contributor). AI-assisted.
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:13 UTC · original

Reviewed 16f3831a5: ran tests/test_make_game_plain_logs.py on the PR (9/9 OK) and on main with the test copied in (9 errors, PlainStageLogs absent, so the test covers the new code); also ran dry_run/interrupt/argparse/resume/progress/preflight/bvh_shaders_stage/translate_cleanup (all OK) and compared test_make_game_platform against main (same pre-existing environment failures on both, no regression). A separate probe verified chunk-boundary splitting (\r, \r\n, UTF-8 split across chunks, unterminated tail), 60 000-line volume, two concurrent stages with children, and the failing-child path: no discrepancies. None of the tests that need a GPU, Windows, MSVC or game files were run. Two non-blocking notes: input=/timeout= kwargs would now raise TypeError on the plain pump (same as the board path; no caller uses them today), and on Windows the plain pump deliberately leaves the child its console handle, so cmake/ninja/MSBuild WriteConsole output may reach the screen but not the stage log; worth a Windows check before relying on the logs there.

AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 15:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1378#issuecomment-7166487240) Reviewed 16f3831a5: ran `tests/test_make_game_plain_logs.py` on the PR (9/9 OK) and on main with the test copied in (9 errors, `PlainStageLogs` absent, so the test covers the new code); also ran dry_run/interrupt/argparse/resume/progress/preflight/bvh_shaders_stage/translate_cleanup (all OK) and compared `test_make_game_platform` against main (same pre-existing environment failures on both, no regression). A separate probe verified chunk-boundary splitting (`\r`, `\r\n`, UTF-8 split across chunks, unterminated tail), 60 000-line volume, two concurrent stages with children, and the failing-child path: no discrepancies. None of the tests that need a GPU, Windows, MSVC or game files were run. Two non-blocking notes: `input=`/`timeout=` kwargs would now raise `TypeError` on the plain pump (same as the board path; no caller uses them today), and on Windows the plain pump deliberately leaves the child its console handle, so cmake/ninja/MSBuild `WriteConsole` output may reach the screen but not the stage log; worth a Windows check before relying on the logs there. AI-assisted review. **Recommendation:** Merge
Author
Owner

@⁠Diegobecker07 on GitHub · 2026-11-25 16:28 UTC · original

Thanks for the review. I checked the Windows console-handle note on this PR's head (16f3831a5) in a real console: cmd in Windows Terminal running python -I make_game.py --game <pkg> --out <scratch> --work <scratch> --stages runtime --jobs 12 --no-tui. make_game's stdout was the console, so the children inherited it (Windows 11 Pro 26300, MSVC 19.44, CMake 3.31 + Ninja from VS Build Tools).

  • The log has the whole build. work/logs/runtime.log has 911 lines:
    • the CMake configure, from The CXX compiler identification to Build files have been written;
    • all 757 ninja steps, [1/757] through [757/757], including vk_pipeline_check.exe;
    • built ...\gta6rt.exe and make_game's own lines.
  • The console matches the log. The last screen of the console matches the end of the log line for line. The only lines that are on screen but not in the log are make_game's closing summary (build: 100% · runtime done, stage logs in …, finished in 4 min), which is printed after the stage ends.
  • Why nothing bypasses the pipe on Windows: the toolchain never sees the console.
    • scripts/build_runtime.ps1 starts cmd/cmake/ninja with -WindowStyle Hidden, redirects their stdout and stderr to _build.stdout.log and _build.stderr.log, and re-emits each line with Write-Output, which goes into this PR's pipe.
    • build_pipeline_check() runs CMake directly only when os.name != "nt". On Windows the pipelines stage uses the vk_pipeline_check.exe that the runtime stage builds.

So the note doesn't affect the build stages on Windows today. A tool that opened CONOUT$ itself would still bypass the pipe, but that is equally true with the board.

AI-assisted.

**@⁠Diegobecker07** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1378#issuecomment-7168045436) Thanks for the review. I checked the Windows console-handle note on this PR's head (16f3831a5) in a real console: cmd in Windows Terminal running `python -I make_game.py --game <pkg> --out <scratch> --work <scratch> --stages runtime --jobs 12 --no-tui`. make_game's stdout was the console, so the children inherited it (Windows 11 Pro 26300, MSVC 19.44, CMake 3.31 + Ninja from VS Build Tools). - **The log has the whole build.** `work/logs/runtime.log` has 911 lines: - the CMake configure, from `The CXX compiler identification` to `Build files have been written`; - all 757 ninja steps, `[1/757]` through `[757/757]`, including `vk_pipeline_check.exe`; - `built ...\gta6rt.exe` and make_game's own lines. - **The console matches the log.** The last screen of the console matches the end of the log line for line. The only lines that are on screen but not in the log are make_game's closing summary (`build: 100% · runtime done`, `stage logs in …`, `finished in 4 min`), which is printed after the stage ends. - **Why nothing bypasses the pipe on Windows:** the toolchain never sees the console. - `scripts/build_runtime.ps1` starts cmd/cmake/ninja with `-WindowStyle Hidden`, redirects their stdout and stderr to `_build.stdout.log` and `_build.stderr.log`, and re-emits each line with `Write-Output`, which goes into this PR's pipe. - `build_pipeline_check()` runs CMake directly only when `os.name != "nt"`. On Windows the pipelines stage uses the `vk_pipeline_check.exe` that the runtime stage builds. So the note doesn't affect the build stages on Windows today. A tool that opened `CONOUT$` itself would still bypass the pipe, but that is equally true with the board. AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1378/head:github-bot/gh-1378'
git switch 'github-bot/gh-1378'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1378'
git switch 'github-bot/gh-1378'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1378'
git switch 'github-bot/gh-1378'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1378'
git switch 'main'
git merge --squash 'github-bot/gh-1378'
git switch 'main'
git merge --ff-only 'github-bot/gh-1378'
git switch 'main'
git merge 'github-bot/gh-1378'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.