| 1 | # build.ps1 - build plugin_opencode_login.exe on a Windows box with MinGW-w64. |
| 2 | # |
| 3 | # powershell -ExecutionPolicy Bypass -File build.ps1 |
| 4 | # powershell -ExecutionPolicy Bypass -File build.ps1 -Cc C:\gcc16\mingw64\bin\gcc.exe |
| 5 | # |
| 6 | # The generated page header (src/ui_html.h) is produced from src/ui.html by |
| 7 | # tools/gen_ui.py. If python3 is not on the box, the checked-in header is used |
| 8 | # as-is; the test suite is the place that proves the two agree. |
| 9 | |
| 10 | param( |
| 11 | [string]$Cc = "x86_64-w64-mingw32-gcc", |
| 12 | [string]$Out = "plugin_opencode_login.exe" |
| 13 | ) |
| 14 | |
| 15 | $ErrorActionPreference = "Stop" |
| 16 | $Root = Split-Path -Parent $MyInvocation.MyCommand.Path |
| 17 | Set-Location $Root |
| 18 | |
| 19 | if (Get-Command python3 -ErrorAction SilentlyContinue) { |
| 20 | python3 tools/gen_ui.py |
| 21 | } elseif (Get-Command python -ErrorAction SilentlyContinue) { |
| 22 | python tools/gen_ui.py |
| 23 | } else { |
| 24 | Write-Host "no python on this box - using the checked-in src/ui_html.h" |
| 25 | } |
| 26 | |
| 27 | Write-Host "==> building $Out with $Cc" |
| 28 | & $Cc -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -static -I src ` |
| 29 | -o $Out src/plugin_opencode_login.c |
| 30 | if ($LASTEXITCODE -ne 0) { throw "build failed ($LASTEXITCODE)" } |
| 31 | |
| 32 | Write-Host "==> --meta" |
| 33 | & ".\$Out" --meta |
| 34 | Write-Host "==> done: $Out" |