Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions features/src/rust/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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."
Expand All @@ -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
Expand Down
26 changes: 23 additions & 3 deletions features/src/rust/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 )";
Expand Down Expand Up @@ -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
Expand Down
Loading