@echo off
setlocal
cd /d "%~dp0"

echo Generating Windows icon resources...
go run ./tools/mkico
if errorlevel 1 exit /b 1

where goversioninfo >nul 2>&1
if errorlevel 1 (
  go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest
)

goversioninfo -icon assets\navis.ico -o cmd\vpnapp\resource.syso versioninfo.json
if errorlevel 1 exit /b 1

echo Building Navis GUI and CLI...
go build -ldflags="-H windowsgui -s -w" -o Navis.exe ./cmd/vpnapp
if errorlevel 1 exit /b 1

go build -ldflags="-s -w" -o vpnclient.exe ./cmd/vpnclient
if errorlevel 1 exit /b 1

echo.
echo Done:
echo   Navis.exe
echo   vpnclient.exe
echo   assets\navis.ico
endlocal
