27 lines
2.1 KiB
PowerShell
27 lines
2.1 KiB
PowerShell
# Build the Windows DEBUG installer natively on Windows (Go + NSIS).
|
|
# Usage: powershell -ExecutionPolicy Bypass -File platform\windows\build-windows-debug.ps1 [-Arch amd64|arm64]
|
|
param([string]$Arch = "amd64", [string]$Version = "0.2.0-debug")
|
|
$ErrorActionPreference = "Stop"
|
|
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
|
|
$Out = Join-Path $Root "dist\windows-debug"
|
|
$Stage = Join-Path $Out "stage-$Arch"
|
|
$Go = (Get-Command go -ErrorAction SilentlyContinue).Source; if (-not $Go) { $Go = "C:\Program Files\Go\bin\go.exe" }
|
|
$Nsis = (Get-Command makensis -ErrorAction SilentlyContinue).Source; if (-not $Nsis) { $Nsis = "${env:ProgramFiles(x86)}\NSIS\makensis.exe" }
|
|
Remove-Item -Recurse -Force $Stage -ErrorAction SilentlyContinue
|
|
New-Item -ItemType Directory -Force -Path $Stage, (Join-Path $Stage "scripts") | Out-Null
|
|
Push-Location $Root
|
|
try {
|
|
$env:CGO_ENABLED = "0"; $env:GOOS = "windows"; $env:GOARCH = $Arch
|
|
& $Go version
|
|
& $Go test ./internal/... ; if ($LASTEXITCODE) { throw "go test failed" }
|
|
& $Go build -trimpath -o (Join-Path $Stage "verae-print.exe") ./cmd/verae-print; if ($LASTEXITCODE) { throw "build cli failed" }
|
|
& $Go build -trimpath -ldflags "-H windowsgui" -o (Join-Path $Stage "verae-printhelper.exe") ./cmd/verae-print; if ($LASTEXITCODE) { throw "build helper failed" }
|
|
} finally { Pop-Location; Remove-Item Env:GOOS, Env:GOARCH -ErrorAction SilentlyContinue }
|
|
Copy-Item (Join-Path $PSScriptRoot "scripts\*.ps1") (Join-Path $Stage "scripts")
|
|
Copy-Item (Join-Path $PSScriptRoot "LICENSE.txt"), (Join-Path $PSScriptRoot "README-TEST.txt") $Stage
|
|
& $Nsis /V3 "/DVERSION=$Version" "/DARCH=$Arch" "/DSRCDIR=$Stage" "/DOUTDIR=$Out" (Join-Path $PSScriptRoot "installer-debug.nsi")
|
|
if ($LASTEXITCODE) { throw "makensis failed" }
|
|
# raw files alongside the installer
|
|
Copy-Item (Join-Path $Stage "*") $Out -Recurse -Force
|
|
Get-ChildItem $Out -File | Where-Object { $_.Name -ne "SHA256SUMS.txt" -and $_.Extension -ne ".bundle" } | Get-FileHash -Algorithm SHA256 | ForEach-Object { "$($_.Hash.ToLower()) $(Split-Path $_.Path -Leaf)" } | Set-Content (Join-Path $Out "SHA256SUMS.txt")
|
|
Get-ChildItem $Out -File | Format-Table Name, Length -AutoSize
|