@echo off
REM Adom KiCad Bridge Server - Startup Script
REM Tries system Python first, falls back to KiCad's bundled Python.

echo [Adom KiCad Bridge] Starting server...

REM Try system Python
where python >nul 2>&1
if %ERRORLEVEL% equ 0 (
    echo [Adom KiCad Bridge] Using system Python
    python "%~dp0server.py" %*
    goto :end
)

REM Try KiCad 9.0 bundled Python
set KICAD_PYTHON=C:\Program Files\KiCad\9.0\bin\python.exe
if exist "%KICAD_PYTHON%" (
    echo [Adom KiCad Bridge] Using KiCad 9.0 bundled Python
    "%KICAD_PYTHON%" "%~dp0server.py" %*
    goto :end
)

REM Try KiCad 8.0 bundled Python
set KICAD_PYTHON=C:\Program Files\KiCad\8.0\bin\python.exe
if exist "%KICAD_PYTHON%" (
    echo [Adom KiCad Bridge] Using KiCad 8.0 bundled Python
    "%KICAD_PYTHON%" "%~dp0server.py" %*
    goto :end
)

echo [Adom KiCad Bridge] ERROR: Python not found. Install Python 3.10+ or KiCad 9.0.
pause

:end