@@ -8,6 +8,7 @@ use std::ops::Deref;
8
8
use std:: path:: { Path , PathBuf } ;
9
9
use std:: process:: exit;
10
10
use std:: process:: Command ;
11
+ use std:: slice;
11
12
use std:: time:: Duration ;
12
13
13
14
use ansi_term:: Color :: { Red , Yellow } ;
@@ -70,6 +71,12 @@ struct Args {
70
71
) ]
71
72
components : Vec < String > ,
72
73
74
+ #[ structopt(
75
+ long,
76
+ help = "do not install rustc and rust-std component unless explicitly specified"
77
+ ) ]
78
+ no_default_components : bool ,
79
+
73
80
#[ structopt(
74
81
long = "channel" ,
75
82
help = "specify the channel of the commits instead of detecting it automatically"
@@ -203,6 +210,7 @@ struct Toolchain<'a> {
203
210
host_target : & ' a str ,
204
211
rust_std_targets : & ' a [ & ' a str ] ,
205
212
components : & ' a [ & ' a str ] ,
213
+ no_default_components : bool ,
206
214
dest : PathBuf ,
207
215
}
208
216
@@ -236,43 +244,40 @@ fn install_single_toolchain(
236
244
get_channel ( client, prefix, toolchain. commit ) ?
237
245
} ;
238
246
239
- // download every component except rust-std.
240
- for component in once ( & "rustc" ) . chain ( toolchain. components ) {
241
- let component_filename = if * component == "rust-src" {
242
- // rust-src is the only target-independent component
243
- format ! ( "{}-{}" , component, channel)
244
- } else {
245
- format ! ( "{}-{}-{}" , component, channel, toolchain. host_target)
246
- } ;
247
- download_tar_xz (
248
- maybe_dry_client,
249
- & format ! (
250
- "{}/{}/{}.tar.xz" ,
251
- prefix, toolchain. commit, & component_filename
252
- ) ,
253
- & toolchain. dest ,
254
- toolchain. commit ,
255
- component,
256
- channel,
257
- toolchain. host_target ,
258
- ) ?;
247
+ let mut components = toolchain. components . to_vec ( ) ;
248
+ if !toolchain. no_default_components {
249
+ components. insert ( 0 , "rustc" ) ;
250
+ components. push ( "rust-std" ) ;
259
251
}
260
252
261
- // download rust-std for every target.
262
- for target in toolchain. rust_std_targets {
263
- let rust_std_filename = format ! ( "rust-std-{}-{}" , channel, target) ;
264
- download_tar_xz (
265
- maybe_dry_client,
266
- & format ! (
267
- "{}/{}/{}.tar.xz" ,
268
- prefix, toolchain. commit, rust_std_filename
269
- ) ,
270
- & toolchain. dest ,
271
- toolchain. commit ,
272
- "rust-std" ,
273
- channel,
274
- target,
275
- ) ?;
253
+ for component in components {
254
+ let targets = if component == "rust-std" {
255
+ // download rust-std for every target
256
+ & toolchain. rust_std_targets
257
+ } else {
258
+ // otherwise just the host target
259
+ slice:: from_ref ( & toolchain. host_target )
260
+ } ;
261
+ for target in targets {
262
+ let component_filename = if component == "rust-src" {
263
+ // rust-src is the only target-independent component
264
+ format ! ( "{}-{}" , component, channel)
265
+ } else {
266
+ format ! ( "{}-{}-{}" , component, channel, target)
267
+ } ;
268
+ download_tar_xz (
269
+ maybe_dry_client,
270
+ & format ! (
271
+ "{}/{}/{}.tar.xz" ,
272
+ prefix, toolchain. commit, & component_filename
273
+ ) ,
274
+ & toolchain. dest ,
275
+ toolchain. commit ,
276
+ component,
277
+ channel,
278
+ target,
279
+ ) ?;
280
+ }
276
281
}
277
282
278
283
// install
@@ -472,6 +477,7 @@ fn run() -> Result<(), Error> {
472
477
host_target : host,
473
478
rust_std_targets : & rust_std_targets,
474
479
components : & components,
480
+ no_default_components : args. no_default_components ,
475
481
dest,
476
482
} ,
477
483
args. channel . as_deref ( ) ,
0 commit comments