From 8110bb2773b6c841029a51eca7971f42a36f480c Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:58:00 +0200 Subject: Rewrite srdwm in Rust: working X11 and Wayland backends, Lua config The C++ prototype (moved to legacy-cpp/) was mostly a design skeleton: X11 and Windows backends were partially real, Wayland created the wlroots object graph but never wired a single event listener, macOS was stub except monitor enumeration, and the Lua engine's srd.bind() stored a key-combo string but never the actual closure. See docs/PRIOR_ART.md for the full audit. This replaces it with a Cargo workspace: - srdwm-core: platform-independent window/workspace/monitor state, a real master-stack tiling layout, and SmartPlacement grid/cascade/ snap-to-edge placement - fixing several bugs in the C++ version (hardcoded 2-column grid, cascade that never cascaded, snap-to-edge that always returned a fixed rect). 35 unit tests. - srdwm-config: the srd Lua API via mlua, implementing the surface docs/DEFAULTS.md always documented but the C++ engine never actually built (srd.window.close()/focus(direction), srd.workspace.next(), real keybinding closures, require("srd") support). 10 unit tests. - srdwm-x11: a real reparenting WM with a drawn title bar (buttons, drag, resize), verified live under Xephyr - frame placement and client offset match srdwm-core's computed geometry exactly, and the decoration renders correctly on screen. - srdwm-wayland: a from-scratch smithay compositor (the C++ version had nothing working to port from) - runs via the winit backend, tracks xdg-shell toplevels through the same WindowManager and hit-testing code X11 uses, verified to start/render/run without crashing. Decorations are solid-color (no text yet); see docs/IMPLEMENTATION_STATUS.md for exact scope. - srdwm-windows / srdwm-macos: structured, cfg-gated designs informed by komorebi/glazewm and yabai/AeroSpace respectively (see docs/PRIOR_ART.md), honestly marked as unbuilt/unverified since this sandbox has no Windows or macOS target. --- legacy-cpp/scripts/bootstrap.sh | 186 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100755 legacy-cpp/scripts/bootstrap.sh (limited to 'legacy-cpp/scripts/bootstrap.sh') diff --git a/legacy-cpp/scripts/bootstrap.sh b/legacy-cpp/scripts/bootstrap.sh new file mode 100755 index 0000000..ca6b17d --- /dev/null +++ b/legacy-cpp/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 < Use CMake preset (overrides generator/build flags) + --generator 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." -- cgit v1.2.3