Scripts: add .env configuration support and launcher scripts #1389

Open
WTactic wants to merge 1 commit from upstream-pr/1399 into main
WTactic commented 2026-11-24 15:37:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by WTactic on 2026-11-24T15:37:48Z.


Allows developers to configure local paths and environment settings (such as GAME_PATH, XCL_DXC_DIR, XCL_DXC_THREADS, memory throttle overrides, and test thread limits) centrally in scripts/.env rather than manually passing repetitive command-line parameters.

What is in it

  • .gitignore: ignores local .env files across the tree.
  • scripts/.env.example: template documenting available configuration variables (GAME_PATH, XCL_DXC_DIR, XCL_DXC_THREADS, XCL_MEMORY_RESERVE_GB, XCL_MEMORY_WAIT_SECS, SMOKE_SECONDS, TEST_THREADS).
  • scripts/smoke.ps1: loads defaults from scripts/.env, allowing execution without mandatory -Game argument when GAME_PATH is defined.
  • scripts/test.ps1: loads settings from scripts/.env, supporting configurable TEST_THREADS.
  • scripts/test-native-stderr.tests.ps1: initializes environment defaults from scripts/.env.
  • scripts/run-game.ps1: generic helper script to launch any title with active .env configuration.
  • scripts/precompile-shaders.ps1: generic utility to precompile game shaders into the disk cache.

Tested

  • Hardware: NVIDIA GeForce RTX 4090, Intel Core i9-10850K @ 3.60 GHz (10 cores, 20 threads)
  • OS: Windows 11 x64 (NT 10.0.26200.0)
  • Rust: rustc 1.97.1 (8bab26f4f 2026-07-14)
  • Commands run and results:
    • powershell -ExecutionPolicy Bypass -File .\scripts\test-native-stderr.tests.ps1: passed (exit code 0)
    • cargo test --workspace -- --test-threads=4: 741 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests on this adapter:
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
  • Verified scripts/smoke.ps1 runs without -Game argument, picking up GAME_PATH from scripts/.env.

Regression run
Not applicable: this PR modifies only scripts and .gitignore, with zero changes to crates/xcl/src.

Not tested

  • Running test scripts on macOS / Linux (XCL is Windows-only).
  • AMD RDNA GPU adapter.

AI use

  • Google Antigravity Gemini 3.8 + custom harness: wrote the script enhancements, test runs, and prepared this description.
<!-- greyfinch-sync:ivall/xcl:issue:5475327237 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399). Originally posted by [WTactic](https://github.com/WTactic) on 2026-11-24T15:37:48Z. --- Allows developers to configure local paths and environment settings (such as `GAME_PATH`, `XCL_DXC_DIR`, `XCL_DXC_THREADS`, memory throttle overrides, and test thread limits) centrally in `scripts/.env` rather than manually passing repetitive command-line parameters. **What is in it** - `.gitignore`: ignores local `.env` files across the tree. - `scripts/.env.example`: template documenting available configuration variables (`GAME_PATH`, `XCL_DXC_DIR`, `XCL_DXC_THREADS`, `XCL_MEMORY_RESERVE_GB`, `XCL_MEMORY_WAIT_SECS`, `SMOKE_SECONDS`, `TEST_THREADS`). - `scripts/smoke.ps1`: loads defaults from `scripts/.env`, allowing execution without mandatory `-Game` argument when `GAME_PATH` is defined. - `scripts/test.ps1`: loads settings from `scripts/.env`, supporting configurable `TEST_THREADS`. - `scripts/test-native-stderr.tests.ps1`: initializes environment defaults from `scripts/.env`. - `scripts/run-game.ps1`: generic helper script to launch any title with active `.env` configuration. - `scripts/precompile-shaders.ps1`: generic utility to precompile game shaders into the disk cache. **Tested** - Hardware: NVIDIA GeForce RTX 4090, Intel Core i9-10850K @ 3.60 GHz (10 cores, 20 threads) - OS: Windows 11 x64 (NT 10.0.26200.0) - Rust: `rustc 1.97.1 (8bab26f4f 2026-07-14)` - Commands run and results: - `powershell -ExecutionPolicy Bypass -File .\scripts\test-native-stderr.tests.ps1`: passed (exit code 0) - `cargo test --workspace -- --test-threads=4`: 741 passed, 0 failed, 41 ignored - `SKIPPED` GPU tests on this adapter: - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`: no wave64 - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`: no wave64 - Verified `scripts/smoke.ps1` runs without `-Game` argument, picking up `GAME_PATH` from `scripts/.env`. **Regression run** Not applicable: this PR modifies only scripts and `.gitignore`, with zero changes to `crates/xcl/src`. **Not tested** - Running test scripts on macOS / Linux (XCL is Windows-only). - AMD RDNA GPU adapter. **AI use** - Google Antigravity Gemini 3.8 + custom harness: wrote the script enhancements, test runs, and prepared this description.
futurepro62 commented 2026-11-24 17:06:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:52:43Z.


Script check for this PR, since it has no test report yet. Tested exact head ed4d8d6.

Tested

  • Windows 11 Home 26300, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here).
  • powershell.exe -NoProfile -File scripts/test-native-stderr.tests.ps1 at the head: exit 0.
  • The same test file against main's scripts: also exit 0, as expected. The PR changes this test only so that it loads .env and finds its folder without $PSScriptRoot. It doesn't test the new behaviour.
  • No test covers the new .env loading (smoke.ps1, test.ps1, precompile-shaders.ps1, run-game.ps1). One thing to note: the test file now loads scripts/.env or the repo-root .env into its own process first. On a machine that has a .env, the test then runs with the developer's settings rather than a clean environment.

