35 lines
938 B
PowerShell
35 lines
938 B
PowerShell
param(
|
|
[switch]$NoRun
|
|
)
|
|
|
|
# Ensure script runs from repo root (where this script lives)
|
|
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $root
|
|
|
|
Write-Host "Working directory: $PWD"
|
|
|
|
# Build Debug configuration
|
|
Write-Host "Running: cmake --build build-msvc --config Debug"
|
|
$proc = Start-Process -FilePath cmake -ArgumentList '--build','build-msvc','--config','Debug' -NoNewWindow -Wait -PassThru
|
|
if ($proc.ExitCode -ne 0) {
|
|
Write-Error "Build failed with exit code $($proc.ExitCode)"
|
|
exit $proc.ExitCode
|
|
}
|
|
|
|
if ($NoRun) {
|
|
Write-Host "Build succeeded; skipping run because -NoRun was specified."
|
|
exit 0
|
|
}
|
|
|
|
$exePath = Join-Path $root "build-msvc\Debug\tetris.exe"
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Error "Executable not found: $exePath"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Launching: $exePath"
|
|
# Launch the executable and wait for it to exit so the caller sees its output.
|
|
& $exePath
|
|
|
|
exit $LASTEXITCODE
|