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.8 KiB

param(
[string]$OutputPath = ""
)
$ErrorActionPreference = "Stop"
$scriptApiRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$workingApiRoot = Resolve-Path (Get-Location)
if (Test-Path -LiteralPath (Join-Path $workingApiRoot "go.mod")) {
$apiRoot = $workingApiRoot
} elseif (Test-Path -LiteralPath (Join-Path $scriptApiRoot "go.mod")) {
$apiRoot = $scriptApiRoot
} else {
throw "Run this script from services\tera-api, or place it under services\tera-api\scripts."
}
$repoRoot = Resolve-Path (Join-Path $apiRoot "..\..")
$goRoot = Join-Path $repoRoot ".tools\go1.26.4"
$goExe = Join-Path $goRoot "bin\go.exe"
if (-not (Test-Path -LiteralPath $goExe)) {
throw "Portable Go is not installed at $goExe"
}
if ($OutputPath -eq "") {
$OutputPath = Join-Path ([System.IO.Path]::GetTempPath()) "tera-api-serial-termios-linux-arm64.test"
}
$outputParent = Split-Path -Parent $OutputPath
if ($outputParent -ne "") {
New-Item -ItemType Directory -Force $outputParent | Out-Null
}
Push-Location $apiRoot
try {
$env:GOROOT = $goRoot
$env:GOPATH = Join-Path $repoRoot ".tools\gopath"
$env:GOCACHE = Join-Path $repoRoot ".tools\go-build"
$env:GOMODCACHE = Join-Path $env:GOPATH "pkg\mod"
$env:GOOS = "linux"
$env:GOARCH = "arm64"
$env:CGO_ENABLED = "0"
New-Item -ItemType Directory -Force $env:GOPATH, $env:GOCACHE, $env:GOMODCACHE | Out-Null
& $goExe test -c -trimpath -mod=vendor -o $OutputPath ./internal/serial
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
} finally {
Pop-Location
}
$artifact = Get-Item -LiteralPath $OutputPath
if ($artifact.Length -le 0) {
throw "Linux ARM64 serial termios test binary is empty: $OutputPath"
}
Write-Host "[check-linux-arm64-serial-termios] Built $($artifact.FullName) ($($artifact.Length) bytes)"