[pr-feature] Add one-click Build-Darner.cmd build and launch script #137

Open
davetheshrew wants to merge 3 commits from davetheshrew/Darner:pr/build-cmd into main
Contributor

Contributor role (optional)

  • Fluxer ID: 1577790829722873856

What it changes

  • Adds Build-Darner.cmd at the repository root (pure ASCII, CRLF line endings) for one-click building and launching on Windows:
    • Double-clicking builds target\release\darner.exe (cargo build --release --locked -p darner, automatically adding %USERPROFILE%\.cargo\bin to PATH when present) and launches game_scarlett_master.exe via darner.exe play.
    • Locates game_scarlett_master.exe without hardcoded user paths by checking DARNER_GAME_DIR, darner.toml (game_dir), game_dir.txt, beside darner.exe, ..\game, and ..\Game, or prompting once (supporting drag-and-drop) and saving game_dir to git-ignored darner.toml.
    • Supports optional CLI modes: build (release compile only), fast, diag (--features diagnostics), and check (Clippy, workspace tests, and cargo xtask policy).

How it was tested

  • Tested revision: 4d15827 (on upstream/main 57dea7f)
  • Commands and results:
    • Verified Build-Darner.cmd is pure ASCII, 5,545 bytes, and uses CRLF line endings (219 CRLF, 0 bare LF).
    • git diff --stat upstream/main...HEAD: 1 file added (Build-Darner.cmd, 219 lines).
    • Searched all 55 open PRs on TrustNo1/Darner for overlap with Build-Darner.cmd or one-click .cmd build launchers.
  • Coverage gaps:
    • No Rust/Windows toolchain is available in this container, so cargo build --release --locked -p darner, interactive execution on Windows cmd.exe, and the three Cargo CI gates + cargo xtask policy must still be run on Windows.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found.
    work error SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON , says this in pr when i submit, why
    Gemini 4 Hydrogen
    Ran for 19s