Not tested

  • run-game.ps1, precompile-shaders.ps1 and smoke.ps1 with a real .env, because I have no title to run them against.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7138346463 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1399#issuecomment-7138346463). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T16:52:43Z. --- Script check for this PR, since it has no test report yet. Tested exact head `ed4d8d6`. **Tested** - Windows 11 Home 26300, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here). - `powershell.exe -NoProfile -File scripts/test-native-stderr.tests.ps1` at the head: **exit 0**. - The same test file against `main`'s scripts: also exit 0, as expected. The PR changes this test only so that it loads `.env` and finds its folder without `$PSScriptRoot`. It doesn't test the new behaviour. - No test covers the new `.env` loading (`smoke.ps1`, `test.ps1`, `precompile-shaders.ps1`, `run-game.ps1`). One thing to note: the test file now loads `scripts/.env` or the repo-root `.env` into its own process first. On a machine that has a `.env`, the test then runs with the developer's settings rather than a clean environment. **Not tested** - `run-game.ps1`, `precompile-shaders.ps1` and `smoke.ps1` with a real `.env`, because I have no title to run them against. **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 17:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:01:43Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138574411 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#issuecomment-7138574411). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T17:01:43Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
RavenCurseBurg commented 2026-11-25 16:12:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T15:35:51Z.


I’ll check the .env defaults and the new launch helpers on this head using a synthetic native executable, so the child arguments, environment precedence and exit codes are observable without a game. Testing 1746a9e2da with OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ivall/xcl:comment:7167087747 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#issuecomment-7167087747). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T15:35:51Z. --- I’ll check the .env defaults and the new launch helpers on this head using a synthetic native executable, so the child arguments, environment precedence and exit codes are observable without a game. Testing 1746a9e2da8be8c2e0df46d7f5320c072566e003 with OpenAI Codex (GPT-6).
RavenCurseBurg commented 2026-11-25 16:12:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T15:52:55Z.


Tested 1746a9e2da8be8c2e0df46d7f5320c072566e003 on Windows 11 with Windows PowerShell 5.1 and PowerShell 7.6.9. When a fixture xcl.exe returned 23, both run-game.ps1 and precompile-shaders.ps1 reported success to the caller. Exit 0 can cause an automation to treat a failed launch as successful.

I pushed a fix and regression tests to the RavenCurseBurg/xcl fork, branch scripts/propagate-launch-helper-exits, commit 0bb5997ace40ed3c3d411f271323a22c1dc15ef2. After the fix both scripts returned 23. When a stub build failed with 17, run-game.ps1 stopped before launch and returned 17. The new regression test and the existing native-stderr tests passed in both shells. All 16 independent checks for environment precedence, paths with spaces, arguments and exit codes passed.

