#!/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 # Colors for output (only if stdout is a terminal) if [[ -t 1 ]]; then RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color else RED='' GREEN='' YELLOW='' BLUE='' NC='' fi echo -e "${BLUE}Cthulhu Meson Local Build Script${NC}" 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 -e "${RED}Error: This script must be run from the Cthulhu source directory${NC}" exit 1 fi # Check for required dependencies echo -e "${YELLOW}Checking dependencies...${NC}" for cmd in meson ninja python3; do if ! command -v "$cmd" &> /dev/null; then echo -e "${RED}Error: $cmd is not installed${NC}" echo "Please install: meson ninja python" exit 1 fi done # Check for optional dependencies missing_optional=() for module in gi speech; do if ! python3 -c "import $module" 2>/dev/null; then missing_optional+=("python-$module") fi done if [[ ${#missing_optional[@]} -gt 0 ]]; then echo -e "${YELLOW}Warning: Optional dependencies missing: ${missing_optional[*]}${NC}" echo "Cthulhu may not function properly without these." fi # Clean any existing build directory if [[ -d "_build" ]]; then echo -e "${YELLOW}Removing existing build directory...${NC}" rm -rf _build fi # Setup Meson build echo -e "${YELLOW}Setting up Meson build...${NC}" meson setup _build --prefix="$HOME/.local" --buildtype=debugoptimized # Build echo -e "${YELLOW}Building Cthulhu...${NC}" meson compile -C _build # Install echo -e "${YELLOW}Installing Cthulhu to ~/.local...${NC}" meson install -C _build # Update desktop database and icon cache if command -v update-desktop-database &> /dev/null; then echo -e "${YELLOW}Updating desktop database...${NC}" update-desktop-database "$HOME/.local/share/applications" 2>/dev/null || true fi if command -v gtk-update-icon-cache &> /dev/null; then echo -e "${YELLOW}Updating icon cache...${NC}" gtk-update-icon-cache -f -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true fi echo echo -e "${GREEN}Build completed successfully!${NC}" 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 -e "${BLUE}To clean build artifacts, run: ${YELLOW}rm -rf _build${NC}"