-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-backends.sh
More file actions
executable file
·48 lines (40 loc) · 1.22 KB
/
Copy pathbuild-backends.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.22 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
#!/bin/bash
# Build script for C++/CUDA backends
# This script compiles the high-performance physics engine backends
set -e
echo "Building Astrosis C++/CUDA backends..."
# Check if CMake is installed
if ! command -v cmake &> /dev/null; then
echo "Error: CMake is not installed. Please install CMake 3.15+"
exit 1
fi
# Install pybind11 if not available
if ! python3 -c "import pybind11" 2>/dev/null; then
echo "Installing pybind11..."
pip3 install pybind11 --user || {
echo "Error: Failed to install pybind11. Try: pip3 install pybind11"
exit 1
}
fi
# Create build directory
mkdir -p cpp/build
cd cpp/build
# Configure with CMake
echo "Configuring with CMake..."
PYBIND11_DIR=$(python3 -m pybind11 --cmakedir 2>/dev/null || echo "")
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release"
if [ -n "$PYBIND11_DIR" ]; then
CMAKE_ARGS="$CMAKE_ARGS -Dpybind11_DIR=$PYBIND11_DIR"
fi
if command -v nvcc &> /dev/null; then
echo "CUDA detected - enabling CUDA support"
cmake .. $CMAKE_ARGS -DUSE_CUDA=ON
else
echo "CUDA not found - building CPU-only backend"
cmake .. $CMAKE_ARGS -DUSE_CUDA=OFF
fi
# Build
echo "Compiling..."
make -j$(nproc)
echo "Build complete!"
echo "Backend libraries are in cpp/build/"