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

mkdir "dist\navis-release\darwin-arm64" 2>nul
mkdir "dist\navis-release\darwin-amd64" 2>nul

set CGO_ENABLED=0
set GOOS=darwin
set GOARCH=arm64
go build -ldflags="-s -w" -o "dist\navis-release\darwin-arm64\Navis" .\cmd\vpnclient
if errorlevel 1 exit /b 1

set GOARCH=amd64
go build -ldflags="-s -w" -o "dist\navis-release\darwin-amd64\Navis" .\cmd\vpnclient
if errorlevel 1 exit /b 1

set GOOS=
set GOARCH=
set CGO_ENABLED=

go build -o "tools\packmac\packmac.exe" .\tools\packmac
if errorlevel 1 exit /b 1

tools\packmac\packmac.exe -bin "dist\navis-release\darwin-arm64\Navis" -out "dist\navis-release\darwin-arm64" -version 1.4.1 -arch arm64
if errorlevel 1 exit /b 1
tools\packmac\packmac.exe -bin "dist\navis-release\darwin-amd64\Navis" -out "dist\navis-release\darwin-amd64" -version 1.4.1 -arch amd64
if errorlevel 1 exit /b 1

echo Built:
dir "dist\navis-release\darwin-arm64"
dir "dist\navis-release\darwin-amd64"
endlocal
