Files
QFT/VERIFY_WINDOWS_HOST.ps1
2026-08-12 14:48:09 +08:00

63 lines
2.7 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
Write-Host "== QFT v0.4.16 Windows host verification ==" -ForegroundColor Cyan
if (Get-Command python -ErrorAction SilentlyContinue) {
Write-Host "[1/4] Core protocol/selftests"
& python "$Root\scripts\run_all_selftests.py"
if ($LASTEXITCODE -ne 0) {
Write-Host "If Python reports missing qrcode/cv2, run: python -m pip install -r `"$Root\scripts\requirements-test.txt`"" -ForegroundColor Yellow
throw "repository Python selftests failed"
}
} else {
Write-Warning "python not found; skipping repository Python selftests"
}
Write-Host "[2/4] Desktop Rust compile/test/release"
# 正在运行的 qft-desktop.exe 会锁住产物文件,cargo 只会抛出
# "failed to remove file ... 拒绝访问 (os error 5)" 这种看不出原因的错误。
# 这里提前识别并说清楚,而不是让用户去猜。
$Running = Get-Process -Name 'qft-desktop' -ErrorAction SilentlyContinue
if ($Running) {
Write-Host ""
Write-Warning "检测到 qft-desktop.exe 正在运行(PID: $($Running.Id -join ', '))。"
Write-Warning "它会锁住 target\release\qft-desktop.exe,导致构建报 'os error 5 拒绝访问'。"
$Answer = Read-Host "是否结束这些进程后继续构建?(y/N)"
if ($Answer -eq 'y' -or $Answer -eq 'Y') {
$Running | Stop-Process -Force
Start-Sleep -Milliseconds 500
Write-Host "已结束,继续构建。"
} else {
throw "请先关闭 QFT 窗口再重新运行本脚本"
}
}
Push-Location "$Root\desktop"
try {
& cargo check
if ($LASTEXITCODE -ne 0) { throw "cargo check failed" }
& cargo test
if ($LASTEXITCODE -ne 0) { throw "cargo test failed" }
& cargo build --release
if ($LASTEXITCODE -ne 0) { throw "cargo build --release failed" }
} finally { Pop-Location }
Write-Host "[3/4] Android unit/build"
Push-Location "$Root\android"
try {
if (!(Test-Path '.\gradle\wrapper\gradle-wrapper.jar')) {
Write-Host "Gradle wrapper jar missing; attempting bootstrap..."
& powershell -ExecutionPolicy Bypass -File '.\bootstrap-wrapper.ps1'
}
& .\gradlew.bat :app:testDebugUnitTest :app:assembleDebug --stacktrace
if ($LASTEXITCODE -ne 0) { throw "Android Gradle verification failed" }
} finally { Pop-Location }
Write-Host "[4/4] Artifact locations" -ForegroundColor Cyan
Write-Host "Windows EXE: $Root\desktop\target\release\qft-desktop.exe"
Write-Host "Android APK: $Root\android\app\build\outputs\apk\debug\app-debug.apk"
Write-Host "`nHOST BUILD VERIFICATION PASSED" -ForegroundColor Green
Write-Host "Next: perform the physical display/camera and Wi-Fi Direct acceptance matrix in TEST_REPORT.md."