Skip to content

Commit cfb0141

Browse files
authored
Merge pull request #73 from wesleywiser/ci_toolchain_targets_components
Allow installing targets & components for CI toolchains
2 parents b354448 + c10a334 commit cfb0141

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
## [0.15.2] - 2022-10-13
9+
10+
### Changed
11+
12+
* CI toolchains can now install additional targets and components.
13+
814
## [0.15.1] - 2022-09-04
915

1016
### Changed
@@ -286,6 +292,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
286292

287293
- Initial version of Rustwide, extracted from Crater.
288294

295+
[0.15.2]: https://github.com/rust-lang/rustwide/releases/tag/0.15.2
289296
[0.15.1]: https://github.com/rust-lang/rustwide/releases/tag/0.15.1
290297
[0.15.0]: https://github.com/rust-lang/rustwide/releases/tag/0.15.0
291298
[0.14.0]: https://github.com/rust-lang/rustwide/releases/tag/0.14.0

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustwide"
3-
version = "0.15.1"
3+
version = "0.15.2"
44
edition = "2018"
55
build = "build.rs"
66

src/native/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::CurrentUser;
22
use crate::cmd::KillFailedError;
3-
use failure::{bail, Error};
3+
use failure::Error;
44
use std::fs::File;
55
use std::path::Path;
66
use windows_sys::Win32::Foundation::CloseHandle;

src/toolchain.rs

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,23 +315,48 @@ impl Toolchain {
315315
RustupAction::Remove => ("remove", "removing"),
316316
};
317317

318-
let thing = thing.to_string();
319-
let action = action.to_string();
318+
let toolchain_name = self.rustup_name();
319+
info!("{log_action_ing} {thing} {name} for toolchain {toolchain_name}");
320320

321321
#[cfg(feature = "unstable-toolchain-ci")]
322-
if let ToolchainInner::CI { .. } = self.inner {
323-
failure::bail!(
324-
"{} {} on CI toolchains is not supported yet",
325-
log_action_ing,
326-
thing
327-
);
322+
if let ToolchainInner::CI(ci) = &self.inner {
323+
if let RustupAction::Remove = action {
324+
failure::bail!("removing {thing} on CI toolchains is not supported yet");
325+
}
326+
327+
let mut args = Vec::with_capacity(6);
328+
if ci.alt {
329+
args.push("--alt");
330+
}
331+
args.extend([
332+
// `-f` is required otherwise rustup-toolchain-install-master will early return
333+
// because the toolchain (but not the new component) is already installed.
334+
"-f",
335+
match thing {
336+
RustupThing::Target => "--targets",
337+
RustupThing::Component => "--component",
338+
},
339+
name,
340+
// We have to pass `--` otherwise the sha is interpreted as a target name.
341+
"--",
342+
&ci.sha,
343+
]);
344+
345+
Command::new(workspace, &RUSTUP_TOOLCHAIN_INSTALL_MASTER)
346+
.args(&args)
347+
.run()
348+
.with_context(|_| {
349+
format!(
350+
"unable to {log_action} {thing} {name} for CI toolchain {toolchain_name} \
351+
via rustup-toolchain-install-master"
352+
)
353+
})?;
354+
355+
return Ok(());
328356
}
329357

330-
let toolchain_name = self.rustup_name();
331-
info!(
332-
"{} {} {} for toolchain {}",
333-
log_action_ing, thing, name, toolchain_name
334-
);
358+
let thing = thing.to_string();
359+
let action = action.to_string();
335360

336361
Command::new(workspace, &RUSTUP)
337362
.args(&[
@@ -344,8 +369,7 @@ impl Toolchain {
344369
.run()
345370
.with_context(|_| {
346371
format!(
347-
"unable to {} {} {} for toolchain {} via rustup",
348-
log_action, thing, name, toolchain_name,
372+
"unable to {log_action} {thing} {name} for toolchain {toolchain_name} via rustup"
349373
)
350374
})?;
351375
Ok(())
@@ -517,7 +541,7 @@ pub(crate) fn list_installed_toolchains(rustup_home: &Path) -> Result<Vec<Toolch
517541
#[cfg(feature = "unstable-toolchain-ci")]
518542
{
519543
let (sha, alt) = if name.ends_with("-alt") {
520-
((&name[..name.len() - 4]).to_string(), true)
544+
((name[..name.len() - 4]).to_string(), true)
521545
} else {
522546
(name, false)
523547
};

0 commit comments

Comments
 (0)