Tests used disposable files and native fixtures. No games or GPU workload. OpenAI Codex (GPT-6) ran the checks and prepared the patch and report.

Rebase for the reported smoke conflict

I reproduced the conflict between 1746a9e2da8b and main b49be1836844 in the parameter list of scripts/smoke.ps1. I preserved this PR's optional game, duration and launcher parameters alongside main's -OutDir. Rebased author commit. The second commit also carries the previous launch-helper exit-code fix as a separate commit. Main is an ancestor of the rebased series.

I ran launch-helpers.tests.ps1, test-native-stderr.tests.ps1, test-smoke-artifacts.tests.ps1 and smoke-title.tests.ps1 on that second commit under Windows PowerShell 5.1 and PowerShell 7. All eight runs exited 0. Four additional CLI runs combined -OutDir with a private .env and a stand-in launcher emitting see the log:. Both shells honored the configured game and duration, then the explicit overrides, and preserved the synthetic log and report bytes in the saved artifacts. No game, GPU workload or workspace build. OpenAI Codex (GPT-6) prepared the rebase and ran the checks.

I also checked review 6069065597 on this series. Neither memory variable is read by the Rust runtime. The example assigned both, and the launcher echoed the unused reserve value beside the effective thread count. A separate third commit removes those assignments and the reserve banner field. git grep -n -E 'XCL_MEMORY_(RESERVE_GB|WAIT_SECS)' -- crates scripts has no remaining matches. I reran launch-helpers.tests.ps1 with XCL_DXC_THREADS=2; all three cases passed in each shell. The third commit changes launcher text and configuration examples only.

<!-- greyfinch-sync:ivall/xcl:comment:7167395459 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#issuecomment-7167395459). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T15:52:55Z. --- Tested `1746a9e2da8be8c2e0df46d7f5320c072566e003` on Windows 11 with Windows PowerShell 5.1 and PowerShell 7.6.9. When a fixture xcl.exe returned 23, both run-game.ps1 and precompile-shaders.ps1 reported success to the caller. Exit 0 can cause an automation to treat a failed launch as successful. I pushed a fix and regression tests to the `RavenCurseBurg/xcl` fork, branch `scripts/propagate-launch-helper-exits`, commit `0bb5997ace40ed3c3d411f271323a22c1dc15ef2`. After the fix both scripts returned 23. When a stub build failed with 17, run-game.ps1 stopped before launch and returned 17. The new regression test and the existing native-stderr tests passed in both shells. All 16 independent checks for environment precedence, paths with spaces, arguments and exit codes passed. Tests used disposable files and native fixtures. No games or GPU workload. OpenAI Codex (GPT-6) ran the checks and prepared the patch and report. **Rebase for the reported smoke conflict** I reproduced the conflict between `1746a9e2da8b` and main `b49be1836844` in the parameter list of `scripts/smoke.ps1`. I preserved this PR's optional game, duration and launcher parameters alongside main's `-OutDir`. [Rebased author commit](https://github.com/RavenCurseBurg/xcl/commit/c52c5da402343c7905a35f0f6614ac9b7ffd4182). The [second commit](https://github.com/RavenCurseBurg/xcl/commit/a5d5548d05d558657aecade4f32770359a06bf5b) also carries the previous launch-helper exit-code fix as a separate commit. Main is an ancestor of the rebased series. I ran `launch-helpers.tests.ps1`, `test-native-stderr.tests.ps1`, `test-smoke-artifacts.tests.ps1` and `smoke-title.tests.ps1` on that second commit under Windows PowerShell 5.1 and PowerShell 7. All eight runs exited 0. Four additional CLI runs combined `-OutDir` with a private `.env` and a stand-in launcher emitting `see the log:`. Both shells honored the configured game and duration, then the explicit overrides, and preserved the synthetic log and report bytes in the saved artifacts. No game, GPU workload or workspace build. OpenAI Codex (GPT-6) prepared the rebase and ran the checks. I also checked review 6069065597 on this series. Neither memory variable is read by the Rust runtime. The example assigned both, and the launcher echoed the unused reserve value beside the effective thread count. A [separate third commit](https://github.com/RavenCurseBurg/xcl/commit/525e925832af995e53d5df8415a719cee693bb59) removes those assignments and the reserve banner field. `git grep -n -E 'XCL_MEMORY_(RESERVE_GB|WAIT_SECS)' -- crates scripts` has no remaining matches. I reran `launch-helpers.tests.ps1` with `XCL_DXC_THREADS=2`; all three cases passed in each shell. The third commit changes launcher text and configuration examples only.
luckyteagirl commented 2026-11-26 05:38:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:38:35Z.

