a01a53e969
launch WoW Pipeline: 1. tool/src/main.rs compiles MPQ and puts it at $WOW_HOME/Data 2. reload_wow.bat cleans cache and runs Wow.exe TODO: - rebuild all patches instead of only patch-ruRU-5.MPQ - implement "smart rebuild". Do not create new archive if nothing was changed
68 lines
1.7 KiB
PowerShell
68 lines
1.7 KiB
PowerShell
# Stop on errors
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# --- Resolve project root (folder where script is located)
|
|
$ROOT = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
# --- Load .env if WOW_HOME not already set
|
|
if (-not $env:WOW_HOME) {
|
|
$envFile = Join-Path $ROOT ".env"
|
|
|
|
if (Test-Path $envFile) {
|
|
Write-Host "Loading .env file..."
|
|
|
|
Get-Content $envFile | ForEach-Object {
|
|
if ($_ -match "^\s*([^#][^=]+)=(.+)$") {
|
|
$name = $matches[1].Trim()
|
|
$value = $matches[2].Trim()
|
|
[System.Environment]::SetEnvironmentVariable($name, $value)
|
|
Set-Item -Path "Env:$name" -Value $value
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# --- Validate WOW_HOME
|
|
if (-not $env:WOW_HOME) {
|
|
Write-Error "WOW_HOME is not set (env or .env)"
|
|
exit 1
|
|
}
|
|
|
|
$WOW_HOME = $env:WOW_HOME
|
|
Write-Host "WOW_HOME = $WOW_HOME"
|
|
|
|
# --- Paths
|
|
$INPUT_DIR = Join-Path $ROOT "patch-ruRU-5"
|
|
$OUTPUT_MPQ = Join-Path $WOW_HOME "Data\ruRU\patch-ruRU-5.MPQ"
|
|
$TOOL = Join-Path $ROOT "tool\target\release\tool.exe"
|
|
$RELOAD_SCRIPT = Join-Path $ROOT "reload_wow.bat"
|
|
|
|
# --- Ensure tool exists
|
|
if (!(Test-Path $TOOL)) {
|
|
Write-Host "Building Rust tool..."
|
|
Push-Location (Join-Path $ROOT "tool")
|
|
cargo build --release
|
|
Pop-Location
|
|
}
|
|
|
|
# --- Ensure WoW directory exists
|
|
$wowDataDir = Join-Path $WOW_HOME "Data\ruRU"
|
|
if (!(Test-Path $wowDataDir)) {
|
|
New-Item -ItemType Directory -Force -Path $wowDataDir | Out-Null
|
|
}
|
|
|
|
# --- Build MPQ
|
|
Write-Host "Building MPQ..."
|
|
& $TOOL $INPUT_DIR $OUTPUT_MPQ
|
|
|
|
# --- Verify result
|
|
if (!(Test-Path $OUTPUT_MPQ)) {
|
|
Write-Error "MPQ build failed!"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "MPQ created at $OUTPUT_MPQ"
|
|
|
|
# --- Run WoW reload script
|
|
Write-Host "Launching WoW..."
|
|
cmd /c $RELOAD_SCRIPT |