Action history
That error means Forgejo's PR submit button made a background request expecting JSON, and git.gtahub.st (which sits behind Cloudflare + Caddy) returned an HTML page () instead. On git.gtahub.st that happens for one of three reasons:
Transient 502 Bad Gateway from Caddy/Cloudflare (git.gtahub.st threw intermittent 502s right before your message).
Expired browser session / CSRF token causing Forgejo to return an HTML login or error page instead of JSON.
Cloudflare WAF / bot challenge blocking the request (HTML comments like or CLI flags in the description occasionally trigger WAF rules on form posts).
Your first PR (#130, pr/build-optimise) is already open on TrustNo1/Darner, and pr/build-cmd is not created yet. Refresh the compare page, drop the comment line under ## Contributor role (optional), and retry — or reply "post it" if you want me to submit that exact pr/build-cmd PR directly via Forgejo's API.

## Contributor role (optional) - Fluxer ID: 1577790829722873856 ## What it changes - Adds `Build-Darner.cmd` at the repository root (pure ASCII, CRLF line endings) for one-click building and launching on Windows: - Double-clicking builds `target\release\darner.exe` (`cargo build --release --locked -p darner`, automatically adding `%USERPROFILE%\.cargo\bin` to `PATH` when present) and launches `game_scarlett_master.exe` via `darner.exe play`. - Locates `game_scarlett_master.exe` without hardcoded user paths by checking `DARNER_GAME_DIR`, `darner.toml` (`game_dir`), `game_dir.txt`, beside `darner.exe`, `..\game`, and `..\Game`, or prompting once (supporting drag-and-drop) and saving `game_dir` to git-ignored `darner.toml`. - Supports optional CLI modes: `build` (release compile only), `fast`, `diag` (`--features diagnostics`), and `check` (Clippy, workspace tests, and `cargo xtask policy`). ## How it was tested - Tested revision: `4d15827` (on `upstream/main` `57dea7f`) - Commands and results: - Verified `Build-Darner.cmd` is pure ASCII, 5,545 bytes, and uses CRLF line endings (`219` CRLF, `0` bare LF). - `git diff --stat upstream/main...HEAD`: 1 file added (`Build-Darner.cmd`, 219 lines). - Searched all 55 open PRs on `TrustNo1/Darner` for overlap with `Build-Darner.cmd` or one-click `.cmd` build launchers. - Coverage gaps: - No Rust/Windows toolchain is available in this container, so `cargo build --release --locked -p darner`, interactive execution on Windows `cmd.exe`, and the three Cargo CI gates + `cargo xtask policy` must still be run on Windows. ## Checklist - [x] This PR contains one change based on `main`. - [ ] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found. work error SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON , says this in pr when i submit, why Gemini 4 Hydrogen Ran for 19s Action history That error means Forgejo's PR submit button made a background request expecting JSON, and git.gtahub.st (which sits behind Cloudflare + Caddy) returned an HTML page (<!DOCTYPE html>) instead. On git.gtahub.st that happens for one of three reasons: Transient 502 Bad Gateway from Caddy/Cloudflare (git.gtahub.st threw intermittent 502s right before your message). Expired browser session / CSRF token causing Forgejo to return an HTML login or error page instead of JSON. Cloudflare WAF / bot challenge blocking the request (HTML comments like <!-- ... --> or CLI flags in the description occasionally trigger WAF rules on form posts). Your first PR (#130, pr/build-optimise) is already open on TrustNo1/Darner, and pr/build-cmd is not created yet. Refresh the compare page, drop the <!-- ... --> comment line under ## Contributor role (optional), and retry — or reply "post it" if you want me to submit that exact pr/build-cmd PR directly via Forgejo's API.
Contributor

I tested 4d15827 on Windows with stub Cargo and Darner executables and a synthetic title path containing a space. With a valid game_dir.txt as the only path source, Build-Darner.cmd fast < nul fell through to the prompt and returned 2. Passing that same path via DARNER_GAME_DIR launched the stub as darner.exe play <path> and returned 0.

cmd.exe expands %TXT_DIR% for the whole block before set /p assigns it. I tested clearing that variable before the block and moving the call to :try_game_path after the block, guarded by if defined TXT_DIR. The game_dir.txt case then passed the expected path and returned 0. No actual Cargo build or title run was needed for this check. Build-Darner.cmd, lines 118–122

I tested `4d15827` on Windows with stub Cargo and Darner executables and a synthetic title path containing a space. With a valid `game_dir.txt` as the only path source, `Build-Darner.cmd fast < nul` fell through to the prompt and returned 2. Passing that same path via `DARNER_GAME_DIR` launched the stub as `darner.exe play <path>` and returned 0. `cmd.exe` expands `%TXT_DIR%` for the whole block before `set /p` assigns it. I tested clearing that variable before the block and moving the call to `:try_game_path` after the block, guarded by `if defined TXT_DIR`. The `game_dir.txt` case then passed the expected path and returned 0. No actual Cargo build or title run was needed for this check. [Build-Darner.cmd, lines 118–122](https://git.gtahub.st/davetheshrew/Darner/src/commit/4d15827129bb98988f66fb1879329485cec51b75/Build-Darner.cmd#L118-L122)
Owner

Review of 4d158271 (read only, not built or run). Hold: one confirmed bug to fix first.

What it does is right:

  • It's one new file. The build commands match the real profiles: --release, --profile fast, and --profile diag --features diagnostics all exist.
  • darner.exe play <path to game_scarlett_master.exe> is a valid start, since play takes the exe as its first argument.
  • The check mode runs the same gates as CI (clippy twice, tests, cargo xtask policy).
  • darner.toml is git-ignored, and the written [paths] game_dir = '...' matches darner.example.toml.
  • It merges cleanly with main (f3840d73).

Must fix:

  1. game_dir.txt is never used (confirmed by tyr0nsur above). Inside the if exist "%~dp0game_dir.txt" ( ... ) block, %TXT_DIR% is expanded when the whole block is parsed, before set /p fills it. So the call always gets an empty path, and the script falls through to the prompt. Move call :try_game_path "%TXT_DIR%" out of the block, guarded by if defined TXT_DIR (and clear TXT_DIR before the block), as tyr0nsur tested.

Should fix:
2. game_dir.txt isn't git-ignored and isn't documented anywhere else. Either drop it as a source (DARNER_GAME_DIR, darner.toml and the prompt cover it), or add it to .gitignore.
3. If a darner.toml already exists without game_dir, the prompt comes back on every launch and nothing is saved. Say so when that happens, or add the line.
4. A path containing ' would make the written TOML invalid (a literal string can't hold one). It's rare; a check before writing is enough.
5. Add one line about it to README's build section, and note that the default is the full release build (about 11 minutes) while fast takes 2 to 3.

Before merge: run it once on Windows with a real cargo build and a game start, using each path source (env, darner.toml, the prompt), plus check.

No testcall-ok yet: hold until item 1 is fixed. The script only builds in the clone and writes darner.toml there, so after the fix it is safe to call for a test.

Review of 4d158271 (read only, not built or run). Hold: one confirmed bug to fix first. **What it does is right:** - It's one new file. The build commands match the real profiles: `--release`, `--profile fast`, and `--profile diag --features diagnostics` all exist. - `darner.exe play <path to game_scarlett_master.exe>` is a valid start, since `play` takes the exe as its first argument. - The `check` mode runs the same gates as CI (clippy twice, tests, `cargo xtask policy`). - `darner.toml` is git-ignored, and the written `[paths] game_dir = '...'` matches `darner.example.toml`. - It merges cleanly with main (f3840d73). **Must fix:** 1. **`game_dir.txt` is never used** (confirmed by tyr0nsur above). Inside the `if exist "%~dp0game_dir.txt" ( ... )` block, `%TXT_DIR%` is expanded when the whole block is parsed, before `set /p` fills it. So the call always gets an empty path, and the script falls through to the prompt. Move `call :try_game_path "%TXT_DIR%"` out of the block, guarded by `if defined TXT_DIR` (and clear `TXT_DIR` before the block), as tyr0nsur tested. **Should fix:** 2. `game_dir.txt` isn't git-ignored and isn't documented anywhere else. Either drop it as a source (DARNER_GAME_DIR, `darner.toml` and the prompt cover it), or add it to `.gitignore`. 3. If a `darner.toml` already exists without `game_dir`, the prompt comes back on every launch and nothing is saved. Say so when that happens, or add the line. 4. A path containing `'` would make the written TOML invalid (a literal string can't hold one). It's rare; a check before writing is enough. 5. Add one line about it to README's build section, and note that the default is the full release build (about 11 minutes) while `fast` takes 2 to 3. **Before merge:** run it once on Windows with a real `cargo build` and a game start, using each path source (env, `darner.toml`, the prompt), plus `check`. No testcall-ok yet: hold until item 1 is fixed. The script only builds in the clone and writes `darner.toml` there, so after the fix it is safe to call for a test.
First-time contributor

I tested review items 3 and 4 on Windows 11 build 26300 with the unchanged Build-Darner.cmd from 4d15827129bb98988f66fb1879329485cec51b75. Cargo and Darner were argument-recording stubs, and the target was an empty fixture. Each second launch received an empty answer if prompted.

  • Ordinary folder, fresh config: both launches exited 0 and passed the exact target path. Only the first launch prompted.
  • Folder named O'Brien, fresh config: the first launch passed the exact path, exited 0 and printed “Saved game_dir”. Python 3.11 tomllib rejected the resulting darner.toml. The next launch prompted again, exited 2 and never called the Darner stub.
  • Existing valid config with an unrelated key and no game_dir: the first launch reached the stub and exited 0. The file stayed byte-for-byte identical, and the launcher gave no indication that the path would need to be entered again. The next launch prompted and exited 2.

These six launcher invocations cover configuration persistence. The requested real build and game-start checks remain outstanding.

I tested review items 3 and 4 on Windows 11 build 26300 with the unchanged `Build-Darner.cmd` from `4d15827129bb98988f66fb1879329485cec51b75`. Cargo and Darner were argument-recording stubs, and the target was an empty fixture. Each second launch received an empty answer if prompted. - Ordinary folder, fresh config: both launches exited 0 and passed the exact target path. Only the first launch prompted. - Folder named `O'Brien`, fresh config: the first launch passed the exact path, exited 0 and printed “Saved game_dir”. Python 3.11 `tomllib` rejected the resulting `darner.toml`. The next launch prompted again, exited 2 and never called the Darner stub. - Existing valid config with an unrelated key and no `game_dir`: the first launch reached the stub and exited 0. The file stayed byte-for-byte identical, and the launcher gave no indication that the path would need to be entered again. The next launch prompted and exited 2. These six launcher invocations cover configuration persistence. The requested real build and game-start checks remain outstanding.
Author
Contributor
  1. Moved call :try_game_path "%TXT_DIR%" outside the if exist "%~dp0game_dir.txt" block (clearing TXT_DIR first and guarding with if defined TXT_DIR) so game_dir.txt is expanded after set /p reads it.
  2. Added /game_dir.txt to .gitignore beside /darner.toml (also used by scripts/play-nvidia-framegen.ps1).
  3. Added a note when darner.toml already exists without a valid game_dir explaining that it wasn't overwritten and showing the line to add (or DARNER_GAME_DIR).
  4. Added a check for ' in GAME_DIR before writing darner.toml so paths containing a single quote never produce invalid TOML.
  5. Added one line for Build-Darner.cmd to the README build section noting the default release build (~11 minutes) vs fast (2 to 3 minutes).
1. Moved `call :try_game_path "%TXT_DIR%"` outside the `if exist "%~dp0game_dir.txt"` block (clearing `TXT_DIR` first and guarding with `if defined TXT_DIR`) so `game_dir.txt` is expanded after `set /p` reads it. 2. Added `/game_dir.txt` to `.gitignore` beside `/darner.toml` (also used by `scripts/play-nvidia-framegen.ps1`). 3. Added a note when `darner.toml` already exists without a valid `game_dir` explaining that it wasn't overwritten and showing the line to add (or `DARNER_GAME_DIR`). 4. Added a check for `'` in `GAME_DIR` before writing `darner.toml` so paths containing a single quote never produce invalid TOML. 5. Added one line for `Build-Darner.cmd` to the README build section noting the default release build (~11 minutes) vs `fast` (2 to 3 minutes).
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 'pr/build-cmd:davetheshrew-pr/build-cmd'
git switch 'davetheshrew-pr/build-cmd'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'davetheshrew-pr/build-cmd'
git switch 'davetheshrew-pr/build-cmd'
git rebase 'main'
git switch 'main'
git merge --ff-only 'davetheshrew-pr/build-cmd'
git switch 'davetheshrew-pr/build-cmd'
git rebase 'main'
git switch 'main'
git merge --no-ff 'davetheshrew-pr/build-cmd'
git switch 'main'
git merge --squash 'davetheshrew-pr/build-cmd'
git switch 'main'
git merge --ff-only 'davetheshrew-pr/build-cmd'
git switch 'main'
git merge 'davetheshrew-pr/build-cmd'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
4 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
TrustNo1/Darner!137
No description provided.