Review: COMMENTED


Could the template omit XCL_MEMORY_RESERVE_GB and XCL_MEMORY_WAIT_SECS until the DXC admission code reads them? At this head, neither variable is consumed by XCL: dxc.rs initializes its reserve to 6 GiB, offline precompile sets it internally to 2 GiB, and the memory wait has fixed behavior. Copying the example therefore does not uncap workers or make admission immediate as its comments promise. run-game.ps1 also prints a reserve value it has not applied. Removing the entries and display would keep the example accurate. Source review at exact head 1746a9e2da8be8c2e0df46d7f5320c072566e003; no runtime test. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6069065597 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#pullrequestreview-6069065597). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T05:38:35Z. **Review:** COMMENTED --- Could the template omit `XCL_MEMORY_RESERVE_GB` and `XCL_MEMORY_WAIT_SECS` until the DXC admission code reads them? At this head, neither variable is consumed by XCL: `dxc.rs` initializes its reserve to 6 GiB, offline precompile sets it internally to 2 GiB, and the memory wait has fixed behavior. Copying the example therefore does not uncap workers or make admission immediate as its comments promise. `run-game.ps1` also prints a reserve value it has not applied. Removing the entries and display would keep the example accurate. Source review at exact head `1746a9e2da8be8c2e0df46d7f5320c072566e003`; no runtime test. AI-assisted review with Codex.
DavidM1911 commented 2026-11-26 06:06:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:13:13Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7183288352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#issuecomment-7183288352). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:13:13Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
Foniass commented 2026-12-01 05:37:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:37:50Z.


Triage (#1607) – head 1746a9e

No open or merged PR adds .env support to the scripts (#1500 is a separate preset launcher, not the same change).
Problems in the diff: scripts/.env.example sets XCL_MEMORY_RESERVE_GB and XCL_MEMORY_WAIT_SECS, which nothing in crates/ reads (the reserve on main is the RESERVE_GB static in dxc.rs), so those lines and the run-game.ps1 'Memory Reserve' print do nothing. main now has its own scripts/precompile-shaders.ps1 (-Package , -Pipelines, ...); this PR adds a file at the same path with a different interface, which is the conflict and would replace the existing script.
smoke.ps1 and test.ps1 now pull any XCL_* variable from a local .env, so a smoke block can be produced with switches that are not visible in the command; precompile-shaders.ps1/run-game.ps1 overwrite already-set variables while smoke.ps1/test.ps1 do not.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301972397 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1399#issuecomment-7301972397). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:37:50Z. --- **Triage (#1607)** – head 1746a9e No open or merged PR adds .env support to the scripts (#1500 is a separate preset launcher, not the same change). Problems in the diff: scripts/.env.example sets XCL_MEMORY_RESERVE_GB and XCL_MEMORY_WAIT_SECS, which nothing in crates/ reads (the reserve on main is the RESERVE_GB static in dxc.rs), so those lines and the run-game.ps1 'Memory Reserve' print do nothing. main now has its own scripts/precompile-shaders.ps1 (-Package <rpf>, -Pipelines, ...); this PR adds a file at the same path with a different interface, which is the conflict and would replace the existing script. smoke.ps1 and test.ps1 now pull any XCL_* variable from a local .env, so a smoke block can be produced with switches that are not visible in the command; precompile-shaders.ps1/run-game.ps1 overwrite already-set variables while smoke.ps1/test.ps1 do not. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1399:upstream-pr/1399'
git switch 'upstream-pr/1399'

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 'upstream-pr/1399'
git switch 'upstream-pr/1399'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1399'
git switch 'upstream-pr/1399'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1399'
git switch 'main'
git merge --squash 'upstream-pr/1399'
git switch 'main'
git merge --ff-only 'upstream-pr/1399'
git switch 'main'
git merge 'upstream-pr/1399'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1389
No description provided.