diff --git a/features/src/rust/devcontainer-feature.json b/features/src/rust/devcontainer-feature.json index 40ce5f766..3d92bf659 100644 --- a/features/src/rust/devcontainer-feature.json +++ b/features/src/rust/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "rust", - "version": "26.8.1", + "version": "26.8.2", "name": "Rust", "documentationURL": "https://github.com/rapidsai/devcontainers/features/tree/main/src/rust", "description": "Installs Rust, common Rust utilities, and their required dependencies", @@ -10,6 +10,17 @@ "proposals": [ "latest", "none", + "1.87", + "1.86", + "1.85", + "1.84", + "1.83", + "1.82", + "1.81", + "1.80", + "1.79", + "1.78", + "1.77", "1.76", "1.75", "1.74", @@ -22,10 +33,7 @@ "1.67", "1.66", "1.65", - "1.64", - "1.63", - "1.62", - "1.61" + "1.64" ], "default": "latest", "description": "Select or enter a version of Rust to install." @@ -40,6 +48,27 @@ "default": "minimal", "description": "Select a rustup install profile." }, + "targets": { + "type": "string", + "default": "", + "description": "Optional comma separated list of additional Rust targets to install.", + "proposals": [ + "aarch64-unknown-linux-gnu", + "armv7-unknown-linux-gnueabihf", + "x86_64-unknown-redox,x86_64-unknown-uefi" + ] + }, + "components": { + "type": "string", + "default": "rust-analyzer,rust-src,rustfmt,clippy", + "description": "Optional, comma separated list of Rust components to be installed", + "proposals": [ + "rust-analyzer,rust-src,rustfmt,clippy", + "rust-analyzer,rust-src", + "rustfmt,clippy,rust-docs", + "llvm-tools-preview,rust-src,rustfmt" + ] + }, "updateRc": { "type": "boolean", "default": true diff --git a/features/src/rust/install.sh b/features/src/rust/install.sh index b18a497e0..188ad5f20 100644 --- a/features/src/rust/install.sh +++ b/features/src/rust/install.sh @@ -12,6 +12,8 @@ UPDATE_RC="${UPDATERC:-"true"}"; UPDATE_RUST="${UPDATERUST:-"false"}"; RUST_VERSION="${VERSION:-"latest"}"; RUSTUP_PROFILE="${PROFILE:-"minimal"}"; +RUSTUP_TARGETS="${TARGETS:-""}" +IFS=',' read -ra components <<< "${COMPONENTS:-rust-analyzer,rust-src,rustfmt,clippy}" # Ensure we're in this feature's directory during build cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; @@ -128,9 +130,27 @@ if [ "${UPDATE_RUST}" = "true" ]; then rustup update 2>&1; fi -echo "Installing common Rust dependencies..."; - -rustup component add rust-analyzer rust-src rustfmt clippy 2>&1; +# Install Rust components +echo "Installing Rust components..." +for component in "${components[@]}"; do + # Trim leading and trailing whitespace + component="${component#"${component%%[![:space:]]*}"}" && component="${component%"${component##*[![:space:]]}"}" + if [ -n "${component}" ]; then + echo "Installing Rust component: ${component}" + if ! rustup component add "${component}" 2>&1; then + echo "Warning: Failed to install component '${component}'. It may not be available for this toolchain." >&2 + exit 1 + fi + fi +done + +if [ -n "${RUSTUP_TARGETS}" ]; then + IFS=',' read -ra targets <<< "${RUSTUP_TARGETS}" + for target in "${targets[@]}"; do + echo "Installing additional Rust target $target" + rustup target add "$target" 2>&1 + done +fi # Add CARGO_HOME, RUSTUP_HOME and bin directory into bashrc/zshrc files (unless disabled) if [ "${UPDATE_RC}" = "true" ]; then