Harden Windows icon resource generation

This commit is contained in:
Stu Leak 2026-01-07 15:29:02 -05:00
parent db381b92df
commit 39c5cc5c7d
3 changed files with 34 additions and 4 deletions

View File

@ -71,6 +71,9 @@ if [ -f "$RC_FILE" ]; then
else
echo "WARNING: windres not found; Windows icon will not be embedded in the EXE"
fi
if [ ! -f "$SYMBOL_FILE" ]; then
echo "WARNING: windres did not produce $SYMBOL_FILE; icon may be missing"
fi
fi
# Set Windows build environment

View File

@ -177,9 +177,23 @@ echo.
REM ----------------------------
REM Embed Windows icon (if windres is available)
REM ----------------------------
set WINDRES_PATH=
where windres >nul 2>&1
if %ERRORLEVEL% equ 0 (
windres scripts\videotools.rc -O coff -o videotools_windows_amd64.syso
for /f "delims=" %%I in ('where windres') do set WINDRES_PATH=%%I
) else if exist "C:\msys64\mingw64\bin\windres.exe" (
set WINDRES_PATH=C:\msys64\mingw64\bin\windres.exe
) else if exist "C:\msys64\usr\bin\windres.exe" (
set WINDRES_PATH=C:\msys64\usr\bin\windres.exe
) else if exist "C:\MinGW\bin\windres.exe" (
set WINDRES_PATH=C:\MinGW\bin\windres.exe
)
if not "%WINDRES_PATH%"=="" (
"%WINDRES_PATH%" scripts\videotools.rc -O coff -o videotools_windows_amd64.syso
if not exist videotools_windows_amd64.syso (
echo [WARN] windres did not produce videotools_windows_amd64.syso; icon may be missing
)
) else (
echo [WARN] windres not found; Windows icon will not be embedded in the EXE
)

View File

@ -60,9 +60,22 @@ Write-Host ""
$rcFile = Join-Path $PROJECT_ROOT "scripts\videotools.rc"
$sysoFile = Join-Path $PROJECT_ROOT "videotools_windows_amd64.syso"
if (Test-Path $rcFile) {
$windres = Get-Command windres -ErrorAction SilentlyContinue
if ($windres) {
& $windres.Path $rcFile -O coff -o $sysoFile | Out-Null
$windresCandidates = @()
$windresCmd = Get-Command windres -ErrorAction SilentlyContinue
if ($windresCmd) {
$windresCandidates += $windresCmd.Path
}
$windresCandidates += @(
"C:\msys64\mingw64\bin\windres.exe",
"C:\msys64\usr\bin\windres.exe",
"C:\MinGW\bin\windres.exe"
)
$windresPath = $windresCandidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
if ($windresPath) {
& $windresPath $rcFile -O coff -o $sysoFile | Out-Null
if (-not (Test-Path $sysoFile)) {
Write-Host "⚠️ windres did not produce $sysoFile; icon may be missing" -ForegroundColor Yellow
}
} else {
Write-Host "⚠️ windres not found; Windows icon will not be embedded in the EXE" -ForegroundColor Yellow
}