@echo off
echo Building Medi-WOL for multiple platforms...

REM Erstelle dist-Verzeichnis
if not exist dist mkdir dist

echo Building for Windows AMD64...
go build -ldflags="-s -w" -o dist/medi-wol-windows-amd64.exe cmd/server/main.go

echo Building for Linux AMD64...
set GOOS=linux
set GOARCH=amd64
go build -ldflags="-s -w" -o dist/medi-wol-linux-amd64 cmd/server/main.go

echo Building for Linux ARM64...
set GOOS=linux
set GOARCH=arm64
go build -ldflags="-s -w" -o dist/medi-wol-linux-arm64 cmd/server/main.go

echo Building for Windows ARM64...
set GOOS=windows
set GOARCH=arm64
go build -ldflags="-s -w" -o dist/medi-wol-windows-arm64.exe cmd/server/main.go

REM Zurücksetzen auf Windows AMD64
set GOOS=windows
set GOARCH=amd64

echo.
echo Build complete! Binaries created in dist/ folder:
dir dist

echo.
echo Building Windows Installer with Inno Setup...
if exist "C:\Users\markus.MEDISOFT\AppData\Local\Programs\Inno Setup 6\ISCC.exe" (
    "C:\Users\markus.MEDISOFT\AppData\Local\Programs\Inno Setup 6\ISCC.exe" installer\medi-wol-setup.iss
    if %ERRORLEVEL% EQU 0 (
        echo.
        echo Installer successfully created: dist\medi-wol-setup.exe
    ) else (
        echo.
        echo Error: Failed to create installer
    )
) else (
    echo.
    echo Warning: Inno Setup Compiler not found at expected location
    echo Please install Inno Setup 6 or update the path in build.bat
)

echo.
pause
