summaryrefslogtreecommitdiff
path: root/gui/gtk/scripts/run.sh
blob: e5f60b790b4b585845988945f151113e21582822 (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
#!/bin/bash

# Butchunker GTK Run Script

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
BUILD_DIR="$PROJECT_ROOT/build"
EXECUTABLE="$BUILD_DIR/bin/butckg"

# Check if executable exists
if [ ! -f "$EXECUTABLE" ]; then
    exit 1
fi

# Check if executable is executable
if [ ! -x "$EXECUTABLE" ]; then
    chmod +x "$EXECUTABLE"
fi

# Check if Rust library exists and copy it if needed
RUST_LIB="$PROJECT_ROOT/../../.temp/target/release/lib_butck.so"
if [ -f "$RUST_LIB" ]; then
    # Copy library to executable directory if not already there
    LIB_DEST="$BUILD_DIR/bin/lib_butck.so"
    if [ ! -f "$LIB_DEST" ] || [ "$RUST_LIB" -nt "$LIB_DEST" ]; then
        cp "$RUST_LIB" "$LIB_DEST"
    fi
fi

# Set LD_LIBRARY_PATH to include the build directory
export LD_LIBRARY_PATH="$BUILD_DIR/bin:$LD_LIBRARY_PATH"

# Run the executable
"$EXECUTABLE"

EXIT_CODE=$?
exit $EXIT_CODE