From 8b12cb6439e3af34cb30fb18bd8f39fd0ef959d8 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 24 Nov 2026 17:55:32 +0500 Subject: [PATCH 1/5] runtime: forward options when launching the packaged image AI-assisted: yes --- README.md | 2 ++ make_game.py | 15 +++++++++++++-- tests/test_make_game_platform.py | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e5554881..e10a320b3 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,8 @@ skips the build on Windows. On Linux, run `/gta6rt.sh --dry-run` to inspect the packaged title's imports, then `/gta6rt.sh --init` to check TLS callbacks and DLL initialization. Use `/gta6rt.sh --run` for startup. These commands use the package in `game_path.txt`, the port's `overlay` for writes, and Vulkan by default. +To use the packaged image with extra runtime options, add `--packaged` before the mode. For example, +run `/gta6rt.sh --packaged --run --trace "Z:$PWD/startup.jsonl"` to record startup in your current directory. When the Vulkan backend is selected with `LEONIDA_D3D12=vulkan`, the packaged runtime finds the translated shaders in `/shaders/spirv` using `shader_path.txt` beside `gta6rt.exe`. Set `LEONIDA_SHADERS` to use another directory. diff --git a/make_game.py b/make_game.py index ff5ff7676..8e87cc64a 100644 --- a/make_game.py +++ b/make_game.py @@ -2210,7 +2210,18 @@ def wine_launcher(out: str, work: str, image: str) -> str: return f"""#!/bin/sh # Starts the Windows build of the loader with Wine. WINE picks another one, e.g. a Proton build's bin/wine. here=$(dirname "$(readlink -f "$0")") -if [ "$#" -eq 1 ] && {{ [ "$1" = --dry-run ] || [ "$1" = --init ] || [ "$1" = --run ]; }}; then +use_package= +if [ "${{1-}}" = --packaged ]; then + shift + use_package=1 +elif [ "$#" -eq 1 ]; then + case "$1" in --dry-run|--init|--run) use_package=1 ;; esac +fi +if [ "$use_package" ]; then + case "${{1-}}" in + --dry-run|--init|--run) mode=$1; shift ;; + *) printf 'Use --packaged with --dry-run, --init or --run.\\n' >&2; exit 2 ;; + esac game=$(cat "$here/game_path.txt" && printf .) || exit 1 cd "${{game%.}}" || exit 1 image={shlex.quote(image)} @@ -2220,7 +2231,7 @@ def wine_launcher(out: str, work: str, image: str) -> str: fi # Wine maps the Unix filesystem root to Z:. The game reads from its package and writes to the port's overlay. {moved_catalog} export LEONIDA_D3D12="${{LEONIDA_D3D12:-vulkan}}" - set -- "$1" "./$image" --overlay "Z:$here/overlay" + set -- "$mode" "./$image" --overlay "Z:$here/overlay" "$@" fi exec "${{WINE:-wine}}" "$here/gta6rt.exe" "$@" """ diff --git a/tests/test_make_game_platform.py b/tests/test_make_game_platform.py index aaf6ef491..227ccf1c6 100644 --- a/tests/test_make_game_platform.py +++ b/tests/test_make_game_platform.py @@ -271,6 +271,16 @@ def test_wine_first_boot_uses_the_packaged_game_and_shader_paths(self): self.assertEqual(json.loads(result)[2:], ["D:/custom", "trace"]) result = subprocess.check_output([launcher, "--run", "other.exe", "--", "two words"], cwd=self.root, env=env) self.assertEqual(json.loads(result)[:2], [self.root, ["--run", "other.exe", "--", "two words"]]) + result = subprocess.check_output( + [launcher, "--packaged", "--run", "--trace", "Z:/trace file.jsonl", "--", "two words"], + cwd=self.root, env=env) + self.assertEqual(json.loads(result)[:2], [ + self.game, ["--run", "./" + image, "--overlay", "Z:" + self.out + "/overlay", + "--trace", "Z:/trace file.jsonl", "--", "two words"], + ]) + invalid = subprocess.run([launcher, "--packaged"], cwd=self.root, env=env, capture_output=True, text=True) + self.assertEqual(invalid.returncode, 2) + self.assertIn("Use --packaged", invalid.stderr) work = os.path.join(self.out, "Shader cache '$HOME'") make_game.runtime(self.game, self.out, {"expected_exe": image}, self.build, work=work) From 150a67b0174606ba85a7477489d7e7d250a14c85 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 24 Nov 2026 17:55:54 +0500 Subject: [PATCH 2/5] runtime: reject a missing or empty packaged game path AI-assisted: yes --- make_game.py | 5 ++++- tests/test_make_game_platform.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/make_game.py b/make_game.py index 8e87cc64a..ed8048cdc 100644 --- a/make_game.py +++ b/make_game.py @@ -2222,7 +2222,10 @@ def wine_launcher(out: str, work: str, image: str) -> str: --dry-run|--init|--run) mode=$1; shift ;; *) printf 'Use --packaged with --dry-run, --init or --run.\\n' >&2; exit 2 ;; esac - game=$(cat "$here/game_path.txt" && printf .) || exit 1 + if ! game=$(cat "$here/game_path.txt" 2>/dev/null && printf .) || [ "$game" = . ]; then + printf 'Missing package path in %s/game_path.txt\\n' "$here" >&2 + exit 1 + fi cd "${{game%.}}" || exit 1 image={shlex.quote(image)} if [ ! -f "./$image" ]; then diff --git a/tests/test_make_game_platform.py b/tests/test_make_game_platform.py index 227ccf1c6..f7fc4a9ba 100644 --- a/tests/test_make_game_platform.py +++ b/tests/test_make_game_platform.py @@ -254,6 +254,16 @@ def test_wine_first_boot_uses_the_packaged_game_and_shader_paths(self): env = dict(os.environ, WINE=sys.executable) env.pop("LEONIDA_D3D12", None) env.pop("LEONIDA_SHADERS", None) + path_file = os.path.join(self.out, "game_path.txt") + with open(path_file, "rb") as f: + path_bytes = f.read() + with open(os.path.join(self.root, image), "wb"), open(path_file, "wb"): + pass + empty_path = subprocess.run([launcher, "--run"], cwd=self.root, env=env, capture_output=True, text=True) + self.assertEqual(empty_path.returncode, 1) + self.assertIn("Missing package path", empty_path.stderr) + with open(path_file, "wb") as f: + f.write(path_bytes) missing = subprocess.run([launcher, "--run"], cwd=self.root, env=env, capture_output=True, text=True) self.assertNotEqual(missing.returncode, 0) self.assertIn(image, missing.stderr) From e54a85a92b0d32ae5a45d88fb803f028f6473c48 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 24 Nov 2026 17:57:26 +0500 Subject: [PATCH 3/5] runtime: stop when the Wine launcher path cannot be resolved AI-assisted: yes --- make_game.py | 6 +++++- tests/test_make_game_platform.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/make_game.py b/make_game.py index ed8048cdc..697ca86ab 100644 --- a/make_game.py +++ b/make_game.py @@ -2209,7 +2209,11 @@ def wine_launcher(out: str, work: str, image: str) -> str: """ return f"""#!/bin/sh # Starts the Windows build of the loader with Wine. WINE picks another one, e.g. a Proton build's bin/wine. -here=$(dirname "$(readlink -f "$0")") +launcher=$(readlink -f "$0") || {{ + printf 'Could not resolve runtime launcher %s\\n' "$0" >&2 + exit 1 +}} +here=$(dirname "$launcher") || exit 1 use_package= if [ "${{1-}}" = --packaged ]; then shift diff --git a/tests/test_make_game_platform.py b/tests/test_make_game_platform.py index f7fc4a9ba..cb163640d 100644 --- a/tests/test_make_game_platform.py +++ b/tests/test_make_game_platform.py @@ -264,6 +264,10 @@ def test_wine_first_boot_uses_the_packaged_game_and_shader_paths(self): self.assertIn("Missing package path", empty_path.stderr) with open(path_file, "wb") as f: f.write(path_bytes) + unresolved = subprocess.run([launcher, "--run", "other.exe"], cwd=self.root, + env=dict(env, PATH=self.root), capture_output=True, text=True) + self.assertEqual(unresolved.returncode, 1) + self.assertIn("Could not resolve runtime launcher", unresolved.stderr) missing = subprocess.run([launcher, "--run"], cwd=self.root, env=env, capture_output=True, text=True) self.assertNotEqual(missing.returncode, 0) self.assertIn(image, missing.stderr) From fa87fc568836759a08c1a82300c5bae6bf3e8e51 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 24 Nov 2026 17:58:19 +0500 Subject: [PATCH 4/5] build: discover Windows tools in paths with brackets AI-assisted: yes --- scripts/build_runtime.ps1 | 5 +++-- tests/test_build_runtime_fallback.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/build_runtime.ps1 b/scripts/build_runtime.ps1 index 394c24287..05668c53b 100644 --- a/scripts/build_runtime.ps1 +++ b/scripts/build_runtime.ps1 @@ -25,9 +25,10 @@ function Invoke-ToolProbe([string]$Exe, [string[]]$ProbeArgs) { } function Find-BuildTool([string]$Preferred, [string]$CommandName, [scriptblock]$Validate) { - if ($Preferred -and (Test-Path $Preferred)) { return $Preferred } + if ($Preferred -and (Test-Path -LiteralPath $Preferred -PathType Leaf)) { return $Preferred } foreach ($cmd in @(Get-Command $CommandName -CommandType Application -All -ErrorAction SilentlyContinue)) { - if ($cmd.Source -and ($cmd.Source -match "\.(exe|cmd|bat)$") -and (Test-Path $cmd.Source) -and (& $Validate $cmd.Source)) { + if ($cmd.Source -and ($cmd.Source -match "\.(exe|cmd|bat)$") -and + (Test-Path -LiteralPath $cmd.Source -PathType Leaf) -and (& $Validate $cmd.Source)) { return $cmd.Source } } diff --git a/tests/test_build_runtime_fallback.py b/tests/test_build_runtime_fallback.py index 236afe91b..a062f19bc 100644 --- a/tests/test_build_runtime_fallback.py +++ b/tests/test_build_runtime_fallback.py @@ -160,8 +160,8 @@ def run_probe(vs_dir: Path, path_dirs: list[Path]) -> tuple[str, str]: root = Path(tmp) vs_empty = root / "vs_empty" msys_dir = root / "msys_bin" - native_cmake_dir = root / "native_cmake_bin" - native_ninja_dir = root / "native_ninja_bin" + native_cmake_dir = root / "native [cmake] bin" + native_ninja_dir = root / "native [ninja] bin" for d in (vs_empty, msys_dir, native_cmake_dir, native_ninja_dir): d.mkdir() @@ -194,7 +194,7 @@ def run_probe(vs_dir: Path, path_dirs: list[Path]) -> tuple[str, str]: self.assertEqual(ninja, "") # 4) VS bundled CMake + Ninja present -> must prefer VS over PATH. - vs_full = root / "vs_full" + vs_full = root / "vs [full]" vs_cmake = vs_full / "Common7" / "IDE" / "CommonExtensions" / "Microsoft" / "CMake" / "CMake" / "bin" / "cmake.exe" vs_ninja = vs_full / "Common7" / "IDE" / "CommonExtensions" / "Microsoft" / "CMake" / "Ninja" / "ninja.exe" vs_cmake.parent.mkdir(parents=True) From ff1d98f1f043a8904230be383f5b696342076a40 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 24 Nov 2026 18:00:32 +0500 Subject: [PATCH 5/5] build: verify both files required for runtime startup AI-assisted: yes --- scripts/build_runtime.ps1 | 6 ++++++ tests/test_build_runtime_cmake.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/build_runtime.ps1 b/scripts/build_runtime.ps1 index 05668c53b..6cc7e958d 100644 --- a/scripts/build_runtime.ps1 +++ b/scripts/build_runtime.ps1 @@ -170,4 +170,10 @@ while (-not $p.HasExited) { Emit-NewLogLines -Offset ([ref]$outOff) -Path $stdoutLog Emit-NewLogLines -Offset ([ref]$errOff) -Path $stderrLog if ($p.ExitCode -ne 0) { throw "build failed ($($p.ExitCode))" } +foreach ($artifact in @("gta6rt.exe", "gta6rt_tls_host.dll")) { + $built = Join-Path $out $artifact + if (-not (Test-Path -LiteralPath $built -PathType Leaf)) { + throw "The runtime build did not produce $built." + } +} Write-Output "built $out\gta6rt.exe" diff --git a/tests/test_build_runtime_cmake.py b/tests/test_build_runtime_cmake.py index c7685a521..e851718f1 100644 --- a/tests/test_build_runtime_cmake.py +++ b/tests/test_build_runtime_cmake.py @@ -25,7 +25,14 @@ class Recorder { for (int i = 0; i + 1 < args.Length; ++i) if (args[i] == "-S" && !Directory.Exists(args[i + 1])) return 9; } - return Environment.GetEnvironmentVariable("LEONIDA_CMAKE_FAIL") == stage ? 7 : 0; + string fail = Environment.GetEnvironmentVariable("LEONIDA_CMAKE_FAIL"); + if (fail == stage) return 7; + if (build) { + File.WriteAllText(Path.Combine(args[1], "gta6rt.exe"), "synthetic runtime"); + if (fail != "missing-tls") + File.WriteAllText(Path.Combine(args[1], "gta6rt_tls_host.dll"), "synthetic TLS host"); + } + return 0; } } ''' @@ -113,6 +120,15 @@ def test_native_and_batch_cmake_paths_and_exit_codes(self): self.assertEqual(built.read_text(encoding="utf-8-sig").splitlines(), ["--build", str(out), "-j", "3"]) + def test_build_without_the_tls_host_is_reported_as_failed(self): + with tempfile.TemporaryDirectory(dir=self.base) as tmp: + result, _, out, _ = self.run_build(Path(tmp), ".exe", "missing-tls") + self.assertTrue((out / "gta6rt.exe").is_file()) + self.assertEqual(result.returncode, 1, (result.stdout + result.stderr).decode(errors="replace")) + self.assertIn(b"The runtime build did not produce", result.stderr) + self.assertIn(b"gta6rt_tls_host.dll", result.stderr) + self.assertNotIn(b"built ", result.stdout) + if __name__ == "__main__": unittest.main()