diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/bootstrap.sh | 186 | ||||
| -rw-r--r-- | scripts/install_deps_alpine.sh | 23 | ||||
| -rw-r--r-- | scripts/install_deps_arch.sh | 18 | ||||
| -rw-r--r-- | scripts/install_deps_fedora.sh | 17 | ||||
| -rw-r--r-- | scripts/install_deps_macos.sh | 17 | ||||
| -rw-r--r-- | scripts/install_deps_opensuse.sh | 17 | ||||
| -rw-r--r-- | scripts/install_deps_ubuntu.sh | 22 | ||||
| -rw-r--r-- | scripts/install_deps_windows_vcpkg.ps1 | 21 |
8 files changed, 321 insertions, 0 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100755 index 0000000..ca6b17d --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +# SRDWM Bootstrap Installer +# Detects platform/distro, installs dependencies, builds, tests, and installs. + +set -euo pipefail + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +info() { echo -e "${BLUE}[INFO]${NC} $*"; } +success(){ echo -e "${GREEN}[OK]${NC} $*"; } +warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } +error() { echo -e "${RED}[ERR]${NC} $*"; } + +usage(){ + cat <<EOF +Usage: $0 [options] + +Options: + --deps Install dependencies only + --build [Debug|Release] Build only (default Release) + --test Run tests after building + --install [PREFIX] Install (default /usr/local) + --all Install deps, build, test, install + --no-wayland Disable Wayland support (X11 only) + --real-wayland Use real wlroots backend (requires full deps) + --preset <name> Use CMake preset (overrides generator/build flags) + --generator <Ninja|Unix Makefiles> Choose generator if no preset + -h, --help Show this help +EOF +} + +platform="unknown" +case "$(uname -s)" in + Linux*) platform="linux";; + Darwin*) platform="macos";; + CYGWIN*|MINGW*|MSYS*) platform="windows";; + *) platform="unknown";; +esac + +ACTION="build" +BUILD_TYPE="Release" +RUN_TESTS=false +INSTALL_PREFIX="/usr/local" +ENABLE_WAYLAND=ON +USE_WAYLAND_STUB=ON +CMAKE_PRESET="" +GENERATOR="Ninja" + +while [[ $# -gt 0 ]]; do + case "$1" in + --deps) ACTION="deps"; shift;; + --build) ACTION="build"; BUILD_TYPE="${2:-$BUILD_TYPE}"; shift 2;; + --test) RUN_TESTS=true; shift;; + --install) ACTION="install"; INSTALL_PREFIX="${2:-$INSTALL_PREFIX}"; shift 2;; + --all) ACTION="all"; shift;; + --no-wayland) ENABLE_WAYLAND=OFF; shift;; + --real-wayland) USE_WAYLAND_STUB=OFF; shift;; + --preset) CMAKE_PRESET="${2}"; shift 2;; + --generator) GENERATOR="${2}"; shift 2;; + -h|--help) usage; exit 0;; + *) warn "Unknown option: $1"; usage; exit 1;; + esac +done + +install_deps_linux(){ + if command -v apt-get >/dev/null 2>&1; then + bash scripts/install_deps_ubuntu.sh + elif command -v dnf >/dev/null 2>&1; then + bash scripts/install_deps_fedora.sh + elif command -v pacman >/dev/null 2>&1; then + bash scripts/install_deps_arch.sh + elif command -v zypper >/dev/null 2>&1; then + bash scripts/install_deps_opensuse.sh + elif command -v apk >/dev/null 2>&1; then + bash scripts/install_deps_alpine.sh + else + error "Unsupported Linux distro. Install dependencies manually (see DEPENDENCIES.md)."; exit 1 + fi +} + +install_deps_macos(){ + bash scripts/install_deps_macos.sh +} + +check_deps_windows(){ + info "On Windows, use PowerShell: scripts\\install_deps_windows_vcpkg.ps1" +} + +configure_build(){ + mkdir -p build + if [[ -n "$CMAKE_PRESET" ]]; then + info "Configuring with preset: $CMAKE_PRESET" + cmake --preset "$CMAKE_PRESET" + return + fi + + local cache_file="build/CMakeCache.txt" + local generator_arg=( ) + local effective_generator="$GENERATOR" + if [[ -f "$cache_file" ]]; then + local cached_gen + cached_gen=$(grep -E '^CMAKE_GENERATOR:INTERNAL=' "$cache_file" | sed 's/^[^=]*=//') || true + if [[ -n "${cached_gen:-}" ]]; then + effective_generator="$cached_gen" + info "Reusing existing CMake generator from cache: $effective_generator" + fi + fi + + if [[ ! -f "$cache_file" ]]; then + generator_arg=( -G "$effective_generator" ) + else + # Do not override generator if cache exists + generator_arg=( ) + fi + + info "Configuring with generator=${effective_generator}, type=$BUILD_TYPE, ENABLE_WAYLAND=$ENABLE_WAYLAND, USE_WAYLAND_STUB=$USE_WAYLAND_STUB" + cmake -S . -B build "${generator_arg[@]}" \ + -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ + -DENABLE_WAYLAND="$ENABLE_WAYLAND" \ + -DUSE_WAYLAND_STUB="$USE_WAYLAND_STUB" +} + +build(){ + if [[ -n "$CMAKE_PRESET" ]]; then + cmake --build --preset "$CMAKE_PRESET" -j + else + cmake --build build -j + fi +} + +test_run(){ + if [[ -n "$CMAKE_PRESET" ]]; then + ctest --test-dir $(jq -r '.configurePresets[] | select(.name=="'"$CMAKE_PRESET"'") | .binaryDir' CMakePresets.json 2>/dev/null || echo build) --output-on-failure || true + else + ctest --test-dir build --output-on-failure || true + fi +} + +install(){ + if [[ "$platform" == "windows" ]]; then + cmake --install build --prefix "$INSTALL_PREFIX" + else + sudo cmake --install build --prefix "$INSTALL_PREFIX" + fi +} + +info "Platform detected: $platform" +case "$ACTION" in + deps) + case "$platform" in + linux) install_deps_linux;; + macos) install_deps_macos;; + windows) check_deps_windows;; + *) error "Unsupported platform"; exit 1;; + esac + ;; + build) + [[ "$platform" == "linux" ]] && install -d build >/dev/null 2>&1 || true + configure_build + build + $RUN_TESTS && test_run + ;; + install) + configure_build + build + install + ;; + all) + case "$platform" in + linux) install_deps_linux;; + macos) install_deps_macos;; + windows) check_deps_windows;; + esac + configure_build + build + test_run + install + ;; + *) usage; exit 1;; +esac + +success "Bootstrap completed." diff --git a/scripts/install_deps_alpine.sh b/scripts/install_deps_alpine.sh new file mode 100644 index 0000000..2ebf131 --- /dev/null +++ b/scripts/install_deps_alpine.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +if ! command -v apk >/dev/null 2>&1; then + echo "This script is intended for Alpine Linux (apk not found)." >&2 + exit 1 +fi + +sudo apk update +sudo apk add --no-cache \ + build-base cmake ninja git pkgconf \ + lua5.4 lua5.4-dev \ + libx11-dev libxrandr-dev libxinerama-dev libxfixes-dev libxcursor-dev \ + libxcb-dev xcb-util-keysyms-dev xcb-util-wm-dev \ + libxft-dev \ + wayland-dev wayland-protocols \ + libxkbcommon-dev seatd-dev \ + libdrm-dev mesa-egl mesa-gbm \ + libinput-dev \ + pixman-dev \ + wlroots-dev || true + +echo "Dependencies installed." diff --git a/scripts/install_deps_arch.sh b/scripts/install_deps_arch.sh new file mode 100644 index 0000000..640eda1 --- /dev/null +++ b/scripts/install_deps_arch.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +sudo pacman -Syu --noconfirm +sudo pacman -S --noconfirm \ + base-devel cmake ninja pkgconf git \ + lua \ + libx11 libxrandr libxinerama libxfixes libxcursor \ + libxcb xcb-util xcb-util-keysyms xcb-util-wm \ + libxft \ + wayland wayland-protocols \ + libxkbcommon seatd \ + libdrm mesa egl-wayland libgbm \ + libinput \ + pixman \ + wlroots + +echo "Dependencies installed." diff --git a/scripts/install_deps_fedora.sh b/scripts/install_deps_fedora.sh new file mode 100644 index 0000000..b2db109 --- /dev/null +++ b/scripts/install_deps_fedora.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +sudo dnf groupinstall -y "Development Tools" "Development Libraries" +sudo dnf install -y \ + cmake ninja-build pkgconf-pkg-config git \ + lua-devel \ + libX11-devel libXrandr-devel libXinerama-devel libXfixes-devel libXcursor-devel \ + libxcb-devel xcb-util-keysyms-devel xcb-util-wm-devel xcb-util-renderutil-devel xcb-util-image-devel \ + libXft-devel \ + wayland-devel wayland-protocols-devel \ + libxkbcommon-devel seatd-devel \ + libdrm-devel mesa-libEGL-devel mesa-libgbm-devel systemd-devel libinput-devel \ + pixman-devel \ + wlroots-devel || true + +echo "Dependencies installed." diff --git a/scripts/install_deps_macos.sh b/scripts/install_deps_macos.sh new file mode 100644 index 0000000..a341cf2 --- /dev/null +++ b/scripts/install_deps_macos.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Ensure Command Line Tools +if ! xcode-select -p >/dev/null 2>&1; then + xcode-select --install || true +fi + +# Install Homebrew if missing +if ! command -v brew >/dev/null 2>&1; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +brew update +brew install cmake ninja lua pkg-config git + +echo "Dependencies installed." diff --git a/scripts/install_deps_opensuse.sh b/scripts/install_deps_opensuse.sh new file mode 100644 index 0000000..7bf17bd --- /dev/null +++ b/scripts/install_deps_opensuse.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +sudo zypper refresh +sudo zypper install -y \ + gcc-c++ cmake ninja git pkg-config \ + lua54 lua54-devel \ + libX11-devel libXrandr-devel libXinerama-devel libXfixes-devel libXcursor-devel \ + libxcb-devel xcb-util-keysyms-devel xcb-util-wm-devel \ + libXft-devel \ + wayland-devel wayland-protocols-devel \ + libxkbcommon-devel seatd-devel \ + libdrm-devel Mesa-libEGL-devel Mesa-libgbm-devel libinput-devel \ + pixman-devel \ + wlroots-devel || true + +echo "Dependencies installed." diff --git a/scripts/install_deps_ubuntu.sh b/scripts/install_deps_ubuntu.sh new file mode 100644 index 0000000..4939557 --- /dev/null +++ b/scripts/install_deps_ubuntu.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +sudo apt-get update +sudo apt-get install -y \ + build-essential cmake ninja-build pkg-config git \ + liblua5.4-dev \ + libx11-dev libxrandr-dev libxinerama-dev libxfixes-dev libxcursor-dev \ + libxcb1-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-ewmh-dev libxcb-randr0-dev \ + libxft-dev \ + libwayland-dev wayland-protocols \ + libxkbcommon-dev libseat-dev \ + libdrm-dev libegl1-mesa-dev libgbm-dev libudev-dev libinput-dev \ + libpixman-1-dev \ + libwlroots-dev || true + +# Fallback for distros that use wlroots-dev instead of libwlroots-dev +if ! pkg-config --exists wlroots; then + sudo apt-get install -y wlroots-dev || true +fi + +echo "Dependencies installed." diff --git a/scripts/install_deps_windows_vcpkg.ps1 b/scripts/install_deps_windows_vcpkg.ps1 new file mode 100644 index 0000000..40b6c06 --- /dev/null +++ b/scripts/install_deps_windows_vcpkg.ps1 @@ -0,0 +1,21 @@ +Param( + [string]$VcpkgDir = "$PSScriptRoot\..\..\vcpkg" +) + +$ErrorActionPreference = "Stop" + +if (!(Test-Path $VcpkgDir)) { + git clone https://github.com/microsoft/vcpkg.git $VcpkgDir +} + +Push-Location $VcpkgDir +try { + .\bootstrap-vcpkg.bat + .\vcpkg.exe integrate install + .\vcpkg.exe install lua:x64-windows +} +finally { + Pop-Location +} + +Write-Host "Dependencies installed via vcpkg. Use CMake with -DCMAKE_TOOLCHAIN_FILE=$VcpkgDir\scripts\buildsystems\vcpkg.cmake" |
