Migrated to meson/ninja for building. There may be bugs. Thanks Claud for the assist.
This commit is contained in:
157
build-local.sh
157
build-local.sh
@@ -1,93 +1,96 @@
|
||||
#!/bin/bash
|
||||
# Local build script for Cthulhu development
|
||||
# Builds and installs Cthulhu to ~/.local without touching system installation
|
||||
#
|
||||
# Build script for Cthulhu screen reader using Meson build system
|
||||
# This script builds and installs Cthulhu locally to ~/.local
|
||||
#
|
||||
|
||||
set -e # Exit on any error
|
||||
set -e # Exit on error
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
# 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 "${GREEN}=== Cthulhu Local Build Script ===${NC}"
|
||||
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 "configure.ac" ]]; then
|
||||
echo -e "${RED}Error: Not in Cthulhu source directory (configure.ac not found)${NC}"
|
||||
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 dependencies
|
||||
# Check for required dependencies
|
||||
echo -e "${YELLOW}Checking dependencies...${NC}"
|
||||
if ! command -v autoreconf &> /dev/null; then
|
||||
echo -e "${RED}Error: autoreconf not found. Install autotools.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! python3 -c "import dasbus" 2>/dev/null; then
|
||||
echo -e "${YELLOW}Warning: dasbus not available. D-Bus service will be disabled.${NC}"
|
||||
fi
|
||||
|
||||
# Clean previous build artifacts (optional)
|
||||
if [[ "$1" == "--clean" ]]; then
|
||||
echo -e "${YELLOW}Cleaning previous build...${NC}"
|
||||
make distclean 2>/dev/null || true
|
||||
rm -rf autom4te.cache configure config.status Makefile
|
||||
fi
|
||||
|
||||
# Set local installation prefix
|
||||
LOCAL_PREFIX="$HOME/.local"
|
||||
echo -e "${YELLOW}Installing to: ${LOCAL_PREFIX}${NC}"
|
||||
|
||||
# Regenerate autotools files
|
||||
echo -e "${YELLOW}Regenerating autotools files...${NC}"
|
||||
autoreconf -fiv
|
||||
|
||||
# Configure for local installation
|
||||
echo -e "${YELLOW}Configuring...${NC}"
|
||||
./configure --prefix="$LOCAL_PREFIX" \
|
||||
--sysconfdir="$LOCAL_PREFIX/etc" \
|
||||
--localstatedir="$LOCAL_PREFIX/var" \
|
||||
--disable-help
|
||||
|
||||
# Build
|
||||
echo -e "${YELLOW}Building...${NC}"
|
||||
make -j$(nproc)
|
||||
|
||||
# Install locally
|
||||
echo -e "${YELLOW}Installing to local prefix...${NC}"
|
||||
make install || {
|
||||
echo -e "${YELLOW}Warning: make install had errors, but checking if binary was created...${NC}"
|
||||
if [[ -f "$LOCAL_PREFIX/bin/cthulhu" ]]; then
|
||||
echo -e "${GREEN}Binary successfully installed despite makefile warnings.${NC}"
|
||||
else
|
||||
echo -e "${RED}Installation failed.${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
|
||||
|
||||
echo -e "${GREEN}=== Build Complete ===${NC}"
|
||||
echo -e "${GREEN}Cthulhu installed to: ${LOCAL_PREFIX}${NC}"
|
||||
echo -e "${GREEN}Binary location: ${LOCAL_PREFIX}/bin/cthulhu${NC}"
|
||||
# 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
|
||||
|
||||
# Ensure UI files are installed (fallback in case make install missed them)
|
||||
echo -e "${YELLOW}Ensuring UI files are installed...${NC}"
|
||||
mkdir -p "${LOCAL_PREFIX}/share/cthulhu/ui"
|
||||
if [[ ! -f "${LOCAL_PREFIX}/share/cthulhu/ui/cthulhu-setup.ui" ]]; then
|
||||
cp src/cthulhu/cthulhu-setup.ui "${LOCAL_PREFIX}/share/cthulhu/ui/" 2>/dev/null || true
|
||||
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
|
||||
if [[ ! -f "${LOCAL_PREFIX}/share/cthulhu/ui/cthulhu-find.ui" ]]; then
|
||||
cp src/cthulhu/cthulhu-find.ui "${LOCAL_PREFIX}/share/cthulhu/ui/" 2>/dev/null || true
|
||||
fi
|
||||
echo -e "${GREEN}UI files confirmed.${NC}"
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}To run local Cthulhu:${NC}"
|
||||
echo -e " ${LOCAL_PREFIX}/bin/cthulhu"
|
||||
echo ""
|
||||
echo -e "${YELLOW}To add to PATH (add to ~/.bashrc):${NC}"
|
||||
echo -e " export PATH=\"${LOCAL_PREFIX}/bin:\$PATH\""
|
||||
echo ""
|
||||
echo -e "${YELLOW}To uninstall local build:${NC}"
|
||||
echo -e " ./clean-local.sh"
|
||||
# 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}"
|
Reference in New Issue
Block a user