| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- $ErrorActionPreference = "Stop"
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
- Set-Location $PSScriptRoot
- Write-Host "========================================" -ForegroundColor Cyan
- Write-Host "Building standalone exe (static linking)" -ForegroundColor Cyan
- Write-Host "========================================" -ForegroundColor Cyan
- Write-Host "`n[1/4] Setting OpenSSL static build environment..." -ForegroundColor Yellow
- . (Join-Path $PSScriptRoot "scripts\set-openssl-static-env.ps1")
- $env:DEFAULT_BACKEND_API_URL = "http://125.122.32.114:9000"
- Write-Host "API URL: $env:DEFAULT_BACKEND_API_URL" -ForegroundColor Cyan
- $env:RUSTFLAGS = "-C target-feature=+crt-static"
- $env:PROFILE = "release"
- Write-Host "`n[2/4] Building frontend..." -ForegroundColor Yellow
- npm run build
- if ($LASTEXITCODE -ne 0) {
- Write-Error "Frontend build failed!"
- exit 1
- }
- Write-Host "`n[3/4] Building Rust backend (static linking)..." -ForegroundColor Yellow
- Write-Host "This may take a few minutes, please wait..." -ForegroundColor Cyan
- cargo build --release --manifest-path src-tauri/Cargo.toml --bin your-app-name
- if ($LASTEXITCODE -ne 0) {
- Write-Error "Rust build failed!"
- exit 1
- }
- Write-Host "`n[4/4] Locating generated executable..." -ForegroundColor Yellow
- $exePaths = @(
- "src-tauri/target/release/your-app-name.exe"
- )
- $finalExe = $null
- foreach ($path in $exePaths) {
- if (Test-Path $path) {
- $finalExe = $path
- break
- }
- }
- if (-not $finalExe) {
- $exe = Get-ChildItem -Path "src-tauri/target/release" -Filter "*.exe" -File -Recurse |
- Where-Object { $_.Name -notmatch 'setup|uninstaller|bundle|deps|build' } |
- Sort-Object LastWriteTime -Descending |
- Select-Object -First 1
- if ($exe) {
- $finalExe = $exe.FullName
- }
- }
- if (-not $finalExe) {
- Write-Error "Cannot find generated executable!"
- exit 1
- }
- $outputName = "steamSH_standalone.exe"
- $outputPath = Join-Path $PSScriptRoot $outputName
- Copy-Item -Path $finalExe -Destination $outputPath -Force
- $fileSize = (Get-Item $outputPath).Length / 1MB
- Write-Host "`n========================================" -ForegroundColor Green
- Write-Host "Build completed!" -ForegroundColor Green
- Write-Host "========================================" -ForegroundColor Green
- Write-Host "Output file: $outputPath" -ForegroundColor Cyan
- Write-Host "File size: $([math]::Round($fileSize, 2)) MB" -ForegroundColor Cyan
- Write-Host "`nThis is a standalone executable that can run without installing any dependencies." -ForegroundColor Yellow
- if (Test-Path $outputPath) {
- Write-Host "`nFile verification: OK" -ForegroundColor Green
- }
|