From 5c6bc1b260b68569040a56e262f23658e16ddadf Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Sat, 16 Aug 2025 19:40:41 +0200 Subject: [PATCH] compile and run script --- build-debug-and-run.bat | 11 +++++++++++ build-debug-and-run.ps1 | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 build-debug-and-run.bat create mode 100644 build-debug-and-run.ps1 diff --git a/build-debug-and-run.bat b/build-debug-and-run.bat new file mode 100644 index 0000000..d5070a4 --- /dev/null +++ b/build-debug-and-run.bat @@ -0,0 +1,11 @@ +@echo off +REM Build and run debug executable for the Tetris project +SETLOCAL +cd /d "%~dp0" +cmake --build build-msvc --config Debug +if errorlevel 1 ( + echo Build failed. + exit /b %ERRORLEVEL% +) +"%~dp0build-msvc\Debug\tetris.exe" +ENDLOCAL diff --git a/build-debug-and-run.ps1 b/build-debug-and-run.ps1 new file mode 100644 index 0000000..125d423 --- /dev/null +++ b/build-debug-and-run.ps1 @@ -0,0 +1,34 @@ +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