@echo off
echo ===============================================
echo  Building Scale RS232 Reader v2.2 Ultra Large Display
echo ===============================================
echo.

echo [1/4] Cleaning previous builds...
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
if exist __pycache__ rmdir /s /q __pycache__

echo [2/4] Installing dependencies...
pip install -r requirements.txt
pip install pyinstaller

echo [3/4] Building executable...
pyinstaller ScaleRS232Reader_v2.spec

echo [4/4] Checking build result...
if exist "dist\ScaleRS232Reader_v2.exe" (
    echo.
    echo ===============================================
    echo  BUILD SUCCESSFUL!
    echo ===============================================
    echo  Executable: dist\ScaleRS232Reader_v2.exe
    echo  Size: 
    dir "dist\ScaleRS232Reader_v2.exe" | findstr "ScaleRS232Reader_v2.exe"
    echo.
    echo  You can now run: dist\ScaleRS232Reader_v2.exe
    echo ===============================================
) else (
    echo.
    echo ===============================================
    echo  BUILD FAILED!
    echo ===============================================
    echo  Please check the error messages above.
    echo ===============================================
)

pause
