|
| 1 | +@echo off |
| 2 | +REM build_windows.bat |
| 3 | +REM Windows build script for KokoroTTSGenerator using uv and pyinstaller |
| 4 | + |
| 5 | +REM Exit on error |
| 6 | +setlocal enabledelayedexpansion |
| 7 | +set ERRLEV=0 |
| 8 | + |
| 9 | +REM Check for cmake |
| 10 | +where cmake >nul 2>nul |
| 11 | +if errorlevel 1 ( |
| 12 | + echo Error: cmake is not installed. Please install it (e.g., choco install cmake) and try again. |
| 13 | + exit /b 1 |
| 14 | +) |
| 15 | + |
| 16 | +REM Ensure we're in the script's directory |
| 17 | +cd /d "%~dp0" |
| 18 | + |
| 19 | +REM Clean previous build artifacts |
| 20 | +if exist build rmdir /s /q build |
| 21 | +if exist dist rmdir /s /q dist |
| 22 | +if exist KokoroTTSGenerator.spec del /q KokoroTTSGenerator.spec |
| 23 | + |
| 24 | +REM Build UPX from source if not already built |
| 25 | +if not exist external\upx\src\upx.exe ( |
| 26 | + echo Building UPX from source... |
| 27 | + if not exist external\upx ( |
| 28 | + git clone https://github.com/upx/upx.git external\upx |
| 29 | + if errorlevel 1 ( |
| 30 | + echo Error: Failed to clone UPX repository. |
| 31 | + exit /b 1 |
| 32 | + ) |
| 33 | + ) |
| 34 | + pushd external\upx |
| 35 | + git submodule update --init |
| 36 | + REM On Windows, building UPX requires MSYS2/MinGW or MSVC. You may need to build manually. |
| 37 | + echo Please build UPX manually for Windows if not already built. Press any key to continue... |
| 38 | + pause |
| 39 | + popd |
| 40 | +) else ( |
| 41 | + echo UPX already built, skipping build. |
| 42 | +) |
| 43 | + |
| 44 | +REM Run PyInstaller with UPX for compression |
| 45 | +REM Note: --strip is ignored on Windows, but kept for parity. |
| 46 | +uv run pyinstaller app.py ^ |
| 47 | + -n KokoroTTSGenerator ^ |
| 48 | + --noconfirm ^ |
| 49 | + --clean ^ |
| 50 | + --collect-all "en_core_web_sm" ^ |
| 51 | + --add-data "src;src" ^ |
| 52 | + --add-data ".venv/Lib/site-packages/nicegui;nicegui" ^ |
| 53 | + --add-data ".venv/Lib/site-packages/language_data;language_data" ^ |
| 54 | + --add-data ".venv/Lib/site-packages/language_tags;language_tags" ^ |
| 55 | + --add-data ".venv/Lib/site-packages/espeakng_loader;espeakng_loader" ^ |
| 56 | + --add-data ".venv/Lib/site-packages/en_core_web_sm;en_core_web_sm" ^ |
| 57 | + --add-data ".venv/Lib/site-packages/espeakng_loader-0.2.4.dist-info;espeakng_loader-0.2.4.dist-info" ^ |
| 58 | + --add-data ".venv/Lib/site-packages/misaki;misaki" ^ |
| 59 | + --icon=icon.ico ^ |
| 60 | + --upx-dir=external\upx\src |
| 61 | + |
| 62 | +if errorlevel 1 ( |
| 63 | + echo Build failed. |
| 64 | + exit /b 1 |
| 65 | +) |
| 66 | + |
| 67 | +echo Build complete. Executable is in the dist\ directory. |
| 68 | +exit /b 0 |
0 commit comments