42 lines
1.4 KiB
PowerShell
42 lines
1.4 KiB
PowerShell
# Builds the firmware simulation DLL and runs the headless smoke test.
|
|||
|
|
# Windows PowerShell 5.1 compatible. From the repo root:
|
||
|
|
#
|
||
|
|
# .\sim\build.ps1 configure (first time) + build + smoke test
|
||
|
|
# .\sim\build.ps1 -NoTest build only
|
||
|
|
# .\sim\build.ps1 -Clean wipe sim\build first
|
||
|
|
#
|
||
|
|
# Output: sim\build\hexapod_sim.dll (loaded by the Unity project) and
|
||
|
|
# sim\build\sim_smoke.exe. Exit code = build failure (1) or failed checks.
|
||
|
|
param(
|
||
|
|
[switch]$NoTest,
|
||
|
|
[switch]$Clean
|
||
|
|
)
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
|
||
|
|
$simDir = $PSScriptRoot
|
||
|
|
$buildDir = Join-Path $simDir 'build'
|
||
|
|
|
||
|
|
# g++/cmake/ninja: use what's on PATH, else Strawberry Perl's bundled toolchain.
|
||
|
|
if (-not (Get-Command cmake -ErrorAction SilentlyContinue) -or -not (Get-Command g++ -ErrorAction SilentlyContinue)) {
|
||
|
|
$strawberry = 'C:\Strawberry\c\bin'
|
||
|
|
if (Test-Path $strawberry) {
|
||
|
|
$env:PATH = "$strawberry;$env:PATH"
|
||
|
|
} else {
|
||
|
|
Write-Error 'cmake and g++ not found. Install Strawberry Perl (bundles g++, cmake, ninja) or add a MinGW-w64 toolchain to PATH.'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($Clean -and (Test-Path $buildDir)) { Remove-Item $buildDir -Recurse -Force }
|
||
|
|
|
||
|
|
if (-not (Test-Path (Join-Path $buildDir 'build.ninja'))) {
|
||
|
|
cmake -S $simDir -B $buildDir -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||
|
|
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||
|
|
}
|
||
|
|
|
||
|
|
cmake --build $buildDir
|
||
|
|
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||
|
|
|
||
|
|
if (-not $NoTest) {
|
||
|
|
& (Join-Path $buildDir 'sim_smoke.exe')
|
||
|
|
exit $LASTEXITCODE
|
||
|
|
}
|