Files
sshclient/build_windows.bat
T
Hermes 01c8d3581a fix: rebuild build_windows.bat without Chinese / dangerous cmd patterns
- Remove all non-ASCII text (cmd default GBK mangles UTF-8)
- Replace 'if errorlevel 1 (' multi-line blocks with 'goto :label'
- Replace 'echo(' with 'echo.'
- Use 'for %%I' to get file size (avoid UTF-8 console findstr issues)
- All error paths now end with explicit exit /b 1

Fixes #1: '涓嬭浇鍦板潃' (mojibake) and '('") parse errors.
2026-07-28 21:04:09 +08:00

116 lines
2.4 KiB
Batchfile

@echo off
REM ============================================
REM SSHClient Windows build script
REM Double-click to produce dist\SSHClient.exe
REM ============================================
REM Force UTF-8 console so non-ASCII paths work
chcp 65001 >nul 2>&1
setlocal
echo.
echo ============================================
echo SSHClient Windows Build Script
echo ============================================
echo.
REM 1. Check Python
python --version >nul 2>&1
if errorlevel 1 goto :no_python
echo [OK] Python found:
python --version
echo.
REM 2. Create venv if missing
if not exist "venv\Scripts\python.exe" goto :create_venv
goto :venv_ready
:create_venv
echo [1/4] Creating virtual environment venv\ ...
python -m venv venv
if errorlevel 1 goto :venv_fail
:venv_ready
call venv\Scripts\activate.bat
if errorlevel 1 goto :activate_fail
echo [OK] venv activated
echo.
REM 3. Install dependencies
echo [2/4] Installing dependencies (first run takes 1-2 minutes)...
python -m pip install --upgrade pip --quiet
if errorlevel 1 goto :pip_fail
pip install -r requirements.txt --quiet
if errorlevel 1 goto :pip_fail
echo [OK] Dependencies ready
echo.
REM 4. Build
echo [3/4] Running PyInstaller...
pyinstaller build.spec --clean --noconfirm
if errorlevel 1 goto :build_fail
REM 5. Done
echo.
echo [4/4] Build complete.
echo.
echo ============================================
echo Output: dist\SSHClient.exe
if exist "dist\SSHClient.exe" (
echo Size:
for %%I in ("dist\SSHClient.exe") do echo %%~zI bytes
) else (
echo WARNING: SSHClient.exe not found in dist\
)
echo ============================================
echo.
echo Copy dist\SSHClient.exe to any Windows PC and double-click to run.
echo.
goto :end
:no_python
echo.
echo [ERROR] Python not found in PATH.
echo Please install Python 3.10+ from:
echo https://www.python.org/downloads/windows/
echo IMPORTANT: Check "Add Python to PATH" during install.
echo.
pause
exit /b 1
:venv_fail
echo.
echo [ERROR] Failed to create venv.
echo.
pause
exit /b 1
:activate_fail
echo.
echo [ERROR] Failed to activate venv.
echo.
pause
exit /b 1
:pip_fail
echo.
echo [ERROR] Failed to install dependencies.
echo Check your network connection and try again.
echo.
pause
exit /b 1
:build_fail
echo.
echo [ERROR] PyInstaller build failed.
echo Scroll up to see the error details.
echo.
pause
exit /b 1
:end
pause
endlocal