scorpiox-bot-plugin-sglang
←build.ps1text
45 lines · 1 KBHEADBlameDownload
1# build.ps1 - Windows MinGW-w64 static build for plugin_sglang
2#
3# Usage (from the repo root, PowerShell):
4# powershell -ExecutionPolicy Bypass -File build.ps1
5
6$ErrorActionPreference = "Stop"
7$ScriptDir = $PSScriptRoot
8Push-Location $ScriptDir
9try {
10 $Src = Join-Path $ScriptDir "src\plugin_sglang.c"
11 $Out = Join-Path $ScriptDir "plugin_sglang.exe"
12 $Cc = "x86_64-w64-mingw32-gcc"
13
14 if (-not (Test-Path $Src)) { throw "source not found: $Src" }
15
16 if (-not (Get-Command $Cc -ErrorAction SilentlyContinue)) {
17 if (Test-Path "C:\gcc16\bin\gcc.exe") {
18 $Cc = "C:\gcc16\bin\gcc.exe"
19 } elseif (Get-Command gcc -ErrorAction SilentlyContinue) {
20 $Cc = "gcc"
21 } else {
22 throw "no C compiler found (need x86_64-w64-mingw32-gcc or gcc)"
23 }
24 }
25
26 Write-Host "==> building plugin_sglang.exe with $Cc"
27 & $Cc -O2 -std=c99 -Wall -Wextra -static -Wno-overlength-strings -o $Out $Src
28 if ($LASTEXITCODE -ne 0) { throw "compile failed (exit $LASTEXITCODE)" }
29 if (-not (Test-Path $Out)) { throw "build produced no output" }
30
31 $bytes = [System.IO.File]::ReadAllBytes($Out)
32 if ($bytes.Length -lt 2 -or $bytes[0] -ne 0x4D -or $bytes[1] -ne 0x5A) {
33 throw "output is not a PE executable (missing MZ header)"
34 }
35
36 Write-Host "==> metadata check"
37 & $Out --meta
38 if ($LASTEXITCODE -ne 0) { throw "--meta failed" }
39
40 $size = (Get-Item $Out).Length
41 Write-Host ""
42 Write-Host "Built $Out ($size bytes)"
43} finally {
44 Pop-Location
45}