From aed1cb62e79a484afdb0866c09be2ab71e6fe15b Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Sat, 22 Nov 2025 16:57:05 +0100 Subject: [PATCH] Add DLL sweep to build-production batch script --- build-production.bat | 29 +++++++++++++++++++++++++++-- build-production.ps1 | 44 ++++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/build-production.bat b/build-production.bat index 6d6dd6f..0b9d2b6 100644 --- a/build-production.bat +++ b/build-production.bat @@ -65,8 +65,15 @@ if exist "FreeSans.ttf" copy "FreeSans.ttf" "dist\TetrisGame\" REM Copy SDL DLLs (if available) - SDL_image no longer needed echo Copying dependencies... -if exist "vcpkg_installed\x64-windows\bin\SDL3.dll" copy "vcpkg_installed\x64-windows\bin\SDL3.dll" "dist\TetrisGame\" -if exist "vcpkg_installed\x64-windows\bin\SDL3_ttf.dll" copy "vcpkg_installed\x64-windows\bin\SDL3_ttf.dll" "dist\TetrisGame\" +set "PackageDir=dist\TetrisGame" +set "copiedDependencies=0" + +call :CopyDependencyDir "build-release\vcpkg_installed\x64-windows\bin" +call :CopyDependencyDir "vcpkg_installed\x64-windows\bin" + +if "%copiedDependencies%"=="0" ( + echo Warning: No dependency DLLs were copied. Ensure vcpkg release binaries exist. +) REM Create launcher batch file echo @echo off > "dist\TetrisGame\Launch-Tetris.bat" @@ -84,3 +91,21 @@ echo The game is ready for distribution! echo Users can run tetris.exe or Launch-Tetris.bat echo. pause +goto :eof + +:CopyDependencyDir +set "dllDir=%~1" +if not exist "%dllDir%" goto :eof +echo Scanning %dllDir% for DLLs... +for %%F in ("%dllDir%\*.dll") do ( + if exist "%%~fF" ( + if exist "%PackageDir%\%%~nxF" ( + copy /Y "%%~fF" "%PackageDir%\%%~nxF" >nul + ) else ( + copy "%%~fF" "%PackageDir%\" >nul + ) + echo Copied %%~nxF + set "copiedDependencies=1" + ) +) +goto :eof diff --git a/build-production.ps1 b/build-production.ps1 index 7be74ea..01d3f9b 100644 --- a/build-production.ps1 +++ b/build-production.ps1 @@ -155,32 +155,28 @@ foreach ($font in $FontFiles) { } # Step 7: Copy dependencies (DLLs) -Write-Info "Copying SDL3 dependencies..." -$VcpkgInstalled = Join-Path "vcpkg_installed" "x64-windows" -if (Test-Path $VcpkgInstalled) { - $DllPaths = @( - Join-Path $VcpkgInstalled "bin\SDL3.dll", - Join-Path $VcpkgInstalled "bin\SDL3_ttf.dll" - ) - - $CopiedDlls = 0 - foreach ($dll in $DllPaths) { - if (Test-Path $dll) { - Copy-Item $dll $PackageDir - $dllName = Split-Path $dll -Leaf - Write-Success "Copied $dllName" - $CopiedDlls++ - } else { - Write-Warning "Warning: $dll not found" +Write-Info "Copying runtime dependencies..." +$buildVcpkgBin = Join-Path (Join-Path $BuildDir "vcpkg_installed") "x64-windows/bin" +$repoVcpkgBin = "vcpkg_installed/x64-windows/bin" +$DependencyDirs = @($buildVcpkgBin, $repoVcpkgBin) | Where-Object { $_ } | Select-Object -Unique + +$copiedNames = @{} +foreach ($dir in $DependencyDirs) { + if (!(Test-Path $dir)) { continue } + Write-Info "Scanning $dir for DLLs..." + $dlls = Get-ChildItem -Path $dir -Filter "*.dll" -ErrorAction SilentlyContinue + foreach ($dll in $dlls) { + $dest = Join-Path $PackageDir $dll.Name + Copy-Item $dll.FullName $dest -Force + if (-not $copiedNames.ContainsKey($dll.Name)) { + Write-Success "Copied $($dll.Name)" + $copiedNames[$dll.Name] = $true } } - - if ($CopiedDlls -eq 0) { - Write-Warning "No SDL DLLs found in vcpkg installation" - Write-Warning "You may need to manually copy SDL3 DLLs to the package" - } -} else { - Write-Warning "vcpkg installation not found. SDL DLLs must be manually copied." +} + +if ($copiedNames.Count -eq 0) { + Write-Warning "No dependency DLLs were copied. Please ensure vcpkg has been built for Release." } # Step 8: Create README and batch file for easy launching