feat: add Windows installer build script
One-command build: powershell -ExecutionPolicy Bypass -File scripts\build-installer.ps1 Checks prerequisites, builds frontend/server, stages payload, and produces EdgeAI-Installer.exe via Wails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
522800cc7d
commit
551dee46cc
108
edge-ai-platform/scripts/build-installer.ps1
Normal file
108
edge-ai-platform/scripts/build-installer.ps1
Normal file
@ -0,0 +1,108 @@
|
||||
# Edge AI Platform - Windows Installer Build Script
|
||||
# Usage: powershell -ExecutionPolicy Bypass -File scripts\build-installer.ps1
|
||||
#
|
||||
# Prerequisites: Go 1.23+, Node.js 20+, pnpm, Wails CLI
|
||||
# Run from edge-ai-platform/ directory
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$baseDir = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$repoRoot = Split-Path -Parent $baseDir
|
||||
|
||||
Set-Location $baseDir
|
||||
Write-Host "=== Edge AI Platform - Windows Installer Build ===" -ForegroundColor Cyan
|
||||
Write-Host "Working directory: $baseDir"
|
||||
Write-Host ""
|
||||
|
||||
# Check prerequisites
|
||||
Write-Host "[1/5] Checking prerequisites..." -ForegroundColor Yellow
|
||||
$missing = @()
|
||||
if (-not (Get-Command go -ErrorAction SilentlyContinue)) { $missing += "Go (https://go.dev/dl/)" }
|
||||
if (-not (Get-Command node -ErrorAction SilentlyContinue)) { $missing += "Node.js (https://nodejs.org/)" }
|
||||
if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) { $missing += "pnpm (npm install -g pnpm)" }
|
||||
if (-not (Get-Command wails -ErrorAction SilentlyContinue)) { $missing += "Wails (go install github.com/wailsapp/wails/v2/cmd/wails@latest)" }
|
||||
|
||||
if ($missing.Count -gt 0) {
|
||||
Write-Host "Missing prerequisites:" -ForegroundColor Red
|
||||
foreach ($m in $missing) { Write-Host " - $m" -ForegroundColor Red }
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host " Go: $(go version)" -ForegroundColor Green
|
||||
Write-Host " Node: $(node --version)" -ForegroundColor Green
|
||||
Write-Host " pnpm: $(pnpm --version)" -ForegroundColor Green
|
||||
Write-Host " Wails: $(wails version 2>&1 | Select-String 'v')" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Build frontend
|
||||
Write-Host "[2/5] Building frontend..." -ForegroundColor Yellow
|
||||
Set-Location frontend
|
||||
pnpm install --frozen-lockfile
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "pnpm install failed" -ForegroundColor Red; exit 1 }
|
||||
pnpm build
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "pnpm build failed" -ForegroundColor Red; exit 1 }
|
||||
if (Test-Path ..\server\web\out) { Remove-Item -Recurse -Force ..\server\web\out }
|
||||
xcopy /E /I /Y out ..\server\web\out | Out-Null
|
||||
Set-Location $baseDir
|
||||
Write-Host " Frontend built." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Build server
|
||||
Write-Host "[3/5] Building server..." -ForegroundColor Yellow
|
||||
Set-Location server
|
||||
$env:CGO_ENABLED = "0"
|
||||
go build -tags notray -ldflags="-s -w" -o ..\dist\edge-ai-server.exe main.go
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "Server build failed" -ForegroundColor Red; exit 1 }
|
||||
Set-Location $baseDir
|
||||
$size = [math]::Round((Get-Item dist\edge-ai-server.exe).Length / 1MB, 1)
|
||||
Write-Host " Server built: dist\edge-ai-server.exe ($size MB)" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Stage installer payload
|
||||
Write-Host "[4/5] Staging installer payload..." -ForegroundColor Yellow
|
||||
Remove-Item -Recurse -Force installer\payload -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path installer\payload\data\nef\kl520 | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path installer\payload\data\nef\kl720 | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path installer\payload\scripts\firmware\KL520 | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path installer\payload\scripts\firmware\KL720 | Out-Null
|
||||
|
||||
Copy-Item dist\edge-ai-server.exe installer\payload\
|
||||
Copy-Item server\data\models.json installer\payload\data\
|
||||
Copy-Item server\data\nef\kl520\*.nef installer\payload\data\nef\kl520\
|
||||
Copy-Item server\data\nef\kl720\*.nef installer\payload\data\nef\kl720\
|
||||
Copy-Item server\scripts\kneron_bridge.py installer\payload\scripts\
|
||||
Copy-Item server\scripts\requirements.txt installer\payload\scripts\
|
||||
Copy-Item server\scripts\update_kl720_firmware.py installer\payload\scripts\
|
||||
Copy-Item scripts\kneron_detect.py installer\payload\scripts\
|
||||
Copy-Item server\scripts\firmware\KL520\*.bin installer\payload\scripts\firmware\KL520\
|
||||
Copy-Item server\scripts\firmware\KL720\*.bin installer\payload\scripts\firmware\KL720\
|
||||
|
||||
# Copy libusb DLL if available
|
||||
$libusbSrc = Join-Path $repoRoot "local_service_win\third_party\Kneron_DFUT\bin\libusb-1.0.dll"
|
||||
if (Test-Path $libusbSrc) {
|
||||
Copy-Item $libusbSrc installer\payload\scripts\
|
||||
Write-Host " libusb-1.0.dll bundled." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " libusb-1.0.dll not found, skipping." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
$fileCount = (Get-ChildItem -Recurse installer\payload -File).Count
|
||||
Write-Host " Payload staged: $fileCount files." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Build installer
|
||||
Write-Host "[5/5] Building Wails installer..." -ForegroundColor Yellow
|
||||
Set-Location installer
|
||||
wails build -clean
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "Wails build failed" -ForegroundColor Red; exit 1 }
|
||||
Set-Location $baseDir
|
||||
|
||||
$exe = "installer\build\bin\EdgeAI-Installer.exe"
|
||||
if (Test-Path $exe) {
|
||||
$size = [math]::Round((Get-Item $exe).Length / 1MB, 1)
|
||||
Write-Host ""
|
||||
Write-Host "=== Build complete! ===" -ForegroundColor Cyan
|
||||
Write-Host " Output: $baseDir\$exe ($size MB)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Build output not found!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user