Files
2026-06-20 18:18:50 +08:00

57 lines
1.6 KiB
PowerShell

#!/usr/bin/env pwsh
# Embalming Girl Server - Build Script
# Usage:
# .\build.ps1 # Build for Windows
# .\build.ps1 linux # Cross-compile for Linux
# .\build.ps1 all # Build for both platforms
param([string]$Target = "windows")
$ErrorActionPreference = "Stop"
$ProjectName = "embalming_girl_server"
Write-Host "=== Embalming Girl Server Build ===" -ForegroundColor Cyan
function Build-Windows {
Write-Host "[Building] Windows amd64..." -ForegroundColor Yellow
$env:GOOS = "windows"
$env:GOARCH = "amd64"
go build -o "$ProjectName.exe" .
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] $ProjectName.exe" -ForegroundColor Green
} else {
Write-Host "[FAILED] Windows build" -ForegroundColor Red
exit 1
}
}
function Build-Linux {
Write-Host "[Building] Linux amd64..." -ForegroundColor Yellow
$env:GOOS = "linux"
$env:GOARCH = "amd64"
$env:CGO_ENABLED = "0"
go build -o "${ProjectName}_linux" .
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] ${ProjectName}_linux" -ForegroundColor Green
} else {
Write-Host "[FAILED] Linux build" -ForegroundColor Red
exit 1
}
}
switch ($Target.ToLower()) {
"windows" { Build-Windows }
"linux" { Build-Linux }
"all" { Build-Windows; Build-Linux }
default {
Write-Host "Usage: .\build.ps1 [windows|linux|all]" -ForegroundColor Yellow
}
}
# Clean up environment
Remove-Item Env:GOOS -ErrorAction SilentlyContinue
Remove-Item Env:GOARCH -ErrorAction SilentlyContinue
Remove-Item Env:CGO_ENABLED -ErrorAction SilentlyContinue
Write-Host "=== Build Complete ===" -ForegroundColor Cyan