@echo off
chcp 65001 >nul
setlocal EnableDelayedExpansion

echo ==========================================
echo  Acoustic Offline Demo Build (Windows)
echo ==========================================

set SRC_ROOT=%~dp0
set EIGEN=%SRC_ROOT%third_party\eigen-3.4.0
set ONNX_INC=%SRC_ROOT%third_party\onnxruntime\include
set ONNX_LIB=%SRC_ROOT%third_party\onnxruntime\lib\libonnxruntime.a

set INCLUDES=-I%SRC_ROOT%include -I%EIGEN% -I%ONNX_INC%
set FLAGS=-std=c++17 -O2 -D_USE_MATH_DEFINES -Wa,-mbig-obj
set LIBS=%ONNX_LIB%

if not exist build mkdir build

echo [1/1] Building demo_offline.exe (simplified, no yaml-cpp dependency) ...
g++ %FLAGS% %INCLUDES% ^
    tests\demo_offline.cpp ^
    src\core\fft_utils.cpp ^
    src\core\feature_extractor.cpp ^
    src\core\distance_estimator.cpp ^
    src\core\gunshot_classifier.cpp ^
    src\io\wav_file_source.cpp ^
    -o build\demo_offline.exe ^
    %LIBS% -D_stdcall=
if %ERRORLEVEL% NEQ 0 (
    echo [FAIL] demo_offline build failed.
    exit /b 1
)

echo.
echo [OK] demo_offline.exe built successfully in build\
echo.
echo Usage: build\demo_offline.exe dataset\binary\val\ambient\xxx.wav
echo        build\demo_offline.exe dataset\binary\val\threat\xxx.wav
endlocal
