| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -euo pipefail |
|
|
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| cd "$SCRIPT_DIR" |
|
|
| BUILD_MODE="${1:-dynamic}" |
| OUTPUT_DIR="dist" |
| mkdir -p "$OUTPUT_DIR" |
|
|
| echo "=== BEX Engine Portable Build ===" |
| echo "Mode: $BUILD_MODE" |
| echo "" |
|
|
| case "$BUILD_MODE" in |
| --musl|musl) |
| echo "Building fully static binary (musl)..." |
| echo "This produces a binary with ZERO system library dependencies." |
| echo "" |
|
|
| |
| rustup target add x86_64-unknown-linux-musl 2>/dev/null || true |
|
|
| |
| RUSTFLAGS="-C target-feature=+crt-static" \ |
| cargo build --release --target x86_64-unknown-linux-musl |
|
|
| cp target/x86_64-unknown-linux-musl/release/bex "$OUTPUT_DIR/bex" |
| cp target/x86_64-unknown-linux-musl/release/libbex_runtime.a "$OUTPUT_DIR/libbex_runtime.a" |
|
|
| echo "" |
| echo "Built static binary: $OUTPUT_DIR/bex" |
| echo "No GLIBC dependency — runs on any Linux x86_64" |
| ;; |
|
|
| --docker|docker) |
| echo "Building in Docker (manylinux2_28 / GLIBC 2.28)..." |
| echo "This produces a binary compatible with all modern Linux distros." |
| echo "" |
|
|
| |
| docker run --rm -v "$SCRIPT_DIR:/src" -w /src \ |
| rust:1.79-bullseye \ |
| bash -c ' |
| apt-get update -qq && apt-get install -y -qq pkg-config libssl-dev >/dev/null 2>&1 |
| cargo build --release |
| cp target/release/bex /src/dist/bex |
| cp target/release/libbex_runtime.so /src/dist/libbex_runtime.so 2>/dev/null || true |
| cp target/release/libbex_runtime.a /src/dist/libbex_runtime.a 2>/dev/null || true |
| ' |
|
|
| echo "" |
| echo "Built with GLIBC 2.31 (Debian 11 Bullseye)" |
| echo "Compatible with: Ubuntu 20.04+, Debian 11+, Fedora 34+, RHEL 8+" |
| ;; |
|
|
| *) |
| echo "Building with system toolchain..." |
| echo "" |
|
|
| cargo build --release |
|
|
| cp target/release/bex "$OUTPUT_DIR/bex" 2>/dev/null || true |
| cp target/release/libbex_runtime.so "$OUTPUT_DIR/libbex_runtime.so" 2>/dev/null || true |
| cp target/release/libbex_runtime.a "$OUTPUT_DIR/libbex_runtime.a" 2>/dev/null || true |
|
|
| |
| if command -v objdump &>/dev/null; then |
| echo "" |
| echo "GLIBC version requirements:" |
| objdump -T "$OUTPUT_DIR/bex" 2>/dev/null | grep GLIBC_ | sed 's/.*GLIBC_/GLIBC_/' | sort -Vu || true |
| fi |
| ;; |
| esac |
|
|
| echo "" |
| echo "=== Build Complete ===" |
| ls -la "$OUTPUT_DIR/bex" "$OUTPUT_DIR/libbex_runtime"* 2>/dev/null |
| echo "" |
|
|
| |
| if [ -f "$OUTPUT_DIR/bex" ]; then |
| echo "Binary info:" |
| file "$OUTPUT_DIR/bex" 2>/dev/null || true |
| echo "" |
|
|
| |
| if "$OUTPUT_DIR/bex" --help >/dev/null 2>&1; then |
| echo "✓ Binary runs successfully on this system" |
| else |
| echo "⚠ Binary may not run on this system (different GLIBC)" |
| echo " Use --musl for a fully static build, or --docker for GLIBC 2.31" |
| fi |
| fi |
|
|