You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

param(
[string]$OutputPath = ""
)
$ErrorActionPreference = "Stop"
$frontendRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$desktopRoot = Resolve-Path (Join-Path $frontendRoot "..\..")
$portableGo = Join-Path $desktopRoot ".tools\go1.26.4\bin\go.exe"
$configuredGoRoot = [string]$env:TERA_GO_ROOT
if (-not [string]::IsNullOrWhiteSpace($configuredGoRoot)) {
$configuredGo = Join-Path $configuredGoRoot "bin\go.exe"
if (Test-Path -LiteralPath $configuredGo) {
$portableGo = $configuredGo
}
}
$goCommand = Get-Command go -ErrorAction SilentlyContinue
if (Test-Path -LiteralPath $portableGo) {
$goExe = $portableGo
} elseif ($goCommand) {
$goExe = $goCommand.Source
} else {
throw "Go 1.26.4 or newer is required to build tera-clone-demo-web."
}
if ($OutputPath -eq "") {
$OutputPath = Join-Path ([System.IO.Path]::GetTempPath()) "tera-clone-demo-web-linux-arm64"
}
if (-not [System.IO.Path]::IsPathRooted($OutputPath)) {
$OutputPath = [System.IO.Path]::GetFullPath((Join-Path (Get-Location).Path $OutputPath))
}
$outputParent = Split-Path -Parent $OutputPath
if ($outputParent -ne "") {
New-Item -ItemType Directory -Force $outputParent | Out-Null
}
Push-Location $frontendRoot
try {
$env:GOOS = "linux"
$env:GOARCH = "arm64"
$env:CGO_ENABLED = "0"
& $goExe build -buildvcs=false -trimpath -o $OutputPath ./cmd/server
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
} finally {
Pop-Location
}
$artifact = Get-Item -LiteralPath $OutputPath
if ($artifact.Length -le 0) {
throw "Linux ARM64 build output is empty: $OutputPath"
}
Write-Host "[check-linux-arm64-build] Built $($artifact.FullName) ($($artifact.Length) bytes)"