build_linux_server.ps1 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. $ErrorActionPreference = "Stop"
  2. $repoRoot = Split-Path -Parent $PSScriptRoot
  3. Push-Location $repoRoot
  4. try {
  5. rustup target add x86_64-unknown-linux-musl
  6. cargo build --release --no-default-features --target x86_64-unknown-linux-musl --bin cold_water_server
  7. if ($LASTEXITCODE -ne 0) {
  8. throw "Linux musl build failed with exit code $LASTEXITCODE"
  9. }
  10. $distDir = Join-Path $repoRoot "dist\linux"
  11. New-Item -ItemType Directory -Force -Path $distDir | Out-Null
  12. $binSrc = Join-Path $repoRoot "target\x86_64-unknown-linux-musl\release\cold_water_server"
  13. $binDst = Join-Path $distDir "cold_water_server"
  14. Copy-Item -Force $binSrc $binDst
  15. $cfgSrc = Join-Path $repoRoot "server_config.json"
  16. $cfgDst = Join-Path $distDir "server_config.json"
  17. if (Test-Path $cfgSrc) {
  18. Copy-Item -Force $cfgSrc $cfgDst
  19. }
  20. $modsSrc = Join-Path $repoRoot "mods"
  21. $modsDst = Join-Path $distDir "mods"
  22. if (Test-Path $modsSrc) {
  23. if (Test-Path $modsDst) { Remove-Item -Recurse -Force $modsDst }
  24. Copy-Item -Recurse -Force $modsSrc $modsDst
  25. }
  26. Write-Host "Packaged Linux server bundle at $distDir"
  27. }
  28. finally {
  29. Pop-Location
  30. }