Files
cthulhu/build-local.sh

84 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
#
# Build script for Cthulhu screen reader using Meson build system
# This script builds and installs Cthulhu locally to ~/.local
#
set -e # Exit on error
echo "Cthulhu Meson Local Build Script"
echo "Building and installing Cthulhu to ~/.local"
echo "================================================"
# Check if we're in the right directory
if [[ ! -f "meson.build" ]] || [[ ! -f "src/cthulhu/cthulhu.py" ]]; then
echo "Error: This script must be run from the Cthulhu source directory"
exit 1
fi
# Check for required dependencies
echo "Checking dependencies..."
for cmd in meson ninja python3; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: $cmd is not installed"
echo "Please install: meson ninja python"
exit 1
fi
done
# Check for optional dependencies
missingOptional=()
if ! python3 -c "import gi" 2>/dev/null; then
missingOptional+=("python-gi")
fi
if [[ ${#missingOptional[@]} -gt 0 ]]; then
echo "Warning: Optional dependencies missing: ${missingOptional[*]}"
echo "Cthulhu may not function properly without these."
fi
# Clean any cached bytecode
echo "Removing __pycache__ directories..."
find . -type d -name "__pycache__" -prune -exec rm -rf {} +
# Clean any existing build directory
if [[ -d "_build" ]]; then
echo "Removing existing build directory..."
rm -rf _build
fi
# Setup Meson build
echo "Setting up Meson build..."
meson setup _build --prefix="$HOME/.local" --buildtype=debugoptimized
# Build
echo "Building Cthulhu..."
meson compile -C _build
# Install
echo "Installing Cthulhu to ~/.local..."
meson install -C _build
# Update desktop database and icon cache
if command -v update-desktop-database &> /dev/null; then
echo "Updating desktop database..."
update-desktop-database "$HOME/.local/share/applications" 2>/dev/null || true
fi
if command -v gtk-update-icon-cache &> /dev/null; then
echo "Updating icon cache..."
gtk-update-icon-cache -f -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
fi
echo
echo "Build completed successfully!"
echo
echo "To run Cthulhu:"
echo " ~/.local/bin/cthulhu"
echo
echo "To run Cthulhu setup:"
echo " ~/.local/bin/cthulhu -s"
echo
echo "Build artifacts are in: _build/"
echo "To clean build artifacts, run: rm -rf _build"