Skip to content

Commit e71c39a

Browse files
committed
Add --with-src to download rust-src
1 parent be941d7 commit e71c39a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ struct Opts {
107107
)]
108108
with_cargo: bool,
109109

110+
#[structopt(
111+
long = "with-src", help = "Download rust-src, by default this is not downloaded"
112+
)]
113+
with_src: bool,
114+
110115
#[structopt(
111116
long = "test-dir",
112117
help = "Directory to test; this is where you usually run `cargo build`",
@@ -298,6 +303,7 @@ struct DownloadParams {
298303
tmp_dir: PathBuf,
299304
install_dir: PathBuf,
300305
install_cargo: bool,
306+
install_src: bool,
301307
force_install: bool,
302308
}
303309

@@ -314,6 +320,7 @@ impl DownloadParams {
314320
tmp_dir: cfg.rustup_tmp_path.clone(),
315321
install_dir: cfg.toolchains_path.clone(),
316322
install_cargo: cfg.args.with_cargo,
323+
install_src: cfg.args.with_src,
317324
force_install: cfg.args.force_install,
318325
}
319326
}
@@ -324,6 +331,7 @@ impl DownloadParams {
324331
tmp_dir: cfg.rustup_tmp_path.clone(),
325332
install_dir: cfg.toolchains_path.clone(),
326333
install_cargo: cfg.args.with_cargo,
334+
install_src: cfg.args.with_src,
327335
force_install: cfg.args.force_install,
328336
}
329337
}
@@ -613,6 +621,17 @@ impl Toolchain {
613621
).map_err(InstallError::Download)?;
614622
}
615623

624+
if dl_params.install_src {
625+
let filename = "rust-src-nightly";
626+
download_tarball(
627+
&client,
628+
"rust-src",
629+
&format!("{}/{}/{}.tar", dl_params.url_prefix, location, filename,),
630+
Some(&PathBuf::from(&filename).join("rust-src")),
631+
tmpdir.path(),
632+
).map_err(InstallError::Download)?;
633+
}
634+
616635
fs::rename(tmpdir.into_path(), dest).map_err(InstallError::Move)?;
617636

618637
Ok(())

0 commit comments

Comments
 (0)