FIX (lan 2): bundle app assets qua collect_data_files (import-system) + fallback static dir trong main.py + verify TOC trong build_windows.ps1

This commit is contained in:
2026-08-08 13:59:35 +00:00
parent b78a629429
commit eaca051191
4 changed files with 62 additions and 12 deletions
+24
View File
@@ -14,6 +14,30 @@ node build.mjs # @babel/standalone; thay cho 'npm run build' (Babel 8 ESM-only
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 phải có) =="
# Bắt lỗi bundle NGAY tại build (đã gặp 2 lần: chạy pyinstaller từ nơi khác
# -> static/templates thiếu -> exe crash 'Directory ...\app\static does not exist').
$missing = @()
if (-not (Test-Path "build\engine\Analysis-00.toc")) {
# PyInstaller 6.x: đọc TOC trực tiếp từ 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 thiếu: $($missing -join ', '). Dừng build — kiểm tra engine.spec datas!" -ForegroundColor Red
exit 1
} else {
Write-Host "OK: app/static + app/templates có 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