$ErrorActionPreference = "Stop" $gcc = "D:\Dev-Cpp\MinGW64\bin\gcc.exe" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path $temporaryExe = Join-Path ([System.IO.Path]::GetTempPath()) ` ("plsr_host_tests_{0}.exe" -f [System.Guid]::NewGuid().ToString("N")) $exitCode = 1 if (-not (Test-Path -LiteralPath $gcc)) { throw "Required compiler not found: $gcc" } $compileArguments = @( "-std=c99" "-Wall" "-Wextra" "-Werror" "-DPLSR_HOST_TEST" "-I$repoRoot\PLSR\Inc" "-I$repoRoot\PLSR\Src" "$repoRoot\PLSR\Src\plsr.c" "$repoRoot\PLSR\Src\plsr_planner.c" "$repoRoot\PLSR\Src\plsr_platform_f407.c" "$PSScriptRoot\test_plsr_host.c" "-o" $temporaryExe ) try { & $gcc @compileArguments if ($LASTEXITCODE -ne 0) { $exitCode = $LASTEXITCODE } else { & $temporaryExe $exitCode = $LASTEXITCODE } } finally { Remove-Item -LiteralPath $temporaryExe -Force -ErrorAction SilentlyContinue } exit $exitCode