#!/bin/bash # VT_Player Universal Build Script # Auto-detects platform and builds accordingly set -e PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo "════════════════════════════════════════════════════════════════" echo " VT_Player Universal Build Script" echo "════════════════════════════════════════════════════════════════" echo "" # Detect platform PLATFORM="$(uname -s)" case "${PLATFORM}" in Linux*) OS="Linux" ;; Darwin*) OS="macOS" ;; CYGWIN*|MINGW*|MSYS*) OS="Windows" ;; *) echo "❌ Unknown platform: ${PLATFORM}" exit 1 ;; esac echo "🔍 Detected platform: $OS" echo "" # Check if go is installed if ! command -v go &> /dev/null; then echo "❌ ERROR: Go is not installed. Please install Go 1.21 or later." echo "" echo "Download from: https://go.dev/dl/" exit 1 fi echo "📦 Go version:" go version echo "" # Route to appropriate build script case "$OS" in Linux) echo "→ Building for Linux..." echo "" exec "$SCRIPT_DIR/build-linux.sh" ;; macOS) echo "→ Building for macOS..." echo "" # macOS uses same build process as Linux (native build) exec "$SCRIPT_DIR/build-linux.sh" ;; Windows) echo "→ Building for Windows..." echo "" # Check if running in Git Bash or similar if command -v go.exe &> /dev/null; then # Windows native build cd "$PROJECT_ROOT" echo "🧹 Cleaning previous builds..." rm -f vt_player.exe VTPlayer.exe 2>/dev/null || true echo "✓ Cache cleaned" echo "" echo "⬇️ Downloading dependencies..." go mod download echo "✓ Dependencies downloaded" echo "" echo "🔨 Building VT_Player for Windows..." export CGO_ENABLED=1 # Build with Windows GUI flags if go build -ldflags="-H windowsgui -s -w" -o vt_player.exe .; then echo "✓ Build successful!" echo "" echo "════════════════════════════════════════════════════════════════" echo "✅ BUILD COMPLETE" echo "════════════════════════════════════════════════════════════════" echo "" echo "Output: vt_player.exe" if [ -f "vt_player.exe" ]; then SIZE=$(du -h vt_player.exe 2>/dev/null | cut -f1 || echo "unknown") echo "Size: $SIZE" fi echo "" if ffmpeg -version >/dev/null 2>&1 && ffprobe -version >/dev/null 2>&1; then echo "✓ FFmpeg detected on PATH" echo "" echo "Ready to run:" echo " .\\vt_player.exe" else echo "⚠️ FFmpeg not detected on PATH" echo "" echo "VT_Player requires FFmpeg. Please install it:" echo " 1. Download from: https://ffmpeg.org/download.html" echo " 2. Add to PATH" echo " Or if VideoTools is installed, FFmpeg should already be available." fi else echo "❌ Build failed!" exit 1 fi else echo "❌ ERROR: go.exe not found." echo "Please ensure Go is properly installed on Windows." echo "Download from: https://go.dev/dl/" exit 1 fi ;; esac