@echo off
REM DragonX Wallet - Windows Build Script (Native MSVC/MinGW)
REM Run from Visual Studio Developer Command Prompt or MSYS2 MinGW64

setlocal enabledelayedexpansion

echo DragonX Wallet - Windows Build
echo ==============================

REM Check for CMake
where cmake >nul 2>nul
if %errorlevel% neq 0 (
    echo Error: CMake not found! Please install CMake and add to PATH.
    exit /b 1
)

REM Create build directory
if not exist build-win mkdir build-win
cd build-win

REM Detect compiler
where cl >nul 2>nul
if %errorlevel% equ 0 (
    echo Using MSVC compiler
    set GENERATOR=-G "Visual Studio 17 2022" -A x64
) else (
    where gcc >nul 2>nul
    if %errorlevel% equ 0 (
        echo Using MinGW/GCC compiler
        set GENERATOR=-G "MinGW Makefiles"
    ) else (
        echo Error: No compiler found! Run from VS Developer Command Prompt or MSYS2.
        exit /b 1
    )
)

echo.
echo Configuring with CMake...
cmake .. %GENERATOR% -DCMAKE_BUILD_TYPE=Release -DDRAGONX_USE_SYSTEM_SDL3=OFF

if %errorlevel% neq 0 (
    echo CMake configuration failed!
    exit /b 1
)

echo.
echo Building...
cmake --build . --config Release --parallel

if %errorlevel% neq 0 (
    echo Build failed!
    exit /b 1
)

echo.
echo Build successful!
echo Output: build-win\bin\Release\ObsidianDragon.exe (MSVC)
echo    or: build-win\bin\ObsidianDragon.exe (MinGW)

endlocal
