<# .SYNOPSIS Build every target (or one target) listed in project.json. .DESCRIPTION Reads resolved.targets from project.json. cc65 targets compile every .c and .s file in the target's source folders; BASIC targets tokenize the listing with petcat. Targets with a disk section also get a disk image built with c1541. Outputs go to build/ (ignored by Git). Exit codes: 0 = built, 1 = build error, 2 = a required tool is missing. .EXAMPLE pwsh -File tools/build.ps1 pwsh -File tools/build.ps1 -Target c64 #> [CmdletBinding()] param([string]$Target) . (Join-Path $PSScriptRoot 'lib.ps1') try { $project = Get-ProjectConfig $done = @{} foreach ($t in Get-ProjectTargets $project $Target) { Invoke-TargetBuild $project $t $done } Write-Host "Build complete." } catch [MissingToolException] { Write-Host $_.Exception.Message -ForegroundColor Yellow exit 2 } catch { Write-Host "BUILD FAILED: $($_.Exception.Message)" -ForegroundColor Red exit 1 }