summaryrefslogtreecommitdiff
path: root/gui/gtk/scripts
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-09 22:45:24 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-09 22:45:24 +0800
commitc9ff9a13735010a6d3937a05e8ce9f00f9fab3ac (patch)
tree77ad04e6db77aa037513e4d22866a89f9cf52403 /gui/gtk/scripts
parent25761b5ef0d9d385ac2a371b62913f98350d6f56 (diff)
Add GTK GUI build system for Unix platforms
Diffstat (limited to 'gui/gtk/scripts')
-rwxr-xr-xgui/gtk/scripts/_entry.sh90
-rwxr-xr-xgui/gtk/scripts/build.sh37
-rwxr-xr-xgui/gtk/scripts/clean.sh31
-rwxr-xr-xgui/gtk/scripts/run.sh37
4 files changed, 195 insertions, 0 deletions
diff --git a/gui/gtk/scripts/_entry.sh b/gui/gtk/scripts/_entry.sh
new file mode 100755
index 0000000..a80788e
--- /dev/null
+++ b/gui/gtk/scripts/_entry.sh
@@ -0,0 +1,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
diff --git a/gui/gtk/scripts/build.sh b/gui/gtk/scripts/build.sh
new file mode 100755
index 0000000..ae8aebf
--- /dev/null
+++ b/gui/gtk/scripts/build.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Butchunker GTK Build Script
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
+BUILD_DIR="$PROJECT_ROOT/build"
+
+# Check if GTK3 is available
+if ! pkg-config --exists gtk+-3.0; then
+ echo "Error: GTK3 development files not found!"
+ echo "Please install GTK3 development packages:"
+ echo " Ubuntu/Debian: sudo apt-get install libgtk-3-dev"
+ echo " Fedora: sudo dnf install gtk3-devel"
+ echo " Arch: sudo pacman -S gtk3"
+ exit 1
+fi
+
+# Create build directory
+mkdir -p "$BUILD_DIR"
+
+# Navigate to build directory
+cd "$BUILD_DIR" || exit 1
+
+# Run CMake
+if ! cmake ..; then
+ exit 1
+fi
+
+# Run make
+if ! make -j$(nproc); then
+ echo "Make failed!"
+ exit 1
+fi
+
+# Check if Rust library exists
+RUST_LIB="$PROJECT_ROOT/../../.temp/target/release/lib_butck.so"
diff --git a/gui/gtk/scripts/clean.sh b/gui/gtk/scripts/clean.sh
new file mode 100755
index 0000000..1c8aa5a
--- /dev/null
+++ b/gui/gtk/scripts/clean.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Butchunker GTK Clean Script
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
+BUILD_DIR="$PROJECT_ROOT/build"
+
+# Remove build directory if it exists
+if [ -d "$BUILD_DIR" ]; then
+ rm -rf "$BUILD_DIR"
+fi
+
+# Also clean any other generated files
+
+# Remove CMake cache files if they exist outside build directory
+if [ -f "$PROJECT_ROOT/CMakeCache.txt" ]; then
+ rm -f "$PROJECT_ROOT/CMakeCache.txt"
+fi
+
+if [ -d "$PROJECT_ROOT/CMakeFiles" ]; then
+ rm -rf "$PROJECT_ROOT/CMakeFiles"
+fi
+
+if [ -f "$PROJECT_ROOT/cmake_install.cmake" ]; then
+ rm -f "$PROJECT_ROOT/cmake_install.cmake"
+fi
+
+if [ -f "$PROJECT_ROOT/Makefile" ]; then
+ rm -f "$PROJECT_ROOT/Makefile"
+fi
diff --git a/gui/gtk/scripts/run.sh b/gui/gtk/scripts/run.sh
new file mode 100755
index 0000000..e5f60b7
--- /dev/null
+++ b/gui/gtk/scripts/run.sh
@@ -0,0 +1,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