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

60 lines
1.8 KiB
PowerShell

# OnlineRpg 构建脚本 (Windows PowerShell)
# 使用方法: .\build.ps1
Write-Host "================================================" -ForegroundColor Cyan
Write-Host " OnlineRpg Build Script (Windows)" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
# 检查 CMake 是否安装
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
Write-Host "[ERROR] CMake not found! Please install CMake first." -ForegroundColor Red
exit 1
}
Write-Host "[INFO] CMake version:" -ForegroundColor Green
cmake --version
Write-Host ""
# 创建 build 目录
if (-not (Test-Path "build")) {
Write-Host "[INFO] Creating build directory..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path "build" | Out-Null
}
# 进入 build 目录
Set-Location build
# 配置项目
Write-Host "[INFO] Configuring project with CMake..." -ForegroundColor Yellow
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] CMake configuration failed!" -ForegroundColor Red
Set-Location ..
exit 1
}
Write-Host ""
Write-Host "[INFO] Building project..." -ForegroundColor Yellow
cmake --build . --config Release
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] Build failed!" -ForegroundColor Red
Set-Location ..
exit 1
}
Write-Host ""
Write-Host "[SUCCESS] Build completed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Executables are located in: build\bin\Release\" -ForegroundColor Cyan
Write-Host " - server.exe" -ForegroundColor Cyan
Write-Host " - client.exe" -ForegroundColor Cyan
Write-Host ""
Set-Location ..
Write-Host "To run the server: .\build\bin\Release\server.exe" -ForegroundColor Yellow
Write-Host "To run the client: .\build\bin\Release\client.exe" -ForegroundColor Yellow