summaryrefslogtreecommitdiff
path: root/gui/gtk/cbuild.sh
blob: cf3aeaf23826d70a7f1cb8607dc560b59de71c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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 $?