summaryrefslogtreecommitdiff
path: root/gui/gtk/scripts/_entry.sh
blob: a80788e233a72b8414b7ed604e2cb298ad48c734 (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 Entry Script
# This script sets up the environment and generates .clangd configuration

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

# Get GTK include paths
GTK_INCLUDE_PATHS=""
if pkg-config --exists gtk+-3.0; then
    # Get include paths from pkg-config and split them
    GTK_INCLUDE_PATHS=$(pkg-config --cflags-only-I gtk+-3.0)
fi

# Get Rust library include path
RUST_INCLUDE_PATH="$PROJECT_ROOT/../../.temp/target/release"

# Generate .clangd configuration file
CLANGD_CONTENT="CompileFlags:
  CompilationDatabase: build/
  Add:
    - -I\${workspaceFolder}/include"

# Add GTK include paths
if [ -n "$GTK_INCLUDE_PATHS" ]; then
    # Process each -I flag separately
    for flag in $GTK_INCLUDE_PATHS; do
        if [[ "$flag" == -I* ]]; then
            path="${flag#-I}"
            CLANGD_CONTENT="$CLANGD_CONTENT
    - -I$path"
        fi
    done
fi

# Add Rust include path
CLANGD_CONTENT="$CLANGD_CONTENT
    - -I\${workspaceFolder}/../../.temp/target/release
  Remove: []

Diagnostics:
  ClangTidy:
    Add:
      - \"*\"
    Remove:
      - modernize-use-trailing-return-type
  UnusedIncludes: Strict

Index:
  Background: Build
"

# Write .clangd file
CLANGD_PATH="$PROJECT_ROOT/.clangd"
echo "$CLANGD_CONTENT" > "$CLANGD_PATH"
echo "Generated .clangd configuration at: $CLANGD_PATH"

# Source common functions if exists
if [ -f "$SCRIPT_DIR/_common.sh" ]; then
    source "$SCRIPT_DIR/_common.sh"
fi

# Default action
ACTION="${1:-help}"

case "$ACTION" in
    "build")
        echo "Building Butchunker GTK..."
        "$SCRIPT_DIR/build.sh"
        ;;
    "clean")
        echo "Cleaning Butchunker GTK..."
        "$SCRIPT_DIR/clean.sh"
        ;;
    "run")
        echo "Running Butchunker GTK..."
        "$SCRIPT_DIR/run.sh"
        ;;
    "help"|*)
        echo "Butchunker GTK Build System"
        echo "Usage: $0 [build|clean|run]"
        echo ""
        echo "Commands:"
        echo "  build  - Build the project"
        echo "  clean  - Clean build directory"
        echo "  run    - Run the application"
        exit 0
        ;;
esac