krystv commited on
Commit
ceb9df4
·
verified ·
1 Parent(s): 244c3b7

Upload build-portable.sh

Browse files
Files changed (1) hide show
  1. build-portable.sh +110 -0
build-portable.sh ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Cross-platform build script for BEX Engine
3
+ # Targets GLIBC 2.31+ (Ubuntu 20.04 / Debian 11 / most modern distros)
4
+ #
5
+ # Strategy: Use musl-static or manylinux2_28 build environment
6
+ # This ensures the resulting binary works on:
7
+ # - Ubuntu 20.04+
8
+ # - Debian 11+
9
+ # - Fedora 34+
10
+ # - Alpine (musl)
11
+ # - RHEL 8+
12
+ # - Any system with GLIBC >= 2.28
13
+ #
14
+ # Usage:
15
+ # ./build-portable.sh # Build dynamically linked (GLIBC 2.28+)
16
+ # ./build-portable.sh --musl # Build fully static (no GLIBC dependency)
17
+ # ./build-portable.sh --docker # Build in Docker for reproducibility
18
+ set -euo pipefail
19
+
20
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ cd "$SCRIPT_DIR"
22
+
23
+ BUILD_MODE="${1:-dynamic}"
24
+ OUTPUT_DIR="dist"
25
+ mkdir -p "$OUTPUT_DIR"
26
+
27
+ echo "=== BEX Engine Portable Build ==="
28
+ echo "Mode: $BUILD_MODE"
29
+ echo ""
30
+
31
+ case "$BUILD_MODE" in
32
+ --musl|musl)
33
+ echo "Building fully static binary (musl)..."
34
+ echo "This produces a binary with ZERO system library dependencies."
35
+ echo ""
36
+
37
+ # Ensure musl target is installed
38
+ rustup target add x86_64-unknown-linux-musl 2>/dev/null || true
39
+
40
+ # Build with musl (fully static)
41
+ RUSTFLAGS="-C target-feature=+crt-static" \
42
+ cargo build --release --target x86_64-unknown-linux-musl
43
+
44
+ cp target/x86_64-unknown-linux-musl/release/bex "$OUTPUT_DIR/bex"
45
+ cp target/x86_64-unknown-linux-musl/release/libbex_runtime.a "$OUTPUT_DIR/libbex_runtime.a"
46
+
47
+ echo ""
48
+ echo "Built static binary: $OUTPUT_DIR/bex"
49
+ echo "No GLIBC dependency — runs on any Linux x86_64"
50
+ ;;
51
+
52
+ --docker|docker)
53
+ echo "Building in Docker (manylinux2_28 / GLIBC 2.28)..."
54
+ echo "This produces a binary compatible with all modern Linux distros."
55
+ echo ""
56
+
57
+ # Use a Debian 11 (Bullseye) based image for GLIBC 2.31
58
+ docker run --rm -v "$SCRIPT_DIR:/src" -w /src \
59
+ rust:1.79-bullseye \
60
+ bash -c '
61
+ apt-get update -qq && apt-get install -y -qq pkg-config libssl-dev >/dev/null 2>&1
62
+ cargo build --release
63
+ cp target/release/bex /src/dist/bex
64
+ cp target/release/libbex_runtime.so /src/dist/libbex_runtime.so 2>/dev/null || true
65
+ cp target/release/libbex_runtime.a /src/dist/libbex_runtime.a 2>/dev/null || true
66
+ '
67
+
68
+ echo ""
69
+ echo "Built with GLIBC 2.31 (Debian 11 Bullseye)"
70
+ echo "Compatible with: Ubuntu 20.04+, Debian 11+, Fedora 34+, RHEL 8+"
71
+ ;;
72
+
73
+ *)
74
+ echo "Building with system toolchain..."
75
+ echo ""
76
+
77
+ cargo build --release
78
+
79
+ cp target/release/bex "$OUTPUT_DIR/bex" 2>/dev/null || true
80
+ cp target/release/libbex_runtime.so "$OUTPUT_DIR/libbex_runtime.so" 2>/dev/null || true
81
+ cp target/release/libbex_runtime.a "$OUTPUT_DIR/libbex_runtime.a" 2>/dev/null || true
82
+
83
+ # Check GLIBC version requirement
84
+ if command -v objdump &>/dev/null; then
85
+ echo ""
86
+ echo "GLIBC version requirements:"
87
+ objdump -T "$OUTPUT_DIR/bex" 2>/dev/null | grep GLIBC_ | sed 's/.*GLIBC_/GLIBC_/' | sort -Vu || true
88
+ fi
89
+ ;;
90
+ esac
91
+
92
+ echo ""
93
+ echo "=== Build Complete ==="
94
+ ls -la "$OUTPUT_DIR/bex" "$OUTPUT_DIR/libbex_runtime"* 2>/dev/null
95
+ echo ""
96
+
97
+ # Verify the binary
98
+ if [ -f "$OUTPUT_DIR/bex" ]; then
99
+ echo "Binary info:"
100
+ file "$OUTPUT_DIR/bex" 2>/dev/null || true
101
+ echo ""
102
+
103
+ # Quick sanity test
104
+ if "$OUTPUT_DIR/bex" --help >/dev/null 2>&1; then
105
+ echo "✓ Binary runs successfully on this system"
106
+ else
107
+ echo "⚠ Binary may not run on this system (different GLIBC)"
108
+ echo " Use --musl for a fully static build, or --docker for GLIBC 2.31"
109
+ fi
110
+ fi