#!/bin/bash
set -e

export PATH="$PATH:/usr/local/go/bin"

OUT="bin"
LDFLAGS="-s -w"

mkdir -p "$OUT"

echo "=== Building Linux Client ==="
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o "$OUT/usb-client" ./cmd/usb-client/
echo "  -> $OUT/usb-client"

echo "=== Building Windows Client ==="
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o "$OUT/usb-client.exe" ./cmd/usb-client/
echo "  -> $OUT/usb-client.exe"

echo "=== Building Relay ==="
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o "$OUT/usb-relay" ./cmd/usb-relay/
echo "  -> $OUT/usb-relay"

echo ""
echo "Done. Binaries in $OUT/"
ls -lh "$OUT/"
