@echo off setlocal set BINARY_NAME=opencode-monitor set VERSION=dev if "%1"=="--only-ble" goto only_ble if "%1"=="--ble" goto ble goto all_platforms :only_ble echo === Building BLE relay only === python -m pip install pyinstaller bleak if not exist bin mkdir bin python -m PyInstaller --onefile --name ble_relay --distpath bin --specpath build --workpath build scripts\ble_relay.py copy /Y bin\ble_relay.exe cmd\monitor\ble_relay.exe >nul echo. echo Done: bin\ble_relay.exe + cmd\monitor\ble_relay.exe goto end :ble echo === Building current platform with BLE === echo Step 1: Building BLE relay... python -m pip install pyinstaller bleak if not exist bin mkdir bin python -m PyInstaller --onefile --name ble_relay --distpath bin --specpath build --workpath build scripts\ble_relay.py copy /Y bin\ble_relay.exe cmd\monitor\ble_relay.exe >nul echo Step 2: Building Go binary with BLE embedded... go mod tidy if not exist dist mkdir dist REM Detect architecture if "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( set GOARCH=arm64 set SUFFIX=-windows-arm64.exe ) else ( set GOARCH=amd64 set SUFFIX=-windows-amd64.exe ) set GOOS=windows go build -tags ble -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%%SUFFIX% .\cmd\monitor del /Q cmd\monitor\ble_relay.exe 2>nul echo. echo Done: dist\%BINARY_NAME%%SUFFIX% goto end :all_platforms echo === Building all platforms (no BLE) === if not exist dist mkdir dist go mod tidy echo Building for Linux (amd64)... set GOOS=linux set GOARCH=amd64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-linux-amd64 .\cmd\monitor echo Building for Linux (arm64)... set GOARCH=arm64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-linux-arm64 .\cmd\monitor echo Building for macOS (amd64)... set GOOS=darwin set GOARCH=amd64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-darwin-amd64 .\cmd\monitor echo Building for macOS (arm64)... set GOARCH=arm64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-darwin-arm64 .\cmd\monitor echo Building for Windows (amd64)... set GOOS=windows set GOARCH=amd64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-windows-amd64.exe .\cmd\monitor echo Building for Windows (arm64)... set GOARCH=arm64 go build -ldflags "-X main.Version=%VERSION%" -o dist\%BINARY_NAME%-windows-arm64.exe .\cmd\monitor echo. echo Done! Binaries in dist\ dir dist\ :end endlocal