Skip to content

make_game: write gta6rt.cmd on Windows so the port starts on the package in game_path.txt - #8325

Draft
TriiiEyes wants to merge 4 commits into
ItsNotRexed:mainfrom
TriiiEyes:build-2813-windows-launcher
Draft

TriiiEyes wants to merge 4 commits into
ItsNotRexed:mainfrom
TriiiEyes:build-2813-windows-launcher

Conversation

@TriiiEyes

@TriiiEyes TriiiEyes commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: BUILD-2813 (claim, pointer in #7694)

Depends on: none. It builds on main only and branches from 8575d36e. #7019 and #5278 edit the same runtime() / launcher code in make_game.py, so whichever lands second may need a rebase.

What and why

On Windows, make_game.py writes game_path.txt into the port folder, but nothing reads it. Only gta6rt.sh, the Wine launcher, does. gta6rt.exe started on its own prints usage and exits 2, so the port has no documented way to start on Windows.

The runtime stage now also writes <out>\gta6rt.cmd, the Windows counterpart of gta6rt.sh:

  • The mode on its own (--dry-run, --init or --run): enters the folder named in game_path.txt and runs gta6rt.exe <mode> .\<expected_exe> --overlay <out>\overlay. It sets LEONIDA_D3D12=vulkan unless that is already set.
  • A moved port folder, in every mode: when the translated shaders are inside the port folder and the whole folder has moved since the build, the launcher sets LEONIDA_SHADERS to the shader folder in its new location, unless LEONIDA_SHADERS is already set. This happens before the mode check, so a run with extra launcher arguments finds the shaders too, instead of the stale absolute path in shader_path.txt. The runtime prefers LEONIDA_SHADERS over shader_path.txt (runtime/shims/d3d12_vulkan_device.cpp, configured_shader_directory()). A --work outside the port folder (e.g. on another drive) is unaffected, because shader_path.txt keeps naming it.
  • Any other arguments go to gta6rt.exe unchanged. That includes an explicitly empty second argument, so gta6rt.cmd --run "" --trace t.jsonl passes through, as gta6rt.sh's "$#" -eq 1 does.
  • The exit code of gta6rt.exe comes back.
  • Paths:
    • game_path.txt is read in code page 65001 and the console's code page is put back, so non-ASCII paths work.
    • The package folder is entered with pushd and left with popd, so a UNC package path works. The exit code is kept across popd.
  • The generated comments expand no arguments. cmd expands %-references before it recognizes rem.
  • Split drives: --out and --work on different drives (e.g. D: / E:) are handled with the existing path_is_within() helper. The launcher text is built before gta6rt.cmd is opened, so a failure leaves any previous file intact.
  • Directory guard: runtime() refuses a directory named gta6rt.cmd before copying anything, as the make_game: Reject directories at runtime installation file paths #6734 guard does for the other outputs.

Files:

  • make_game.py: windows_launcher(), plus runtime() and the logged hint.
  • README.md: one paragraph on starting the port on Windows.
  • tests/test_make_game_platform.py
  • runtime/CMakeLists.txt and runtime/test/check_packaged_launcher.py: a CTest, run_packaged_launcher, that runs the real gta6rt and the tiny_game stand-in through the generated launcher.

Tested

This head, 0481e346: no test was run. Test runs are on hold on our side until the game launches and runs stably. The last commit (258c6dba..0481e346) moves the moved-port shader fallback ahead of the mode check and adds a test for it. What was checked at this SHA:

  • py_compile of make_game.py and tests/test_make_game_platform.py, and git diff --check 8575d36e..0481e346.
  • An in-process inspection of the generated launcher text:
    • the moved-port line appears once, before the mode check, and not in :package; the console's code page is restored before the mode check;
    • generating with --out on D: and --work on E: succeeds and has no moved-port line;
    • no rem line references an argument;
    • no command starts with cd;
    • the loader command is followed by set "rc=%ERRORLEVEL%", popd, exit /b %rc%;
    • the explicit-"" check is a command.

Not verified live:

  • entering a UNC package folder (pushd / popd);
  • passthrough with an explicitly empty second argument;
  • the shader lookup after moving the port folder and passing extra launcher arguments.

Tests for all three are included, not yet run: the UNC one uses \\localhost\<drive>$ when that share is reachable and skips otherwise.

Not verified at all: a retail boot. We have no local copy of the game, so neither this launcher nor the shader lookup has run against the real executable here.

Earlier evidence, at 0463ae19 (the same launcher before the review fixes, also on 8575d36e). Platform: Windows 11, NVIDIA RTX 4070 (driver 621.24), clang-cl 23.1.5 + lld-link with the MSVC 14.44 CRT / Windows SDK 10.0.26100.

  • CTest run_packaged_launcher, run_tiny_game* and gta6rt_rejects_*: 14/14 pass. run_packaged_launcher used game and port folder names with non-ASCII characters and & ( ) % !.
  • Python tests/test_make_game_*.py and tests/test_docs_*.py: 427 pass, 4 skipped. 5 files fail identically on unmodified 8575d36e:
  • Controls: the new and updated tests fail against the make_game.py on main; with the code-page switch removed, the CTest fails.

Each revision after 0463ae19 went through an independent static code review by a second AI reviewer, which cleared this head.

AI-assisted: yes (Claude Code; independent review by Codex)

Checklist

  • 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. (not a translator change)

🤖 Generated with Claude Code

TriiiEyes and others added 4 commits November 23, 2026 08:09
…age in game_path.txt

The runtime stage wrote game_path.txt on every platform, but only the Linux gta6rt.sh read it. On Windows nothing
did: gta6rt.exe started with no arguments, or with only a mode, printed its usage and exited 2, and the logged hint
covered --dry-run alone. A user who carried it on to --run got the overlay inside the package folder
(<game>\overlay, main.cpp's default) and the host D3D12 device instead of Vulkan.

The stage now writes gta6rt.cmd next to gta6rt.exe on Windows, the counterpart of gta6rt.sh: --dry-run, --init or
--run on its own changes to the package in game_path.txt and starts gta6rt.exe on the manifest's expected_exe with
--overlay <out>\overlay and LEONIDA_D3D12=vulkan unless set; it points LEONIDA_SHADERS at the moved catalog when the
port folder moved with its work folder inside; any other arguments go to gta6rt.exe as given. cmd reads a batch file
and set /p input in the console code page, so game_path.txt (UTF-8) and the names written into the script are read
in code page 65001, which is then restored. The script is CRLF, as .gitattributes keeps *.cmd. The logged hint is
now `& '<out>\gta6rt.cmd' --dry-run`, and README says how to start the port on Windows.

Tests, synthetic only (no game files):
- tests/test_make_game_platform.py: the generated gta6rt.cmd runs with a copy of cmd.exe standing in for
  gta6rt.exe, in a console of its own (OEM code page), with non-ASCII and & ( ) % ! in the game and port folders:
  argv, working directory, LEONIDA_* defaults and overrides, pass-through, a missing executable, a moved port and
  the exit code. A structural check (CRLF, no BOM, % doubled) runs on every platform; the first-load hint names
  the launcher.
- runtime/test/check_packaged_launcher.py (CTest run_packaged_launcher, Windows hosts): the runtime stage installs
  the built gta6rt.exe and gta6rt_tls_host.dll with tiny_game.exe as the package's executable; gta6rt.cmd
  --dry-run and --init exit 0, and --run reports GAME: as the package, writes to <out>\overlay and returns the
  game's exit code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icit ""

Addresses the three findings of the Codex review of 0463ae1 (BUILD-2813):

- P1, split --out/--work drives: windows_launcher() compared the shader
  folder with --out through os.path.commonpath, which raises ValueError
  for paths on different drives (the D: output / E: work layout), and
  runtime() had already opened gta6rt.cmd for writing. It now uses the
  existing path_is_within() helper (False across drives or UNC shares),
  and runtime() builds the launcher text before opening the file, so a
  failure leaves any previous gta6rt.cmd as it was.
- P2, UNC package folders: cmd cannot make a UNC path its current
  directory with cd /d. The launcher enters the package with pushd,
  which maps a temporary drive letter for a UNC path, keeps the
  loader's exit code in rc, runs popd (also on the missing-executable
  path) and exits with rc.
- P2, explicit empty second argument: %~2 is empty both without a
  second argument and with "". The launcher also checks "%2" for "", so
  `gta6rt.cmd --run "" --trace trace.jsonl` passes through to
  gta6rt.exe with its trace flags, as gta6rt.sh's "$#" -eq 1 does.

Also: runtime() now checks that gta6rt.cmd is not a directory before
copying anything on Windows, as it already did for gta6rt.sh elsewhere
(the guard from ItsNotRexed#6734).

Tests added to tests/test_make_game_platform.py (written, not run: the
director postponed test runs): explicit "" passthrough and a UNC package
via the administrative share (skipped when not reachable) in the
executing Windows test; structural checks for pushd/popd and the empty
second argument; --out and --work on different drives; a directory
named gta6rt.cmd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…commands

Addresses the Codex re-review of 5008bc5 (BUILD-2813):

- P1: the generated rem above the second-argument checks mentioned %~2
  and "%2". cmd expands %-references before it recognizes rem, so a
  quoted second argument carrying &, | or > could be parsed as syntax
  on a line meant as a comment. The rem now names no argument; the
  explanation of the two checks moved into a Python comment in
  windows_launcher().
- P2: the structural test searched the whole generated text, so
  assertNotIn("cd /d") and text.index("popd") also matched the rem
  lines. It now splits the text into executable command lines (no rem
  lines, no labels), asserts that no rem line references an argument,
  that no command starts with cd, and that the loader command is
  followed exactly by set "rc=%ERRORLEVEL%", popd and exit /b %rc%.

Not run (test runs are postponed by the director): the new assertions
and the earlier ones. Checked: both files compile, and the generated
text was inspected in-process (no argument references in rem lines, no
cd command, the loader-return sequence as above, the explicit "" check
present).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The moved-port LEONIDA_SHADERS fallback sat in the launcher's :package
block, so it applied only to `gta6rt.cmd --dry-run|--init|--run` on
their own. With any other arguments (passthrough), a port folder moved
after the build left the runtime reading the stale absolute path in
shader_path.txt, and the first compute PSO found no translated shaders.

The fallback, with its own code-page 65001 window for the UTF-8 names,
now runs right after `set "here=%~dp0"`, before the mode dispatch, and
is removed from :package. It still applies only when the shaders are
inside the port folder, the folder has moved, and LEONIDA_SHADERS is not
already set; arguments pass through unchanged. A split-drive --work is
unaffected (shader_path.txt keeps naming it).

Test added to the executing Windows launcher test (written, not run:
test runs are on hold): after the port moves, a passthrough run keeps
its arguments and gets the moved shader folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant