#!/bin/bash

# Build TSS Party binary for multiple platforms

set -e

OUTPUT_DIR="../electron/bin"
MODULE_NAME="tss-party"

# Create output directories
mkdir -p "$OUTPUT_DIR/linux-x64"
mkdir -p "$OUTPUT_DIR/darwin-x64"
mkdir -p "$OUTPUT_DIR/darwin-arm64"
mkdir -p "$OUTPUT_DIR/win32-x64"

echo "Building TSS Party binary..."

# Build for Linux x64
echo "Building for Linux x64..."
GOOS=linux GOARCH=amd64 go build -o "$OUTPUT_DIR/linux-x64/$MODULE_NAME" .

# Build for macOS x64 (Intel)
echo "Building for macOS x64..."
GOOS=darwin GOARCH=amd64 go build -o "$OUTPUT_DIR/darwin-x64/$MODULE_NAME" .

# Build for macOS arm64 (Apple Silicon)
echo "Building for macOS arm64..."
GOOS=darwin GOARCH=arm64 go build -o "$OUTPUT_DIR/darwin-arm64/$MODULE_NAME" .

# Build for Windows x64
echo "Building for Windows x64..."
GOOS=windows GOARCH=amd64 go build -o "$OUTPUT_DIR/win32-x64/$MODULE_NAME.exe" .

echo "Build complete!"
echo "Binaries available in $OUTPUT_DIR"
