mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
08fa3765ba
A default MinGW build dynamically imports three non-system DLLs (SDL2.dll, libgcc_s_seh-1.dll, libstdc++-6.dll) that get bundled side-by-side. On a user machine with a mismatched-architecture copy of one of those earlier on the DLL search path, Windows loads the wrong one and the process dies at launch with 0xc000007b (STATUS_INVALID_IMAGE_FORMAT) before any of our code runs. Add PSX_STATIC_RUNTIME (default ON for MinGW Release/MinSizeRel): link -static -static-libgcc -static-libstdc++ and pull SDL2 from the pkg-config --static line (libSDL2.a + its Windows system-lib chain) instead of the import lib. The resulting exe imports only Windows system DLLs, so it runs from any folder and 0xc000007b from a mismatched runtime DLL becomes structurally impossible. package_release.ps1 no longer bundles the runtime DLLs and instead asserts self-containment via objdump (fails the build if any non-system import remains). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
109 lines
3.9 KiB
PowerShell
109 lines
3.9 KiB
PowerShell
param(
|
|
[string]$Version = "v0.1.0-alpha",
|
|
[string]$BuildDir = "runtime/build-release"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$Root = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
$BuildPath = Join-Path $Root $BuildDir
|
|
$StageRoot = Join-Path $Root "release-stage"
|
|
$Stage = Join-Path $StageRoot "PSXRecomp-windows-x64"
|
|
$ZipPath = Join-Path $Root ("PSXRecomp-{0}-windows-x64.zip" -f $Version)
|
|
$MingwBin = "C:\msys64\mingw64\bin"
|
|
|
|
$env:PATH = "$MingwBin;$env:PATH"
|
|
|
|
cmake -S (Join-Path $Root "runtime") -B $BuildPath -G Ninja -DCMAKE_BUILD_TYPE=Release -DPSX_DEBUG_TOOLS=OFF
|
|
cmake --build $BuildPath --target psx-runtime -j $env:NUMBER_OF_PROCESSORS
|
|
|
|
if (Test-Path $StageRoot) {
|
|
Remove-Item -Recurse -Force $StageRoot
|
|
}
|
|
New-Item -ItemType Directory -Force $Stage | Out-Null
|
|
New-Item -ItemType Directory -Force (Join-Path $Stage "saves") | Out-Null
|
|
|
|
Copy-Item (Join-Path $BuildPath "psx-runtime.exe") (Join-Path $Stage "PSXRecomp.exe")
|
|
Copy-Item (Join-Path $Root "README.md") $Stage
|
|
Copy-Item (Join-Path $Root "LICENSE") $Stage
|
|
if (Test-Path (Join-Path $Root "RELEASE_NOTES.md")) {
|
|
Copy-Item (Join-Path $Root "RELEASE_NOTES.md") $Stage
|
|
}
|
|
|
|
# The Release build is statically linked (PSX_STATIC_RUNTIME defaults ON for
|
|
# MinGW Release in runtime.cmake), so the exe imports ONLY Windows system DLLs
|
|
# — no SDL2.dll / libgcc_s_seh-1.dll / libstdc++-6.dll to bundle. Shipping
|
|
# those side-by-side was the cause of the 0xc000007b launch crash on user
|
|
# machines that had a mismatched copy earlier on the DLL search path.
|
|
#
|
|
# Assert self-containment rather than trust it: fail packaging if the exe
|
|
# imports any non-system DLL.
|
|
$objdump = Join-Path $MingwBin "objdump.exe"
|
|
$imports = & $objdump -p (Join-Path $Stage "PSXRecomp.exe") |
|
|
Select-String "DLL Name: (.+)" | ForEach-Object { $_.Matches[0].Groups[1].Value.Trim() }
|
|
$systemDlls = @("kernel32.dll","user32.dll","gdi32.dll","shell32.dll","msvcrt.dll",
|
|
"advapi32.dll","ws2_32.dll","comdlg32.dll","dbghelp.dll","ole32.dll",
|
|
"oleaut32.dll","winmm.dll","imm32.dll","version.dll","setupapi.dll",
|
|
"dinput8.dll","rpcrt4.dll","hid.dll","cfgmgr32.dll")
|
|
$nonSystem = $imports | Where-Object { $systemDlls -notcontains $_.ToLower() }
|
|
if ($nonSystem) {
|
|
throw "Release exe is NOT self-contained — imports non-system DLL(s): $($nonSystem -join ', ')"
|
|
}
|
|
Write-Host "Verified self-contained: imports only system DLLs ($($imports.Count) total)"
|
|
|
|
@"
|
|
; PSXRecomp input mapping. PSX buttons are active when any listed source is pressed.
|
|
; Sources use SDL/Xbox names: a,b,x,y,back,start,leftshoulder,rightshoulder,
|
|
; lefttrigger,righttrigger,dpup,dpdown,dpleft,dpright,leftx-/leftx+/lefty-/lefty+.
|
|
|
|
[controller]
|
|
enabled = true
|
|
device = 0
|
|
deadzone = 12000
|
|
|
|
[mapping]
|
|
up = dpup,lefty-
|
|
down = dpdown,lefty+
|
|
left = dpleft,leftx-
|
|
right = dpright,leftx+
|
|
cross = a
|
|
circle = b
|
|
square = x
|
|
triangle = y
|
|
l1 = leftshoulder
|
|
r1 = rightshoulder
|
|
l2 = lefttrigger
|
|
r2 = righttrigger
|
|
start = start
|
|
select = back
|
|
"@ | Set-Content -Encoding ASCII (Join-Path $Stage "input.ini")
|
|
|
|
@"
|
|
PSXRecomp $Version
|
|
|
|
This package does not include a PlayStation BIOS, game disc image, generated
|
|
game source, save data, or any copyrighted Sony/game assets.
|
|
|
|
First launch:
|
|
1. Run PSXRecomp.exe.
|
|
2. Select your legally obtained SCPH1001.BIN BIOS when prompted.
|
|
|
|
The selected BIOS path is saved in bios.cfg next to the executable. Delete that
|
|
file if you want to pick a different BIOS later.
|
|
|
|
This framework package is BIOS-only. Game-specific PSXRecomp releases use the
|
|
same BIOS picker and additionally prompt for the required game disc image.
|
|
|
|
Keyboard and Xbox-style controller defaults are documented in README.md.
|
|
Controller mappings are configurable in input.ini.
|
|
|
|
Memory cards are stored in the saves directory.
|
|
"@ | Set-Content -Encoding ASCII (Join-Path $Stage "START_HERE.txt")
|
|
|
|
if (Test-Path $ZipPath) {
|
|
Remove-Item -Force $ZipPath
|
|
}
|
|
Compress-Archive -Path (Join-Path $Stage "*") -DestinationPath $ZipPath -Force
|
|
|
|
Write-Host "Wrote $ZipPath"
|