@echo off
setlocal enabledelayedexpansion

REM Set the OpenVR include path
set OPENVR_INCLUDE=..\..\headers

REM Set the output directory
set OUTPUT_DIR=bin\win64

REM Create the output directory if it doesn't exist
if not exist %OUTPUT_DIR% mkdir %OUTPUT_DIR%

REM Set the compiler flags
set CFLAGS=/nologo /EHsc /MD /O2 /W4 /I"%OPENVR_INCLUDE%" /D_CRT_SECURE_NO_WARNINGS

REM Set the linker flags
set LFLAGS=/DLL /OUT:"%OUTPUT_DIR%\driver_sauna.dll"

REM Set the source files
set SOURCES=driver_sauna.cpp lighthouse_driver_wrapper.cpp imu_data_provider.cpp sauna_device_driver.cpp

REM Compile the driver
echo Compiling Sauna Driver...
cl %CFLAGS% %SOURCES% /link %LFLAGS%

REM Check if the compilation was successful
if %ERRORLEVEL% NEQ 0 (
    echo Error: Compilation failed.
    exit /b 1
)

REM Copy the driver manifest to the output directory
echo Copying driver manifest...
copy driver.vrdrivermanifest %OUTPUT_DIR%\driver.vrdrivermanifest

echo Build completed successfully.
echo Driver is located at: %OUTPUT_DIR%\driver_sauna.dll

endlocal