60 lines
2.7 KiB
PowerShell
60 lines
2.7 KiB
PowerShell
# build_windows.ps1 - ONE-COMMAND build: daw_engine.exe (PyInstaller) + Tauri v2 (NSIS + MSI)
|
|
# Chay tren Windows: powershell -ExecutionPolicy Bypass -File build_windows.ps1
|
|
# LUU Y: file nay chi dung ky tu ASCII (khong dau, khong em-dash) - PowerShell 5.1
|
|
# doc .ps1 khong BOM theo ANSI, ky tu Unicode bi hong -> "String is missing terminator".
|
|
$ErrorActionPreference = "Stop"
|
|
Set-Location $PSScriptRoot
|
|
|
|
Write-Host "== [1/6] Python dependencies =="
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -r requirements.txt pyinstaller pywin32
|
|
|
|
Write-Host "== [2/6] Frontend bundle (app.jsx -> app.precompiled.js) =="
|
|
npm install
|
|
node build.mjs # @babel/standalone; thay cho 'npm run build' (Babel 8 ESM-only CLI conflict)
|
|
|
|
Write-Host "== [3/6] Build daw_engine.exe (PyInstaller) =="
|
|
pyinstaller engine.spec --clean --noconfirm
|
|
|
|
Write-Host "== [3.5/6] Verify bundle contents (app/static, app/templates phai co) =="
|
|
# Bat loi bundle NGAY tai build (da gap 2 lan: chay pyinstaller tu noi khac
|
|
# -> static/templates thieu -> exe crash 'Directory ...\app\static does not exist').
|
|
$missing = @()
|
|
if (-not (Test-Path "build\engine\Analysis-00.toc")) {
|
|
# PyInstaller 6.x: doc TOC truc tiep tu Analysis
|
|
$tocFiles = Get-ChildItem "build\engine" -Filter "*.toc" -ErrorAction SilentlyContinue
|
|
if ($tocFiles) {
|
|
$tocContent = Get-Content $tocFiles[0].FullName -Raw
|
|
if ($tocContent -notmatch "app/static") { $missing += "app/static" }
|
|
if ($tocContent -notmatch "app/templates") { $missing += "app/templates" }
|
|
}
|
|
} else {
|
|
$tocContent = Get-Content "build\engine\Analysis-00.toc" -Raw
|
|
if ($tocContent -notmatch "app/static") { $missing += "app/static" }
|
|
if ($tocContent -notmatch "app/templates") { $missing += "app/templates" }
|
|
}
|
|
if ($missing.Count -gt 0) {
|
|
Write-Host "ERROR: Bundle thieu: $($missing -join ', '). Dung build - kiem tra engine.spec datas!" -ForegroundColor Red
|
|
exit 1
|
|
} else {
|
|
Write-Host "OK: app/static + app/templates co trong bundle." -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "== [4/6] Sidecar binary -> src-tauri/binaries (tauri triple naming) =="
|
|
New-Item -ItemType Directory -Force src-tauri\binaries | Out-Null
|
|
Copy-Item dist\daw_engine.exe src-tauri\binaries\daw_engine-x86_64-pc-windows-msvc.exe -Force
|
|
|
|
Write-Host "== [5/6] VC++ Redistributable cho hooks.nsh =="
|
|
if (-not (Test-Path src-tauri\vc_redist.x64.exe)) {
|
|
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile src-tauri\vc_redist.x64.exe
|
|
}
|
|
|
|
Write-Host "== [6/6] Tauri build (NSIS .exe + MSI) =="
|
|
npm install -D @tauri-apps/cli
|
|
npx tauri build
|
|
|
|
Write-Host ""
|
|
Write-Host "== DONE =="
|
|
Write-Host " NSIS: src-tauri\target\release\bundle\nsis\SonicForgeDAW_1.0.0_x64-setup.exe"
|
|
Write-Host " MSI : src-tauri\target\release\bundle\msi\SonicForgeDAW_1.0.0_x64_en-US.msi"
|