Files
OnlineRpg/check_env.ps1
2025-10-26 20:44:58 +08:00

103 lines
3.9 KiB
PowerShell

# 环境检查脚本 (Windows PowerShell)
# 检查所有必要的开发工具和依赖
Write-Host "================================================" -ForegroundColor Cyan
Write-Host " OnlineRpg 环境检查" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
$allOk = $true
# 检查 CMake
Write-Host "[1/5] Checking CMake..." -NoNewline
if (Get-Command cmake -ErrorAction SilentlyContinue) {
Write-Host " OK" -ForegroundColor Green
$version = (cmake --version | Select-Object -First 1)
Write-Host " $version" -ForegroundColor Gray
} else {
Write-Host " NOT FOUND" -ForegroundColor Red
Write-Host " Please install CMake from: https://cmake.org/download/" -ForegroundColor Yellow
$allOk = $false
}
# 检查 C++ 编译器
Write-Host "[2/5] Checking C++ Compiler..." -NoNewline
if (Get-Command cl -ErrorAction SilentlyContinue) {
Write-Host " OK (MSVC)" -ForegroundColor Green
$version = (cl 2>&1 | Select-String "Version" | Select-Object -First 1)
if ($version) {
Write-Host " $version" -ForegroundColor Gray
}
} elseif (Get-Command g++ -ErrorAction SilentlyContinue) {
Write-Host " OK (GCC)" -ForegroundColor Green
$version = (g++ --version | Select-Object -First 1)
Write-Host " $version" -ForegroundColor Gray
} elseif (Get-Command clang++ -ErrorAction SilentlyContinue) {
Write-Host " OK (Clang)" -ForegroundColor Green
$version = (clang++ --version | Select-Object -First 1)
Write-Host " $version" -ForegroundColor Gray
} else {
Write-Host " NOT FOUND" -ForegroundColor Red
Write-Host " Please install Visual Studio or MinGW" -ForegroundColor Yellow
$allOk = $false
}
# 检查 Git
Write-Host "[3/5] Checking Git..." -NoNewline
if (Get-Command git -ErrorAction SilentlyContinue) {
Write-Host " OK" -ForegroundColor Green
$version = (git --version)
Write-Host " $version" -ForegroundColor Gray
} else {
Write-Host " NOT FOUND" -ForegroundColor Red
Write-Host " Please install Git from: https://git-scm.com/" -ForegroundColor Yellow
$allOk = $false
}
# 检查项目结构
Write-Host "[4/5] Checking Project Structure..." -NoNewline
$requiredDirs = @("src", "include", "lib", "data")
$missingDirs = @()
foreach ($dir in $requiredDirs) {
if (-not (Test-Path $dir)) {
$missingDirs += $dir
}
}
if ($missingDirs.Count -eq 0) {
Write-Host " OK" -ForegroundColor Green
} else {
Write-Host " INCOMPLETE" -ForegroundColor Yellow
Write-Host " Missing directories: $($missingDirs -join ', ')" -ForegroundColor Yellow
}
# 检查 SQLite3
Write-Host "[5/5] Checking SQLite3..." -NoNewline
if (Test-Path "lib\sqlite3.h") {
Write-Host " OK (Amalgamation)" -ForegroundColor Green
Write-Host " Found: lib\sqlite3.h" -ForegroundColor Gray
} else {
Write-Host " NOT FOUND" -ForegroundColor Yellow
Write-Host " Download from: https://www.sqlite.org/download.html" -ForegroundColor Yellow
Write-Host " Place sqlite3.h and sqlite3.c in lib/ directory" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
if ($allOk) {
Write-Host " Environment Check: PASSED" -ForegroundColor Green
Write-Host " You can proceed with building the project!" -ForegroundColor Green
} else {
Write-Host " Environment Check: FAILED" -ForegroundColor Red
Write-Host " Please install missing dependencies" -ForegroundColor Red
}
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
# 显示系统信息
Write-Host "System Information:" -ForegroundColor Cyan
Write-Host " OS: $([System.Environment]::OSVersion.VersionString)" -ForegroundColor Gray
Write-Host " CPU Cores: $([System.Environment]::ProcessorCount)" -ForegroundColor Gray
Write-Host " PowerShell: $($PSVersionTable.PSVersion)" -ForegroundColor Gray