FIX: sửa 2 file giúp build trên Windows

This commit is contained in:
2026-08-08 09:18:23 +07:00
parent 6edf526d27
commit 3f35b84535
2 changed files with 43 additions and 19 deletions
+37 -19
View File
@@ -1,44 +1,62 @@
@echo off @echo off
REM ── SonicForge DAW Windows build script (Dual-Process: daw_engine.exe + Tauri shell) ── REM SonicForge DAW - Windows build (daw_engine.exe + Tauri shell)
REM Chạy bằng "cmd" (Run as Administrator nếu cần cài Rust/system-wide)
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
cd /d "%~dp0" cd /d "%~dp0"
echo [1/6] Kiem tra Python + Node... echo [1/6] Kiem tra Python + Node...
python --version || (echo THIEU Python 3.11+ — cai tu python.org (tick "Add to PATH") && pause && exit /b 1) python --version
node --version || (echo THIEU Node 20+ — cai tu nodejs.org && pause && exit /b 1) if errorlevel 1 (
echo THIEU Python 3.11+ - cai tu python.org, tick Add to PATH
pause
exit /b 1
)
node --version
if errorlevel 1 (
echo THIEU Node 20+ - cai tu nodejs.org
pause
exit /b 1
)
echo [2/6] Kiem tra / cai Rust toolchain (MSVC)... echo [2/6] Kiem tra / cai Rust toolchain...
where cargo >nul 2>nul where cargo >nul 2>nul
if errorlevel 1 ( if errorlevel 1 (
echo Cai Rust qua rustup (MSVC toolchain — can Visual Studio Build Tools/C++ workload)... echo Cai Rust qua rustup MSVC toolchain...
powershell -Command "Invoke-WebRequest https://win.rustup.rs/x86_64 -OutFile rustup-init.exe" powershell -Command "Invoke-WebRequest https://win.rustup.rs/x86_64 -OutFile rustup-init.exe"
rustup-init.exe -y --default-toolchain stable --profile minimal rustup-init.exe -y --default-toolchain stable --profile minimal
del rustup-init.exe del rustup-init.exe
call "%USERPROFILE%\.cargo\env" 2>nul || set "PATH=%USERPROFILE%\.cargo\bin;%PATH%" set "PATH=%USERPROFILE%\.cargo\bin;%PATH%"
)
cargo --version
if errorlevel 1 (
echo Rust cai that bai - can Visual Studio Build Tools voi C++ workload
pause
exit /b 1
) )
cargo --version || (echo Rust cai that bai — cai Visual Studio Build Tools (C++ workload) roi thu lai && pause && exit /b 1)
echo [3/6] Cai Python deps (PyInstaller + backend)... echo [3/6] Cai Python deps...
pip install pyinstaller pywin32 pip install pyinstaller pywin32
if errorlevel 1 exit /b 1
pip install -r requirements.txt pip install -r requirements.txt
pip install --no-deps pedalboard>=0.8.0 if errorlevel 1 exit /b 1
pip install --no-deps "pedalboard>=0.8.0"
echo [4/6] Precompile JS (Babel)... echo [4/6] Precompile JS...
npm install --no-audit --no-fund >nul 2>nul npm install --no-audit --no-fund >nul 2>nul
node node_modules/@babel/cli/bin/babel.js app/static/js/app.jsx --config-file ./babel.config.json -o app/static/js/app.precompiled.js || exit /b 1 node node_modules/@babel/cli/bin/babel.js app/static/js/app.jsx --config-file ./babel.config.json -o app/static/js/app.precompiled.js
if errorlevel 1 exit /b 1
echo [5/6] Build daw_engine.exe (PyInstaller)... echo [5/6] Build daw_engine.exe...
pyinstaller engine.spec --clean --noconfirm || exit /b 1 pyinstaller engine.spec --clean --noconfirm
if errorlevel 1 exit /b 1
if not exist "src-tauri\binaries" mkdir "src-tauri\binaries" if not exist "src-tauri\binaries" mkdir "src-tauri\binaries"
copy /y dist\daw_engine.exe "src-tauri\binaries\daw_engine-x86_64-pc-windows-msvc.exe" >nul copy /y dist\daw_engine.exe "src-tauri\binaries\daw_engine-x86_64-pc-windows-msvc.exe" >nul
echo [6/6] Build Tauri installer (NSIS + MSI)... echo [6/6] Build Tauri installer...
npm install -D @tauri-apps/cli@^2 >nul 2>nul npm install -D @tauri-apps/cli@^2 >nul 2>nul
call npx tauri build call npx tauri build
echo. echo.
echo HOAN TAT Installer: echo HOAN TAT - Installer:
echo src-tauri\target\release\bundle\nsis\SonicForgeDAW_1.0.0_x64-setup.exe echo src-tauri\target\release\bundle\nsis\SonicForgeDAW_1.0.0_x64-setup.exe
echo src-tauri\target\release\bundle\msi\SonicForgeDAW_1.0.0_x64_en-US.msi echo src-tauri\target\release\bundle\msi\SonicForgeDAW_1.0.0_x64_en-US.msi
pause pause
+6
View File
@@ -2978,3 +2978,9 @@
- **FIX:** (1) `build_windows.bat` — script 1 lệnh: kiểm tra Python/Node → TỰ CÀI Rust (rustup -y) nếu thiếu → pip deps (+ pedalboard --no-deps) → Babel → pyinstaller engine.spec → copy sidecar → npx tauri build; (2) `BUILD_WINDOWS.md` — yêu cầu (Python, Node, Rust MSVC, VS Build Tools C++, WebView2) + build thủ công + checklist kiểm thử theo spec IV. - **FIX:** (1) `build_windows.bat` — script 1 lệnh: kiểm tra Python/Node → TỰ CÀI Rust (rustup -y) nếu thiếu → pip deps (+ pedalboard --no-deps) → Babel → pyinstaller engine.spec → copy sidecar → npx tauri build; (2) `BUILD_WINDOWS.md` — yêu cầu (Python, Node, Rust MSVC, VS Build Tools C++, WebView2) + build thủ công + checklist kiểm thử theo spec IV.
- **Các file ảnh hưởng:** build_windows.bat, BUILD_WINDOWS.md, wiki.md. - **Các file ảnh hưởng:** build_windows.bat, BUILD_WINDOWS.md, wiki.md.
- **Ghi chú/Test:** trên máy Windows: chạy `build_windows.bat` (cmd) → sinh setup.exe; CI (windows-latest — dtolnay/rust-toolchain) không bị lỗi này. - **Ghi chú/Test:** trên máy Windows: chạy `build_windows.bat` (cmd) → sinh setup.exe; CI (windows-latest — dtolnay/rust-toolchain) không bị lỗi này.
### [2026-08-08 08:50] Task: FIX build_windows.bat — lỗi "was unexpected at this time"
- **Lỗi:** `.\build_windows.bat``... was unexpected at this time.` — batch parse: dấu `(` `)` trong chuỗi echo (vd `(tick "Add to PATH")`) phá block `(...)`; `|| ( ... )` kết hợp cũng rủi ro.
- **FIX:** viết lại batch an toàn: bỏ mọi ngoặc trong echo, dùng `if errorlevel 1 ( ... )` thuần, echo KHÔNG DẤU (tránh codepage), quote `"pedalboard>=0.8.0"` (dấu `>` = redirect trong cmd).
- **Các file ảnh hưởng:** build_windows.bat, wiki.md.
- **Ghi chú/Test:** chạy lại `build_windows.bat` trên Windows — hết lỗi parse; nếu thiếu Rust → tự cài rustup rồi tiếp tục.