Add dependency checker script for Windows builds

This commit is contained in:
Aether 2026-02-23 20:53:01 +00:00
parent 20f05b6268
commit 7e5d536748
No known key found for this signature in database
GPG Key ID: 95AFEE837E39AFD2
1 changed files with 166 additions and 0 deletions

View File

@ -0,0 +1,166 @@
# EU-Utility V3 - Dependency Checker for Windows
# Run this in PowerShell to verify all build prerequisites
param(
[switch]$InstallMissing
)
$ErrorActionPreference = "Stop"
$hasErrors = $false
Write-Host "`n=== EU-Utility V3 Build Dependency Checker ===`n" -ForegroundColor Cyan
# 1. Check Node.js
Write-Host "Checking Node.js..." -NoNewline
$nodeVersion = & node --version 2>$null
if ($nodeVersion) {
Write-Host " OK ($nodeVersion)" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Install from: https://nodejs.org/" -ForegroundColor Yellow
$hasErrors = $true
}
# 2. Check npm
Write-Host "Checking npm..." -NoNewline
$npmVersion = & npm --version 2>$null
if ($npmVersion) {
Write-Host " OK ($npmVersion)" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
$hasErrors = $true
}
# 3. Check Rust/Cargo
Write-Host "Checking Rust..." -NoNewline
$cargoVersion = & cargo --version 2>$null
if ($cargoVersion) {
Write-Host " OK ($cargoVersion)" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Install from: https://rustup.rs/" -ForegroundColor Yellow
$hasErrors = $true
}
# 4. Check Tauri CLI
Write-Host "Checking Tauri CLI..." -NoNewline
$tauriVersion = & npx tauri --version 2>$null
if ($tauriVersion) {
Write-Host " OK ($tauriVersion)" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Install with: npm install -g @tauri-apps/cli@^1.5.0" -ForegroundColor Yellow
$hasErrors = $true
}
# 5. Check Visual Studio Build Tools
Write-Host "Checking Visual Studio Build Tools..." -NoNewline
$clPath = Get-Command cl.exe -ErrorAction SilentlyContinue
$vcvarsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
$vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools"
if ($clPath -or (Test-Path $vcvarsPath) -or (Test-Path $vsPath)) {
Write-Host " OK" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Download from: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022" -ForegroundColor Yellow
Write-Host " Select: 'Desktop development with C++' workload" -ForegroundColor Yellow
$hasErrors = $true
}
# 6. Check vcpkg
Write-Host "Checking vcpkg..." -NoNewline
$vcpkgPath = "C:\vcpkg\vcpkg.exe"
$vcpkgExists = Test-Path $vcpkgPath
if ($vcpkgExists) {
Write-Host " OK" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Install with:" -ForegroundColor Yellow
Write-Host " git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg" -ForegroundColor Cyan
Write-Host " C:\vcpkg\bootstrap-vcpkg.bat" -ForegroundColor Cyan
$hasErrors = $true
}
# 7. Check vcpkg static libraries
if ($vcpkgExists) {
Write-Host "`nChecking vcpkg static libraries..." -ForegroundColor White
$requiredLibs = @(
"tesseract:x64-windows-static-md",
"leptonica:x64-windows-static-md",
"libpng:x64-windows-static-md",
"tiff:x64-windows-static-md",
"libjpeg-turbo:x64-windows-static-md",
"openjpeg:x64-windows-static-md"
)
$installedLibs = & C:\vcpkg\vcpkg list 2>$null
foreach ($lib in $requiredLibs) {
$libName = $lib.Split(':')[0]
Write-Host " Checking $libName..." -NoNewline
if ($installedLibs -match $libName) {
Write-Host " OK" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
if ($InstallMissing) {
Write-Host " Installing $lib..." -ForegroundColor Yellow
& C:\vcpkg\vcpkg install $lib
} else {
Write-Host " Install with: C:\vcpkg\vcpkg install $lib" -ForegroundColor Cyan
}
$hasErrors = $true
}
}
}
# 8. Check environment variables
Write-Host "`nChecking environment variables..." -ForegroundColor White
$envVars = @(
@{ Name = "VCPKG_ROOT"; Expected = "C:\vcpkg" }
)
foreach ($var in $envVars) {
$name = $var.Name
$expected = $var.Expected
$value = [Environment]::GetEnvironmentVariable($name, "User")
Write-Host " Checking $name..." -NoNewline
if ($value -eq $expected) {
Write-Host " OK" -ForegroundColor Green
} else {
Write-Host " MISSING or INCORRECT" -ForegroundColor Red
Write-Host " Set with: [Environment]::SetEnvironmentVariable('$name', '$expected', 'User')" -ForegroundColor Cyan
$hasErrors = $true
}
}
# 9. Check npm dependencies
Write-Host "`nChecking npm dependencies..." -NoNewline
Set-Location $PSScriptRoot\..
$nodeModulesExists = Test-Path "node_modules"
if ($nodeModulesExists) {
Write-Host " OK (node_modules exists)" -ForegroundColor Green
} else {
Write-Host " MISSING" -ForegroundColor Red
Write-Host " Install with: npm install" -ForegroundColor Cyan
$hasErrors = $true
}
# Summary
Write-Host "`n=== Summary ===" -ForegroundColor Cyan
if ($hasErrors) {
Write-Host "Some dependencies are missing. Fix the issues above and run again." -ForegroundColor Red
Write-Host "`nTo install missing vcpkg libraries automatically, run:" -ForegroundColor Yellow
Write-Host " .\scripts\check-dependencies.ps1 -InstallMissing" -ForegroundColor Cyan
exit 1
} else {
Write-Host "All dependencies are installed! You can now build with:" -ForegroundColor Green
Write-Host " npm run tauri-build" -ForegroundColor Cyan
exit 0
}