scorpiox-bot-plugin-logs
←build.ps1text
32 lines · 1 KBHEADBlameDownload
1# build.ps1 - native Windows build of plugin_logs with MinGW-w64 or MSVC-style cl.
2#
3# .\build.ps1 # build plugin_logs.exe with gcc (MinGW-w64)
4# .\build.ps1 -Compiler cl # build with cl.exe
5# .\build.ps1 -Test # build then run the offline checks
6param(
7 [string]$Compiler = "gcc",
8 [switch]$Test
9)
10
11$ErrorActionPreference = "Stop"
12$src = "src\plugin_logs.c"
13$out = "plugin_logs.exe"
14$inc = "-Isrc"
15
16if ($Compiler -eq "cl") {
17 Write-Host "==> MSVC build"
18 & cl /nologo /O2 /W3 /I src /Fe:$out $src
19} else {
20 Write-Host "==> MinGW-w64 build"
21 & x86_64-w64-mingw32-gcc -O2 -std=c99 -Wall -Wextra -static $inc -o $out $src
22}
23if ($LASTEXITCODE -ne 0) { throw "build failed" }
24
25$head = [System.IO.File]::ReadAllBytes((Resolve-Path $out))[0..1]
26if ($head[0] -ne 0x4D -or $head[1] -ne 0x5A) { throw "artifact is not a PE image" }
27Write-Host ("==> built {0} ({1} bytes)" -f $out, (Get-Item $out).Length)
28
29& $out --meta
30if ($Test) {
31 Write-Host "==> tests need a POSIX shell; run tests/run.sh under Git Bash or WSL"
32}