#!/bin/bash # Butchunker GTK Build Script # Usage: ./cbuild.sh [build|clean|run|rebuild|env] SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUILD_DIR="$SCRIPT_DIR/build" function setup_environment() { echo "Setting up environment and generating .clangd configuration..." "$SCRIPT_DIR/scripts/_entry.sh" } function build_project() { echo "Building Butchunker GTK..." # Setup environment first setup_environment # Create build directory if it doesn't exist mkdir -p "$BUILD_DIR" # Run CMake and make cd "$BUILD_DIR" if cmake .. && make; then echo "Build successful!" return 0 else echo "Build failed!" return 1 fi } function clean_project() { echo "Cleaning build directory..." rm -rf "$BUILD_DIR" echo "Clean complete!" } function run_project() { echo "Running Butchunker GTK..." # Setup environment first setup_environment # Check if executable exists if [ -f "$BUILD_DIR/bin/butckg" ]; then "$BUILD_DIR/bin/butckg" else echo "Error: Executable not found. Run './cbuild.sh build' first." return 1 fi } function rebuild_project() { clean_project build_project } # Main script logic case "${1:-}" in "build") build_project ;; "clean") clean_project ;; "run") run_project ;; "rebuild") rebuild_project ;; "env") setup_environment ;; *) echo "Usage: $0 [build|clean|run|rebuild|env]" echo "" echo "Commands:" echo " build - Build the project" echo " clean - Clean build directory" echo " run - Build and run the project" echo " rebuild - Clean and rebuild the project" echo " env - Setup environment and generate .clangd config" exit 1 ;; esac exit $?