Last active
January 13, 2026 01:33
-
-
Save travisdowns/acce6bc5202f08be86f546eca1f06029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| export DEBIAN_FRONTEND=noninteractive | |
| # Build Seastar framework from source | |
| # This script clones the Seastar repository, installs dependencies, | |
| # configures the build with required libraries, and compiles the project. | |
| readonly SEASTAR_REPO="https://github.com/scylladb/seastar" | |
| readonly SEASTAR_DIR="seastar" | |
| readonly BUILD_DIR="build/release" | |
| readonly MODE="${MODE:-}" | |
| readonly USE_LLVM="${USE_LLVM:-}" | |
| # Global variable to track LLVM version if installed | |
| LLVM_VERSION="" | |
| is_ubuntu_2204() { | |
| [[ -f /etc/os-release ]] || return 1 | |
| source /etc/os-release | |
| [[ "${ID}" == "ubuntu" && "${VERSION_ID}" == "22.04" ]] | |
| } | |
| install_llvm() { | |
| # Determine if we should install LLVM and which version | |
| if is_ubuntu_2204; then | |
| # Ubuntu 22.04 always uses LLVM (default to 20 if not specified) | |
| LLVM_VERSION="${USE_LLVM:-20}" | |
| elif [[ -n "${USE_LLVM}" ]]; then | |
| # Other systems only if explicitly requested | |
| LLVM_VERSION="${USE_LLVM}" | |
| else | |
| return 0 | |
| fi | |
| local llvm_version="${LLVM_VERSION}" | |
| # Check if clang++ is already installed | |
| if command -v "clang++-${llvm_version}" &>/dev/null; then | |
| echo "LLVM ${llvm_version} (clang++-${llvm_version}) is already installed. Skipping installation." | |
| return 0 | |
| fi | |
| echo "Installing LLVM ${llvm_version}..." | |
| if is_ubuntu_2204; then | |
| # Use llvm.sh on Ubuntu 22.04 | |
| local llvm_script="/tmp/llvm.sh" | |
| # Download llvm.sh if not already present | |
| if [[ ! -f "${llvm_script}" ]]; then | |
| wget -O "${llvm_script}" https://apt.llvm.org/llvm.sh | |
| chmod +x "${llvm_script}" | |
| fi | |
| sudo "${llvm_script}" "${llvm_version}" | |
| else | |
| # On other systems, try to install via package manager | |
| echo "Not on Ubuntu 22.04, attempting to install LLVM ${llvm_version} via system package manager..." | |
| if command -v apt-get &>/dev/null; then | |
| sudo apt-get update | |
| sudo apt-get install -y "llvm-${llvm_version}" "clang-${llvm_version}" | |
| elif command -v dnf &>/dev/null; then | |
| sudo dnf install -y "llvm${llvm_version}" "clang${llvm_version}" | |
| elif command -v yum &>/dev/null; then | |
| sudo yum install -y "llvm${llvm_version}" "clang${llvm_version}" | |
| else | |
| echo "Warning: No supported package manager found. Please install LLVM ${llvm_version} manually." | |
| return 1 | |
| fi | |
| fi | |
| echo "LLVM ${llvm_version} installed successfully." | |
| } | |
| main() { | |
| echo "Starting Seastar build process..." | |
| # Install LLVM if requested | |
| install_llvm | |
| # Clone the repository if it doesn't exist | |
| if [[ -d "${SEASTAR_DIR}" ]]; then | |
| echo "Directory ${SEASTAR_DIR} already exists. Skipping clone." | |
| cd "${SEASTAR_DIR}" | |
| else | |
| echo "Cloning Seastar repository..." | |
| git clone "${SEASTAR_REPO}" | |
| cd "${SEASTAR_DIR}" | |
| fi | |
| # Install system dependencies | |
| echo "Installing dependencies (requires sudo)..." | |
| sudo ./install-dependencies.sh | |
| # Configure the build | |
| local configure_args=(--cook fmt --cook GnuTLS) | |
| if [[ -n "${MODE}" ]]; then | |
| configure_args+=(--mode "${MODE}") | |
| fi | |
| if [[ -n "${LLVM_VERSION}" ]]; then | |
| configure_args+=(--compiler "clang++-${LLVM_VERSION}") | |
| fi | |
| if is_ubuntu_2204; then | |
| configure_args+=(--c++-standard=20) | |
| fi | |
| # Print configuration message | |
| local config_msg="Configuring build with fmt and GnuTLS" | |
| [[ -n "${MODE}" ]] && config_msg+=" (mode: ${MODE})" | |
| [[ -n "${LLVM_VERSION}" ]] && config_msg+=" (compiler: clang++-${LLVM_VERSION})" | |
| echo "${config_msg}..." | |
| ./configure.py "${configure_args[@]}" | |
| # Build the project | |
| echo "Building Seastar with ninja..." | |
| cd "${BUILD_DIR}" | |
| ninja | |
| echo "Build completed successfully!" | |
| } | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment