Files
deskview/build.ps1
T
2026-10-27 17:58:28 +08:00

32 lines
1.0 KiB
PowerShell

# Build viewsagent for Windows (no console window).
# Usage: .\build.ps1
# Requires: Go 1.24+ and gcc from MSYS2 mingw-w64 (C:\msys64\mingw64\bin).
$ErrorActionPreference = "Stop"
$mingw = "C:\msys64\mingw64\bin"
if (Test-Path $mingw) {
$env:Path = "$mingw;" + $env:Path
}
if (-not (Get-Command gcc -ErrorAction SilentlyContinue)) {
Write-Error "gcc not found. Fyne needs cgo; install mingw-w64-gcc first (see scripts/setup-gcc.sh)."
}
$env:CGO_ENABLED = "1"
if (-not (Test-Path "bin")) {
New-Item -ItemType Directory -Path "bin" | Out-Null
}
Write-Host "==> go test" -ForegroundColor Cyan
go test ./...
if ($LASTEXITCODE -ne 0) { Write-Error "tests failed, build aborted." }
Write-Host "==> go build" -ForegroundColor Cyan
go build -trimpath -ldflags "-H windowsgui -s -w" -o "bin\viewsagent.exe" .\cmd\viewsagent
if ($LASTEXITCODE -ne 0) { Write-Error "build failed." }
$mb = [math]::Round((Get-Item "bin\viewsagent.exe").Length / 1MB, 1)
Write-Host "==> done: bin\viewsagent.exe ($mb MB)" -ForegroundColor Green