# PowerShell build script for Pineapple Steam Recording Exporter param( [switch]$Release, [switch]$Clean, [switch]$Help ) if ($Help) { Write-Host "Usage: .\build.ps1 [-Release] [-Clean] [-Help]" Write-Host "" Write-Host "Options:" Write-Host " -Release Build in Release mode (default: Debug)" Write-Host " -Clean Clean build directory before building" Write-Host " -Help Show this help message" Write-Host "" exit 0 } $BuildType = if ($Release) { "Release" } else { "Debug" } Write-Host "Setting up MSYS2 UCRT64 build environment..." -ForegroundColor Green Write-Host "Build type: $BuildType" -ForegroundColor Cyan # Set MSYS2 paths $MSYS2_ROOT = "C:\msys64" $UCRT64_ROOT = "$MSYS2_ROOT\ucrt64" $env:PATH = "$UCRT64_ROOT\bin;$MSYS2_ROOT\usr\bin;$env:PATH" # Check if MSYS2 is available if (-not (Test-Path "$UCRT64_ROOT\bin\gcc.exe")) { Write-Host "Error: MSYS2 UCRT64 environment not found at $UCRT64_ROOT" -ForegroundColor Red Write-Host "Please install MSYS2 and the required packages." -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 } # Set Qt6 environment variables $Qt6_DIR = "$UCRT64_ROOT\lib\cmake\Qt6" $CMAKE_PREFIX_PATH = $UCRT64_ROOT Write-Host "Checking for required packages..." -ForegroundColor Green if (-not (Test-Path $Qt6_DIR)) { Write-Host "Error: Qt6 not found. Please install Qt6 packages." -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } Write-Host "Creating build directory..." -ForegroundColor Green if ($Clean -and (Test-Path "build")) { Write-Host "Cleaning previous build..." -ForegroundColor Yellow Remove-Item -Recurse -Force "build" } if (-not (Test-Path "build")) { New-Item -ItemType Directory -Path "build" | Out-Null } Set-Location "build" try { Write-Host "Configuring with CMake..." -ForegroundColor Green $cmakeArgs = @( "-G", "Ninja" "-DCMAKE_BUILD_TYPE=$BuildType" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" "-DQt6_DIR=$Qt6_DIR" "-DCMAKE_C_COMPILER=$UCRT64_ROOT\bin\gcc.exe" "-DCMAKE_CXX_COMPILER=$UCRT64_ROOT\bin\g++.exe" ".." ) & cmake $cmakeArgs if ($LASTEXITCODE -ne 0) { Write-Host "CMake configuration failed!" -ForegroundColor Red exit 1 } Write-Host "Building..." -ForegroundColor Green & cmake --build . --config $BuildType --parallel if ($LASTEXITCODE -ne 0) { Write-Host "Build failed!" -ForegroundColor Red exit 1 } Write-Host "Build completed successfully!" -ForegroundColor Green Write-Host "Build type: $BuildType" -ForegroundColor Cyan } finally { Set-Location .. }