1+ #! /bin/bash
2+ #
3+ # A reliable script to build and run the Rust Chess Engine GUI locally.
4+ # This script handles dependency checks and uses the correct flags for compatibility.
5+ #
6+
7+ set -e
8+
9+ echo " --- Rust Chess Engine GUI Runner ---"
10+
11+ # --- 1. Dependency Check ---
12+ # Check for required system libraries and prompt for installation if missing.
13+ echo " [1/3] Checking for required system libraries..."
14+ LIBS_TO_CHECK=" pkg-config libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libgl1-mesa-dev libwayland-dev libxkbcommon-dev"
15+ MISSING_LIBS=" "
16+ for LIB in $LIBS_TO_CHECK ; do
17+ if ! dpkg -s " $LIB " & > /dev/null; then
18+ MISSING_LIBS=" $MISSING_LIBS $LIB "
19+ fi
20+ done
21+
22+ if [ ! -z " $MISSING_LIBS " ]; then
23+ echo " WARNING: The following required libraries are missing:$MISSING_LIBS "
24+ read -p " Would you like to try and install them now? (y/N) " -n 1 -r
25+ echo
26+ if [[ $REPLY =~ ^[Yy]$ ]]; then
27+ sudo apt-get update
28+ sudo apt-get install -y $MISSING_LIBS
29+ else
30+ echo " Installation cancelled. The build may fail."
31+ fi
32+ else
33+ echo " All system libraries are present."
34+ fi
35+
36+ # --- 2. Build the Application ---
37+ echo " [2/3] Building the application with Cargo..."
38+ cargo build -p chess-gui --bin best
39+ echo " Build complete."
40+
41+ # --- 3. Run the Application ---
42+ # Use the WGPU_BACKEND=gl flag to ensure maximum graphics compatibility on Linux.
43+ echo " [3/3] Starting the chess application..."
44+ echo " ----------------------------------------"
45+ WGPU_BACKEND=gl ./target/debug/best
0 commit comments