Changes: - Removed -modcache flag that was deleting Go modules unnecessarily - Changed from -cache -modcache -testcache to just go clean - Added automatic system dependency detection (X11 libs) - Will attempt to install missing deps automatically if found - Keeps Go module cache intact between builds for faster compilation This fixes the issue where builds would fail after cache cleaning due to missing Go modules, while still checking for required system libraries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
102 lines
3.3 KiB
Bash
Executable File
102 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# VT_Player Build Script
|
|
# Builds the application with proper dependency checking
|
|
|
|
set -e
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BUILD_OUTPUT="$PROJECT_ROOT/vt_player"
|
|
|
|
echo "════════════════════════════════════════════════════════════════"
|
|
echo " VT_Player Build Script"
|
|
echo "════════════════════════════════════════════════════════════════"
|
|
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."
|
|
exit 1
|
|
fi
|
|
|
|
echo "📦 Go version:"
|
|
go version
|
|
echo ""
|
|
|
|
# Change to project directory
|
|
cd "$PROJECT_ROOT"
|
|
|
|
# Check for system dependencies (X11 development libraries)
|
|
echo "🔍 Checking system dependencies..."
|
|
MISSING_DEPS=()
|
|
|
|
# Check for essential X11 libraries needed by Fyne/GLFW
|
|
if ! pkg-config --exists x11 2>/dev/null; then
|
|
MISSING_DEPS+=("libX11-devel")
|
|
fi
|
|
if ! pkg-config --exists xcursor 2>/dev/null; then
|
|
MISSING_DEPS+=("libXcursor-devel")
|
|
fi
|
|
if ! pkg-config --exists xrandr 2>/dev/null; then
|
|
MISSING_DEPS+=("libXrandr-devel")
|
|
fi
|
|
if ! pkg-config --exists gl 2>/dev/null; then
|
|
MISSING_DEPS+=("mesa-libGL-devel")
|
|
fi
|
|
|
|
if [ ${#MISSING_DEPS[@]} -gt 0 ]; then
|
|
echo "⚠️ Missing system dependencies: ${MISSING_DEPS[*]}"
|
|
echo "📥 Attempting to install dependencies..."
|
|
|
|
if [ -f "$PROJECT_ROOT/scripts/install-deps-linux.sh" ]; then
|
|
bash "$PROJECT_ROOT/scripts/install-deps-linux.sh" || {
|
|
echo "❌ Failed to install dependencies automatically"
|
|
echo "Please run: sudo bash $PROJECT_ROOT/scripts/install-deps-linux.sh"
|
|
exit 1
|
|
}
|
|
else
|
|
echo "❌ Dependency installer not found"
|
|
echo "Please install missing packages manually: ${MISSING_DEPS[*]}"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "✓ System dependencies OK"
|
|
fi
|
|
echo ""
|
|
|
|
echo "🧹 Cleaning previous build..."
|
|
rm -f "$BUILD_OUTPUT" 2>/dev/null || true
|
|
go clean 2>/dev/null || true
|
|
echo "✓ Cleaned"
|
|
echo ""
|
|
|
|
echo "⬇️ Ensuring Go modules are downloaded..."
|
|
go mod download
|
|
go mod verify
|
|
echo "✓ Dependencies ready"
|
|
echo ""
|
|
|
|
echo "🔨 Building VT_Player..."
|
|
# Fyne needs cgo for GLFW/OpenGL bindings; build with CGO enabled.
|
|
export CGO_ENABLED=1
|
|
if go build -o "$BUILD_OUTPUT" .; then
|
|
echo "✓ Build successful!"
|
|
echo ""
|
|
echo "════════════════════════════════════════════════════════════════"
|
|
echo "✅ BUILD COMPLETE"
|
|
echo "════════════════════════════════════════════════════════════════"
|
|
echo ""
|
|
echo "Output: $BUILD_OUTPUT"
|
|
echo "Size: $(du -h "$BUILD_OUTPUT" | cut -f1)"
|
|
echo ""
|
|
echo "To run:"
|
|
echo " $PROJECT_ROOT/vt_player"
|
|
echo ""
|
|
echo "Or use the convenience script:"
|
|
echo " source $PROJECT_ROOT/scripts/alias.sh"
|
|
echo " vt_player"
|
|
echo ""
|
|
else
|
|
echo "❌ Build failed!"
|
|
exit 1
|
|
fi
|