main
sh 33 lines 1 KB
Raw
1 #!/bin/bash
2 # Build vLLM Rust artifacts and install them into the vllm package.
3 # Usage: ./tools/build_rust.sh [--debug]
4 #
5 # By default builds in release mode. Pass --debug for faster compile times
6 # during development.
7
8 set -euo pipefail
9
10 REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
12 # Read the required toolchain from rust-toolchain.toml.
13 TOOLCHAIN=$(grep '^channel' "$REPO_ROOT/rust-toolchain.toml" | sed 's/.*= *"\(.*\)"/\1/')
14
15 # Ensure rustup and the required toolchain are available.
16 if ! command -v rustup &>/dev/null; then
17 echo "rustup not found, installing..."
18 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
19 source "$HOME/.cargo/env"
20 fi
21
22 if ! rustup run "$TOOLCHAIN" rustc --version &>/dev/null; then
23 echo "Installing Rust toolchain: $TOOLCHAIN"
24 rustup toolchain install "$TOOLCHAIN"
25 fi
26
27 if [[ "${1:-}" == "--debug" ]]; then
28 PROFILE_ARG="--debug"
29 else
30 PROFILE_ARG="--release"
31 fi
32
33 python3 "$REPO_ROOT/tools/build_rust.py" "$PROFILE_ARG"