51 lines
1.5 KiB
PowerShell
51 lines
1.5 KiB
PowerShell
param(
|
|
[string]$OutputDir = "dist",
|
|
[string]$Version = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
|
|
|
|
if ([string]::IsNullOrWhiteSpace($Version)) {
|
|
$versionScript = Join-Path $PSScriptRoot "version.ps1"
|
|
if (Test-Path $versionScript) {
|
|
$Version = & $versionScript
|
|
} else {
|
|
$Version = "dev"
|
|
}
|
|
}
|
|
|
|
$targets = @(
|
|
@{ Name = "linux-amd64"; GOOS = "linux"; GOARCH = "amd64"; GOARM = "" },
|
|
@{ Name = "linux-arm64"; GOOS = "linux"; GOARCH = "arm64"; GOARM = "" },
|
|
@{ Name = "linux-armv7"; GOOS = "linux"; GOARCH = "arm"; GOARM = "7" },
|
|
@{ Name = "linux-mipsle"; GOOS = "linux"; GOARCH = "mipsle"; GOARM = ""; GOMIPS = "softfloat" }
|
|
)
|
|
|
|
foreach ($target in $targets) {
|
|
$env:CGO_ENABLED = "0"
|
|
$env:GOOS = $target.GOOS
|
|
$env:GOARCH = $target.GOARCH
|
|
if ($target.GOARM) {
|
|
$env:GOARM = $target.GOARM
|
|
} else {
|
|
Remove-Item Env:\GOARM -ErrorAction SilentlyContinue
|
|
}
|
|
if ($target.GOMIPS) {
|
|
$env:GOMIPS = $target.GOMIPS
|
|
} else {
|
|
Remove-Item Env:\GOMIPS -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
$out = Join-Path $OutputDir "klipperanywhere-agent-$($target.Name)"
|
|
Write-Host "Building $out"
|
|
go build -ldflags "-X main.agentVersion=$Version" -o $out ./cmd/agent
|
|
}
|
|
|
|
Remove-Item Env:\GOOS -ErrorAction SilentlyContinue
|
|
Remove-Item Env:\GOARCH -ErrorAction SilentlyContinue
|
|
Remove-Item Env:\GOARM -ErrorAction SilentlyContinue
|
|
Remove-Item Env:\GOMIPS -ErrorAction SilentlyContinue
|
|
Remove-Item Env:\CGO_ENABLED -ErrorAction SilentlyContinue
|