@echo off

REM Download ONNX Runtime
echo Downloading ONNX Runtime...
powershell -Command "Invoke-WebRequest -Uri 'https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x64-1.17.1.zip' -OutFile 'onnxruntime.zip'"

REM Unzip ONNX Runtime
echo Unzipping ONNX Runtime...
powershell -Command "Expand-Archive -Path 'onnxruntime.zip' -DestinationPath 'onnxruntime'"

REM Get Root Directory
for /d %%D in (onnxruntime\*) do set rootDir=%%D
echo Root directory of the unzipped file is: %rootDir%

REM Run CMake
echo Running CMake...
cmake -S . -B .build/ -G "Visual Studio 17 2022" ^
  -DSAM_STATIC_ANN_ONNX_MODELPATH="dummy.onnx" ^
  -DSAM_STATIC_ANN_STANDARDIZE_PARAMS="dummy.pkl" ^
  -DSAM_STATIC_CNN_COLORMAP="dummy.npy" ^
  -DSAM_ONNXRUNTIME_ROOTDIR="%rootDir%" ^
  -DSAM_STATIC_CNN_ONNX_MODELPATH="dummy.onnx" ^
  -DSAM_DYNAMIC_CNN_BIGRU_ONNX_MODELPATH="dummy.onnx" ^
  -DSAM_BUILD_TESTS=ON ^
  -DSAM_BUILD_CLI_TOOLS=ON ^
  -DSAM_LINK_CONSOLE=OFF

REM Build the Engine
echo Building the Engine...
cmake --build .build/ --config Debug

echo Done.
pause
