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
19 changes: 19 additions & 0 deletions docs/lang/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ mise use -g [email protected]
cargo build
```

## Tool Options

The following [tool-options](/dev-tools/#tool-options) are available for the `rust` backend—these
go in `[tools]` in `mise.toml`.

### `profile`

The `profile` option allows you to specify the type of release to install. The following values
are supported:

- `minimal`: Includes as few components as possible to get a working compiler (rustc, rust-std, and cargo)
- `default` (default): Includes all of components in the minimal profile, and adds rust-docs, rustfmt, and clippy
- `complete`: Includes all the components available through rustup. This should never be used, as it includes every component ever included in the metadata and thus will almost always fail.

```toml
[tools]
"rust" = { version = "1.83.0", profile = "minimal" }
```

## Settings

<script setup>
Expand Down
7 changes: 7 additions & 0 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ impl<'a> CmdLineRunner<'a> {
None
}

pub fn opt_arg<S: AsRef<OsStr>>(mut self, arg: Option<S>) -> Self {
if let Some(arg) = arg {
self.cmd.arg(arg);
}
self
}

pub fn arg<S: AsRef<OsStr>>(mut self, arg: S) -> Self {
self.cmd.arg(arg.as_ref());
self
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/core/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl RustPlugin {
fn target_triple(&self, tv: &ToolVersion) -> String {
format!("{}-{}", tv.version, TARGET)
}

fn tv_profile(&self, tv: &ToolVersion) -> Option<String> {
tv.request.options().get("profile").cloned()
}
}

impl Backend for RustPlugin {
Expand Down Expand Up @@ -98,10 +102,14 @@ impl Backend for RustPlugin {
fn install_version_(&self, ctx: &InstallContext, tv: ToolVersion) -> Result<ToolVersion> {
self.setup_rustup(ctx, &tv)?;

let profile = self.tv_profile(&tv);

CmdLineRunner::new(RUSTUP_BIN)
.with_pr(&ctx.pr)
.arg("toolchain")
.arg("install")
.opt_arg(profile.as_ref().map(|_| "--profile"))
.opt_arg(profile)
.arg(&tv.version)
.prepend_path(self.list_bin_paths(&tv)?)?
.envs(self.exec_env(&Config::get(), Config::get().get_toolset()?, &tv)?)
Expand Down
Loading