secondvoice/setup_mingw.bat
StillHammer 94ad6b4a22 feat: Add MinGW support - Build without Visual Studio!
Lightweight Windows build option using MinGW-w64 instead of Visual Studio:

Size Comparison:
- Visual Studio: 10-20 GB install
- MinGW: ~500 MB install (20x smaller!)

New Files:
- setup_mingw.bat: One-click installer for all tools
  - Chocolatey (package manager)
  - MinGW-w64 (GCC compiler)
  - CMake, Ninja, Git
  - vcpkg integration

- build_mingw.bat: Build script for MinGW
  - Auto-detection of GCC
  - Debug/Release modes
  - Clean build support
  - User-friendly error messages

- WINDOWS_MINGW.md: Complete MinGW guide
  - Installation instructions
  - Troubleshooting
  - Performance comparison MSVC vs GCC
  - Distribution guide

CMake Updates:
- Added mingw-debug and mingw-release presets
- GCC compiler flags: -O3 -Wall -Wextra
- Static linking for portable .exe

Documentation:
- Updated WINDOWS_QUICK_START.md with MinGW option
- Comparison table: MinGW vs Visual Studio
- Recommendation: MinGW for most users

Benefits:
- 20x smaller download (500MB vs 10-20GB)
- 5-10 min install vs 30-60 min
- Same performance as MSVC
- Portable standalone .exe
- Perfect for users without Visual Studio

Usage:
1. Run setup_mingw.bat (one time)
2. Restart terminal
3. Run build_mingw.bat --release
4. Done!

Output: build/mingw-release/SecondVoice.exe

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 03:42:41 +08:00

184 lines
4.2 KiB
Batchfile

@echo off
REM MinGW Setup Script for SecondVoice
REM This installs a lightweight compiler instead of Visual Studio
echo ========================================
echo SecondVoice - MinGW Setup
echo ========================================
echo.
echo This script will install:
echo - MinGW-w64 (GCC compiler for Windows)
echo - CMake (build system)
echo - Ninja (build tool)
echo - Git (if not installed)
echo.
echo Total size: ~500MB (vs 10GB+ for Visual Studio!)
echo.
pause
REM Check if running as admin
net session >nul 2>&1
if %errorlevel% neq 0 (
echo [WARNING] Not running as administrator
echo Some installations might fail. Recommended to run as admin.
echo.
pause
)
REM Install chocolatey if not present
where choco >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] Installing Chocolatey package manager...
echo.
powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"
if %errorlevel% neq 0 (
echo [ERROR] Failed to install Chocolatey
echo Please install manually: https://chocolatey.org/install
pause
exit /b 1
)
echo [SUCCESS] Chocolatey installed!
echo.
REM Refresh environment
refreshenv
)
echo [INFO] Chocolatey found
echo.
REM Install MinGW-w64
where gcc >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] Installing MinGW-w64 (GCC compiler)...
choco install mingw -y
if %errorlevel% neq 0 (
echo [ERROR] Failed to install MinGW
pause
exit /b 1
)
echo [SUCCESS] MinGW installed!
echo.
) else (
echo [INFO] GCC already installed
gcc --version
echo.
)
REM Install CMake
where cmake >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] Installing CMake...
choco install cmake -y --installargs 'ADD_CMAKE_TO_PATH=System'
if %errorlevel% neq 0 (
echo [ERROR] Failed to install CMake
pause
exit /b 1
)
echo [SUCCESS] CMake installed!
echo.
) else (
echo [INFO] CMake already installed
cmake --version
echo.
)
REM Install Ninja
where ninja >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] Installing Ninja...
choco install ninja -y
if %errorlevel% neq 0 (
echo [ERROR] Failed to install Ninja
pause
exit /b 1
)
echo [SUCCESS] Ninja installed!
echo.
) else (
echo [INFO] Ninja already installed
ninja --version
echo.
)
REM Install Git (if not present)
where git >nul 2>&1
if %errorlevel% neq 0 (
echo [INFO] Installing Git...
choco install git -y
if %errorlevel% neq 0 (
echo [ERROR] Failed to install Git
pause
exit /b 1
)
echo [SUCCESS] Git installed!
echo.
) else (
echo [INFO] Git already installed
git --version
echo.
)
REM Setup vcpkg if not present
if not defined VCPKG_ROOT (
if not exist "C:\vcpkg" (
echo [INFO] Installing vcpkg...
cd C:\
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
call bootstrap-vcpkg.bat
if %errorlevel% neq 0 (
echo [ERROR] Failed to bootstrap vcpkg
pause
exit /b 1
)
echo [SUCCESS] vcpkg installed!
echo.
)
echo [INFO] Setting VCPKG_ROOT environment variable...
setx VCPKG_ROOT "C:\vcpkg"
set VCPKG_ROOT=C:\vcpkg
echo [SUCCESS] VCPKG_ROOT set to C:\vcpkg
echo.
) else (
echo [INFO] vcpkg already configured at: %VCPKG_ROOT%
echo.
)
echo ========================================
echo [SUCCESS] Setup Complete!
echo ========================================
echo.
echo Installed tools:
where gcc
where cmake
where ninja
where git
echo VCPKG_ROOT=%VCPKG_ROOT%
echo.
echo ========================================
echo Next Steps:
echo ========================================
echo 1. Close and reopen this terminal (to reload PATH)
echo 2. Run: build_mingw.bat --release
echo 3. Your .exe will be in: build\mingw-release\SecondVoice.exe
echo.
echo Total installation size: ~500MB
echo (vs 10GB+ for Visual Studio!)
echo.
pause