Skip to content
Open
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
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ USAGE:
rustup-toolchain-install-master [FLAGS] [OPTIONS] [--] [commits]...

FLAGS:
-a, --alt download the alt build instead of normal build
--dry-run Only log the URLs, without downloading the artifacts
-f, --force Replace an existing toolchain of the same name
-h, --help Prints help information
-k, --keep-going Continue downloading toolchains even if some of them failed
-V, --version Prints version information
-a, --alt download the alt build instead of normal build
--dry-run Only log the URLs, without downloading the artifacts
-f, --force Replace an existing toolchain of the same name
-h, --help Prints help information
-k, --keep-going Continue downloading toolchains even if some of them failed
--no-default-components do not install rustc and rust-std component unless explicitly specified
-V, --version Prints version information

OPTIONS:
--channel <channel> specify the channel of the commits instead of detecting it automatically
Expand Down
76 changes: 41 additions & 35 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::process::exit;
use std::process::Command;
use std::slice;
use std::time::Duration;

use ansi_term::Color::{Red, Yellow};
Expand Down Expand Up @@ -70,6 +71,12 @@ struct Args {
)]
components: Vec<String>,

#[structopt(
long,
help = "do not install rustc and rust-std component unless explicitly specified"
)]
no_default_components: bool,

#[structopt(
long = "channel",
help = "specify the channel of the commits instead of detecting it automatically"
Expand Down Expand Up @@ -203,6 +210,7 @@ struct Toolchain<'a> {
host_target: &'a str,
rust_std_targets: &'a [&'a str],
components: &'a [&'a str],
no_default_components: bool,
dest: PathBuf,
}

Expand Down Expand Up @@ -236,43 +244,40 @@ fn install_single_toolchain(
get_channel(client, prefix, toolchain.commit)?
};

// download every component except rust-std.
for component in once(&"rustc").chain(toolchain.components) {
let component_filename = if *component == "rust-src" {
// rust-src is the only target-independent component
format!("{}-{}", component, channel)
} else {
format!("{}-{}-{}", component, channel, toolchain.host_target)
};
download_tar_xz(
maybe_dry_client,
&format!(
"{}/{}/{}.tar.xz",
prefix, toolchain.commit, &component_filename
),
&toolchain.dest,
toolchain.commit,
component,
channel,
toolchain.host_target,
)?;
let mut components = toolchain.components.to_vec();
if !toolchain.no_default_components {
components.insert(0, "rustc");
components.push("rust-std");
}

// download rust-std for every target.
for target in toolchain.rust_std_targets {
let rust_std_filename = format!("rust-std-{}-{}", channel, target);
download_tar_xz(
maybe_dry_client,
&format!(
"{}/{}/{}.tar.xz",
prefix, toolchain.commit, rust_std_filename
),
&toolchain.dest,
toolchain.commit,
"rust-std",
channel,
target,
)?;
for component in components {
let targets = if component == "rust-std" {
// download rust-std for every target
&toolchain.rust_std_targets
} else {
// otherwise just the host target
slice::from_ref(&toolchain.host_target)
};
for target in targets {
let component_filename = if component == "rust-src" {
// rust-src is the only target-independent component
format!("{}-{}", component, channel)
} else {
format!("{}-{}-{}", component, channel, target)
};
download_tar_xz(
maybe_dry_client,
&format!(
"{}/{}/{}.tar.xz",
prefix, toolchain.commit, &component_filename
),
&toolchain.dest,
toolchain.commit,
component,
channel,
target,
)?;
}
}

// install
Expand Down Expand Up @@ -472,6 +477,7 @@ fn run() -> Result<(), Error> {
host_target: host,
rust_std_targets: &rust_std_targets,
components: &components,
no_default_components: args.no_default_components,
dest,
},
args.channel.as_deref(),
Expand Down