# build_install.ps1 - Build install/ (portable package) tu source, Windows # Chay: powershell -ExecutionPolicy Bypass -File build_install.ps1 # # install/ = portable package (chay truc tiep, khong can cai dat): # daw_vst_bridge.exe native host bridge (C++) - DA COMMIT san # libfluidsynth-3.dll FluidSynth runtime - DA COMMIT san # sonicforge-daw.exe Tauri app shell - DA COMMIT san # daw_engine/ Python engine (PyInstaller onedir, ~1.8GB) # - KHONG commit -> script nay tu build # # 3 binary C++/Tauri da commit de nguoi pull khong can toolchain # (VS2019/2022 + vcpkg + vst3sdk submodule + sfizz-src). Chay lai # build_windows.ps1 neu muon build lai bridge/app tu source. # LUU Y: file nay chi dung ky tu ASCII (PowerShell 5.1). # "Stop" + npm/pip warn tren stderr -> NativeCommandError -> chet oai. Dung # "Continue" + kiem tra $LASTEXITCODE thu cong sau tung lenh native. $ErrorActionPreference = "Continue" Set-Location $PSScriptRoot Write-Host "== [1/4] Kill tien trinh cu (chi install/dist, khong dong production) ==" Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.Path -like "$PSScriptRoot\install\*" -or $_.Path -like "$PSScriptRoot\dist\daw_engine\*" } | Stop-Process -Force -ErrorAction SilentlyContinue Start-Sleep -Milliseconds 500 Write-Host "== [2/4] Frontend bundle (app.jsx -> app.precompiled.js) ==" npm install --no-audit --no-fund if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: npm install that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } if (-not (Test-Path "node_modules\@babel\standalone")) { npm install @babel/standalone --no-audit --no-fund if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: npm install @babel/standalone that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } } node build.mjs if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: node build.mjs that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } Write-Host "== [3/4] Build daw_engine.exe (PyInstaller onedir) ==" python -m pip install -r requirements.txt pyinstaller pywin32 if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: pip install that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } pyinstaller engine.spec --clean --noconfirm if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: pyinstaller that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } if (-not (Test-Path "dist\daw_engine\daw_engine.exe")) { Write-Host "ERROR: dist\daw_engine\daw_engine.exe khong ton tai" -ForegroundColor Red exit 1 } python tools\verify_bundle.py if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: bundle thieu asset" -ForegroundColor Red exit 1 } Write-Host "== [4/4] Verify bundle sach (khong config dev) + copy vao install\ ==" # Ban cai phai reset ve mac dinh: KHONG duoc mang theo DB/password/secret/ # plugin-dirs/scan-state cua dev sang may nguoi dung moi. $devFiles = Get-ChildItem "dist\daw_engine" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -in @(".secret_key", "plugin_dirs.json", "sf_scan_state.json", "sf_scan_state.json.bak-root") -or $_.Extension -eq ".db" } if ($devFiles) { Write-Host "ERROR: bundle chua config dev - DUNG TAO BAN CAI:" -ForegroundColor Red $devFiles | ForEach-Object { Write-Host " $($_.FullName)" -ForegroundColor Red } exit 1 } New-Item -ItemType Directory -Force "install" | Out-Null # Copy-Item wildcard tu dist\daw_engine vao install\daw_engine tao layout PHANG # (noi dung _internal tran ra root, exe khong thay _internal -> treo luc chay). # Robocopy /MIR mirror dung cau truc onedir (exe + _internal) + xoa file thua. robocopy "dist\daw_engine" "install\daw_engine" /MIR /NFL /NDL /NJH /NP /R:1 /W:1 | Out-Null if ($LASTEXITCODE -ge 8) { Write-Host "ERROR: robocopy install that bai (exit $LASTEXITCODE)" -ForegroundColor Red; exit 1 } if (-not (Test-Path "install\daw_engine\_internal")) { Write-Host "ERROR: install\daw_engine\_internal thieu - onedir layout sai" -ForegroundColor Red; exit 1 } # 3 binary (bridge/lib/app) da commit san trong install/ - khong ghi de, # neu user da build lai bridge/app thi tu copy vao day. # VC++ runtime app-local: bridge C++ link /MD can MSVCP140/VCRUNTIME140 canh # exe (khong phu thuoc vc_redist he thong). Dong bo tu src-tauri/binaries. foreach ($dll in @("MSVCP140.dll", "MSVCP140_2.dll", "VCRUNTIME140.dll", "VCRUNTIME140_1.dll")) { $src = "src-tauri\binaries\$dll" if (Test-Path $src) { Copy-Item $src "install\$dll" -Force } else { Write-Host "WARN: thieu $dll trong src-tauri\binaries - chay build_windows.ps1 -Bridge truoc" -ForegroundColor Yellow } } Write-Host "" Write-Host "== DONE ==" Write-Host " install\daw_engine\daw_engine.exe (moi build)" Write-Host " install\daw_vst_bridge.exe (commit san)" Write-Host " install\libfluidsynth-3.dll (commit san)" Write-Host " install\sonicforge-daw.exe (commit san)" Write-Host "" Write-Host "Chay: install\sonicforge-daw.exe"