-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·74 lines (66 loc) · 2.17 KB
/
build.sh
File metadata and controls
executable file
·74 lines (66 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# Build libhyperdht.so from the repository root.
# Run from examples/python/ — the script finds the repo root automatically.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BUILD_DIR="$REPO_ROOT/build-shared"
echo "=== Building libhyperdht.so ==="
echo " Repo: $REPO_ROOT"
echo " Build: $BUILD_DIR"
echo ""
# Check dependencies
for cmd in cmake ninja pkg-config; do
if ! command -v "$cmd" &>/dev/null; then
echo "ERROR: $cmd not found. Install it first:"
echo ""
echo " Debian/Ubuntu: sudo apt install cmake ninja-build pkg-config libsodium-dev libuv1-dev"
echo " Fedora: sudo dnf install cmake ninja-build pkgconf libsodium-devel libuv-devel"
echo " Arch: sudo pacman -S cmake ninja pkgconf libsodium libuv"
echo ""
exit 1
fi
done
# Check libraries
missing=""
pkg-config --exists libsodium 2>/dev/null || missing="$missing libsodium"
pkg-config --exists libuv 2>/dev/null || missing="$missing libuv"
if [ -n "$missing" ]; then
echo "ERROR: Missing libraries:$missing"
echo ""
echo " Debian/Ubuntu: sudo apt install libsodium-dev libuv1-dev"
echo " Fedora: sudo dnf install libsodium-devel libuv-devel"
echo " Arch: sudo pacman -S libsodium libuv"
echo ""
exit 1
fi
# Init libudx submodule if needed
if [ ! -f "$REPO_ROOT/deps/libudx/CMakeLists.txt" ]; then
echo " Fetching libudx submodule..."
git -C "$REPO_ROOT" submodule update --init deps/libudx
fi
# Build
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake "$REPO_ROOT" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DHYPERDHT_BUILD_TESTS=OFF \
-G Ninja
ninja
SO_PATH="$BUILD_DIR/libhyperdht.so"
if [ ! -f "$SO_PATH" ]; then
echo "ERROR: Build succeeded but libhyperdht.so not found at $SO_PATH"
exit 1
fi
echo ""
echo "=== Build complete ==="
echo " Library: $SO_PATH"
echo ""
echo " Run the examples:"
echo " export HYPERDHT_LIB=$SO_PATH"
echo " cd $SCRIPT_DIR"
echo " python3 example.py keygen"
echo " python3 example.py server"
echo " python3 holesail_server.py --live 8080"
echo ""