|
10 | 10 | RUST_VERSION="${VERSION:-"latest"}" |
11 | 11 | RUSTUP_PROFILE="${PROFILE:-"minimal"}" |
12 | 12 | RUSTUP_TARGETS="${TARGETS:-""}" |
| 13 | +CUSTOM_COMPONENTS="${CUSTOMCOMPONENTS:-"false"}" |
| 14 | +RUST_COMPONENTS="${COMPONENTS:-""}" |
13 | 15 |
|
14 | 16 | export CARGO_HOME="${CARGO_HOME:-"/usr/local/cargo"}" |
15 | 17 | export RUSTUP_HOME="${RUSTUP_HOME:-"/usr/local/rustup"}" |
@@ -394,8 +396,25 @@ if [ "${UPDATE_RUST}" = "true" ]; then |
394 | 396 | echo "Updating Rust..." |
395 | 397 | rustup update 2>&1 |
396 | 398 | fi |
397 | | -echo "Installing common Rust dependencies..." |
398 | | -rustup component add rust-analyzer rust-src rustfmt clippy 2>&1 |
| 399 | +# Install Rust components based on flag |
| 400 | +if [ "${CUSTOM_COMPONENTS}" = "true" ] && [ -n "${RUST_COMPONENTS}" ]; then |
| 401 | + echo "Installing custom Rust components..." |
| 402 | + IFS=',' read -ra components <<< "${RUST_COMPONENTS}" |
| 403 | + for component in "${components[@]}"; do |
| 404 | + # Trim whitespace |
| 405 | + component=$(echo "${component}" | xargs) |
| 406 | + if [ -n "${component}" ]; then |
| 407 | + echo "Installing Rust component: ${component}" |
| 408 | + if ! rustup component add "${component}" 2>&1; then |
| 409 | + echo "Warning: Failed to install component '${component}'. It may not be available for this toolchain." >&2 |
| 410 | + exit 1 |
| 411 | + fi |
| 412 | + fi |
| 413 | + done |
| 414 | +else |
| 415 | + echo "Installing common Rust dependencies..." |
| 416 | + rustup component add rust-analyzer rust-src rustfmt clippy 2>&1 |
| 417 | +fi |
399 | 418 |
|
400 | 419 | if [ -n "${RUSTUP_TARGETS}" ]; then |
401 | 420 | IFS=',' read -ra targets <<< "${RUSTUP_TARGETS}" |
|
0 commit comments