upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/build_runtime.ps1
diff options
context:
space:
mode:
authorNotRexed <therealnothingfn@gmail.com>2026-11-20 15:22:16 -0500
committerNotRexed <therealnothingfn@gmail.com>2026-11-20 15:22:16 -0500
commitdb0dc8bd5ebce6e2bc27d47085f7f104eb3037d3 (patch)
tree4fb3edca45f8b4dd3368c6ac2a0e4fdc8ed7065c /scripts/build_runtime.ps1
Initial commit: Leonida, build-it-yourself PC port groundwork
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V), asset export via rpf9-explorer's Core (submodule), PE loader and shim skeleton, and make_game.py, which builds from the user's own copy of the game. No game data, keys or executables are included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/build_runtime.ps1')
-rw-r--r--scripts/build_runtime.ps146
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/build_runtime.ps1 b/scripts/build_runtime.ps1
new file mode 100644
index 000000000..ffca056fd
--- /dev/null
+++ b/scripts/build_runtime.ps1
@@ -0,0 +1,46 @@
1# Builds runtime\build\gta6rt.exe with MSVC at BelowNormal priority, on half the cores.
2# Uses VS's CMake + Ninja when the "C++ CMake tools" component is installed, otherwise calls cl.exe directly.
3param([switch]$Debug)
4$ErrorActionPreference = "Stop"
5
6$root = Split-Path $PSScriptRoot -Parent
7$installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
8$vs = & "$installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
9if (-not $vs) { throw "Visual Studio with the C++ x64 tools wasn't found." }
10$vcvars = Join-Path $vs "VC\Auxiliary\Build\vcvars64.bat"
11$jobs = [Math]::Max(1, [int]([Environment]::ProcessorCount / 2))
12
13$src = Join-Path $root "runtime"
14$out = Join-Path $src "build"
15New-Item -ItemType Directory -Force $out | Out-Null
16
17$cmakeDir = Join-Path $vs "Common7\IDE\CommonExtensions\Microsoft\CMake"
18$cmake = Join-Path $cmakeDir "CMake\bin\cmake.exe"
19$ninja = Join-Path $cmakeDir "Ninja\ninja.exe"
20$cfg = if ($Debug) { "Debug" } else { "RelWithDebInfo" }
21
22if ((Test-Path $cmake) -and (Test-Path $ninja)) {
23 $body = @"
24"$cmake" -S "$src" -B "$out" -G Ninja "-DCMAKE_MAKE_PROGRAM=$ninja" -DCMAKE_BUILD_TYPE=$cfg || exit /b 1
25"$cmake" --build "$out" -j $jobs || exit /b 1
26"@
27} else {
28 # Keep this list in step with runtime\CMakeLists.txt.
29 $files = "src\main.cpp", "src\pe_loader.cpp", "shims\registry.cpp", "shims\xmem.cpp", "shims\d3d12_xs.cpp" | ForEach-Object { "`"$src\$_`"" }
30 $opt = if ($Debug) { "/Od /MDd" } else { "/O2 /MD" }
31 $body = @"
32cd /d "$out" || exit /b 1
33cl /nologo /std:c++20 /EHsc /W4 /permissive- /utf-8 /Zi $opt /MP$jobs /DWIN32_LEAN_AND_MEAN /DNOMINMAX /DUNICODE /D_UNICODE $($files -join ' ') /Fe:gta6rt.exe /link /OPT:NOREF psapi.lib || exit /b 1
34"@
35}
36
37# A .cmd file avoids cmd.exe's quote stripping on paths with spaces.
38$bat = Join-Path $out "_build.cmd"
39"@echo off`r`nset `"PATH=$installer;%PATH%`"`r`ncall `"$vcvars`" >nul || exit /b 1`r`n$body" | Set-Content -Encoding ascii $bat
40
41$p = Start-Process cmd.exe -ArgumentList "/c", "`"$bat`"" -NoNewWindow -PassThru
42$null = $p.Handle # keeps the exit code readable after WaitForExit
43try { $p.PriorityClass = "BelowNormal" } catch {}
44$p.WaitForExit()
45if ($p.ExitCode -ne 0) { throw "build failed ($($p.ExitCode))" }
46Write-Host "built $out\gta6rt.exe"