build-release.ps1 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Build script for Tauri application(OpenSSL 静态链接进 exe,无需 libcrypto DLL)
  2. [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
  3. $ErrorActionPreference = "Stop"
  4. $ProjectRoot = $PSScriptRoot
  5. $APIUrl = "http://125.122.32.114:9000"
  6. # OpenSSL 静态链接(与 .cargo/config.toml +crt-static 一致)
  7. . (Join-Path $ProjectRoot "scripts\set-openssl-static-env.ps1")
  8. Set-Location $ProjectRoot
  9. Write-Host "========================================"
  10. Write-Host " Building Tauri App (static OpenSSL)"
  11. Write-Host "========================================"
  12. Write-Host ""
  13. Write-Host "Checking Rust..."
  14. if (-not (Get-Command rustc -ErrorAction SilentlyContinue)) {
  15. Write-Host "ERROR: Rust not found!"
  16. exit 1
  17. }
  18. Write-Host " Rust OK"
  19. Write-Host "Checking Node.js..."
  20. if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
  21. Write-Host "ERROR: Node.js not found!"
  22. exit 1
  23. }
  24. Write-Host " Node OK"
  25. Write-Host ""
  26. Write-Host "OpenSSL static linking:"
  27. Write-Host " OPENSSL_DIR=$env:OPENSSL_DIR"
  28. Write-Host " OPENSSL_LIB_DIR=$env:OPENSSL_LIB_DIR"
  29. Write-Host " OPENSSL_STATIC=$env:OPENSSL_STATIC"
  30. Write-Host ""
  31. Write-Host "Setting API URL: $APIUrl"
  32. $env:DEFAULT_BACKEND_API_URL = $APIUrl
  33. Write-Host ""
  34. Write-Host "Installing dependencies..."
  35. npm install --silent
  36. Write-Host ""
  37. Write-Host "Building Tauri application..."
  38. Write-Host ""
  39. $startTime = Get-Date
  40. npm run tauri build
  41. if ($LASTEXITCODE -ne 0) {
  42. Write-Host ""
  43. Write-Host "BUILD FAILED!" -ForegroundColor Red
  44. exit 1
  45. }
  46. $endTime = Get-Date
  47. $duration = New-TimeSpan -Start $startTime -End $endTime
  48. Write-Host ""
  49. Write-Host "========================================"
  50. Write-Host " BUILD SUCCESS!" -ForegroundColor Green
  51. Write-Host "========================================"
  52. Write-Host ""
  53. Write-Host "Duration: $($duration.ToString('mm\:ss'))"
  54. Write-Host "API URL: $APIUrl"
  55. Write-Host ""
  56. $exe = Get-ChildItem "src-tauri\target\release" -Filter "*.exe" -File -ErrorAction SilentlyContinue |
  57. Where-Object { $_.DirectoryName -like "*release" -and $_.Length -gt 5MB } |
  58. Sort-Object Length -Descending | Select-Object -First 1
  59. if ($exe) {
  60. $size = "{0:N2} MB" -f ($exe.Length / 1MB)
  61. Write-Host "Standalone EXE:"
  62. Write-Host " $($exe.FullName)" -ForegroundColor Green
  63. Write-Host " Size: $size"
  64. # 定制版分发副本(不覆盖 steamSH_V*.exe / SteamSH_Portable.zip)
  65. $customName = "SteamQG.exe"
  66. $customPath = Join-Path $ProjectRoot $customName
  67. Copy-Item -Path $exe.FullName -Destination $customPath -Force
  68. Write-Host ""
  69. Write-Host "Custom portable copy:"
  70. Write-Host " $customPath" -ForegroundColor Green
  71. Write-Host " (old SteamSH_Portable.zip / steamSH_V*.exe left untouched)"
  72. }
  73. $nsisFiles = Get-ChildItem -Path "src-tauri\target\release\bundle\nsis" -Filter "*setup.exe" -ErrorAction SilentlyContinue
  74. if ($nsisFiles) {
  75. Write-Host ""
  76. Write-Host "NSIS Installer:"
  77. foreach ($nsis in $nsisFiles) {
  78. $size = "{0:N2} MB" -f ($nsis.Length / 1MB)
  79. Write-Host " $($nsis.FullName)" -ForegroundColor Cyan
  80. Write-Host " Size: $size"
  81. }
  82. }
  83. Write-Host ""
  84. Write-Host "Build complete!"