104 lines
2.2 KiB
PowerShell
104 lines
2.2 KiB
PowerShell
# FunMC 构建脚本 (Windows PowerShell)
|
|
# 用于构建所有组件
|
|
|
|
param(
|
|
[ValidateSet("all", "client", "server", "relay")]
|
|
[string]$Target = "all",
|
|
[switch]$Release,
|
|
[switch]$Bundle
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$RootDir = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
|
|
function Write-Step {
|
|
param([string]$Message)
|
|
Write-Host "`n==> $Message" -ForegroundColor Cyan
|
|
}
|
|
|
|
function Build-Server {
|
|
Write-Step "构建主服务端..."
|
|
Push-Location "$RootDir/server"
|
|
|
|
if ($Release) {
|
|
cargo build --release
|
|
} else {
|
|
cargo build
|
|
}
|
|
|
|
Pop-Location
|
|
Write-Host "主服务端构建完成!" -ForegroundColor Green
|
|
}
|
|
|
|
function Build-Relay {
|
|
Write-Step "构建中继服务端..."
|
|
Push-Location "$RootDir/relay-server"
|
|
|
|
if ($Release) {
|
|
cargo build --release
|
|
} else {
|
|
cargo build
|
|
}
|
|
|
|
Pop-Location
|
|
Write-Host "中继服务端构建完成!" -ForegroundColor Green
|
|
}
|
|
|
|
function Build-Client {
|
|
Write-Step "构建客户端..."
|
|
Push-Location "$RootDir/client"
|
|
|
|
# 安装前端依赖
|
|
Write-Host "安装前端依赖..."
|
|
Push-Location "ui"
|
|
npm install
|
|
Pop-Location
|
|
|
|
# 构建 Tauri 应用
|
|
if ($Bundle) {
|
|
if ($Release) {
|
|
cargo tauri build
|
|
} else {
|
|
cargo tauri build --debug
|
|
}
|
|
} else {
|
|
if ($Release) {
|
|
cargo build --release
|
|
} else {
|
|
cargo build
|
|
}
|
|
}
|
|
|
|
Pop-Location
|
|
Write-Host "客户端构建完成!" -ForegroundColor Green
|
|
}
|
|
|
|
# 主逻辑
|
|
Write-Host "FunMC 构建系统" -ForegroundColor Yellow
|
|
Write-Host "===============" -ForegroundColor Yellow
|
|
|
|
switch ($Target) {
|
|
"all" {
|
|
Build-Server
|
|
Build-Relay
|
|
Build-Client
|
|
}
|
|
"client" {
|
|
Build-Client
|
|
}
|
|
"server" {
|
|
Build-Server
|
|
}
|
|
"relay" {
|
|
Build-Relay
|
|
}
|
|
}
|
|
|
|
Write-Host "`n所有构建完成!" -ForegroundColor Green
|
|
|
|
if ($Bundle -and $Target -in @("all", "client")) {
|
|
Write-Host "`n客户端安装包位置:" -ForegroundColor Yellow
|
|
Write-Host "$RootDir\client\target\release\bundle\" -ForegroundColor White
|
|
}
|