param( [ValidateSet("Debug", "Release")] [string]$Configuration = "Release", [string]$BuildDirectory = "build-ninja" ) $ErrorActionPreference = "Stop" if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) { Write-Error "CMake was not found. Install CMake and ensure it is on PATH." exit 1 } $sourceDirectory = Split-Path -Parent $PSScriptRoot if ([System.IO.Path]::IsPathRooted($BuildDirectory)) { $buildPath = $BuildDirectory } else { $buildPath = Join-Path $sourceDirectory $BuildDirectory } $configureArgs = @( "-S", $sourceDirectory, "-B", $buildPath, "-G", "Ninja", "-DCMAKE_CXX_COMPILER=g++", "-DCMAKE_BUILD_TYPE=$Configuration" ) & cmake @configureArgs if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $compilationDatabase = Join-Path $buildPath "compile_commands.json" if (-not (Test-Path $compilationDatabase)) { Write-Error "CMake did not generate compile_commands.json at '$compilationDatabase'." exit 1 } Copy-Item -LiteralPath $compilationDatabase -Destination (Join-Path $sourceDirectory "compile_commands.json") -Force & cmake --build $buildPath --config $Configuration if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $outputPath = Join-Path $buildPath "bin\$($Configuration.ToLowerInvariant())\LumberJack.exe" Write-Host "Build complete: $outputPath" Write-Host "Updated compile_commands.json for clangd."