ContentsFoundations to FrontierBezhig

cp/cp01/run.ps1

All lab code. Download this file.

# Build and run the CP01 checks with Visual Studio's clang++ (C++20, warnings on).
#   .\run.ps1          every step
#   .\run.ps1 3        step 3 only
#   .\run.ps1 -Bench   time your one-pass code against the brute force (after step 9)
#   .\run.ps1 -Gate    the mastery gate's checks (gate\gate.h)
param([int]$Step = 0, [switch]$Bench, [switch]$Gate)

$clang = "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\Llvm\x64\bin\clang++.exe"
if (-not (Test-Path $clang)) { $clang = "clang++" }
$flags = @("-std=c++20", "-O2", "-Wall", "-Wextra", "-Wshadow", "-Wno-unused-parameter")

Push-Location $PSScriptRoot
try {
    if ($Gate) {
        & $clang @flags -o gate\gate_check.exe gate\gate_check.cpp
        if ($LASTEXITCODE -ne 0) { Write-Host "Build failed: read the FIRST error above."; exit 1 }
        .\gate\gate_check.exe
        exit $LASTEXITCODE
    }
    if ($Bench) {
        & $clang @flags -o bench.exe bench.cpp
        if ($LASTEXITCODE -ne 0) { Write-Host "Build failed: read the FIRST error above."; exit 1 }
        .\bench.exe
        exit $LASTEXITCODE
    }
    & $clang @flags -o check.exe check.cpp
    if ($LASTEXITCODE -ne 0) { Write-Host "Build failed: read the FIRST error above."; exit 1 }
    if ($Step -gt 0) { .\check.exe $Step } else { .\check.exe }
    exit $LASTEXITCODE
} finally {
    Pop-Location
}