From fb132742a879665c39ada7e1aa59793dc001b905 Mon Sep 17 00:00:00 2001 From: A-ai-bot-N Date: Sun, 1 Mar 2026 22:10:01 +0400 Subject: [PATCH] feat: add unified build script with improved options - Add comprehensive build script with configuration options - Support for different build types (Debug/Release) - Configurable installation prefix - Optional test execution - Optional documentation generation - Clean build functionality - Parallel compilation support - Better error handling and user feedback --- build.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..b1bbdd61 --- /dev/null +++ b/build.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# 3FS Unified Build Script + +set -e + +# Configuration +BUILD_TYPE=${BUILD_TYPE:-Release} +INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local} +ENABLE_TESTS=${ENABLE_TESTS:-OFF} +ENABLE_DOCS=${ENABLE_DOCS:-OFF} + +echo "=== 3FS Build Script ===" +echo "Build type: $BUILD_TYPE" +echo "Install prefix: $INSTALL_PREFIX" + +# Clean build directory +if [ "$1" = "clean" ]; then + echo "Cleaning build directory..." + rm -rf build + exit 0 +fi + +# Create build directory +mkdir -p build +cd build + +# Run CMake +cmake .. \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ + -DENABLE_TESTS=$ENABLE_TESTS \ + -DENABLE_DOCS=$ENABLE_DOCS + +# Compile +make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) + +# Run tests if enabled +if [ "$ENABLE_TESTS" = "ON" ]; then + ctest --output-on-failure +fi + +# Install if requested +if [ "$1" = "install" ]; then + make install + echo "Installed to: $INSTALL_PREFIX" +fi + +echo "Build completed!"