Skip to content

Commit 270d545

Browse files
committed
move clippy download from python to rust
1 parent 3b92376 commit 270d545

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/bootstrap/bootstrap.py

-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ def download_toolchain(self):
570570
("rust-std-{}".format(toolchain_suffix), "rust-std-{}".format(self.build)),
571571
("rustc-{}".format(toolchain_suffix), "rustc"),
572572
("cargo-{}".format(toolchain_suffix), "cargo"),
573-
("clippy-{}".format(toolchain_suffix), "clippy-preview"),
574573
]
575574

576575
tarballs_download_info = [

src/bootstrap/src/core/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ impl<'a> Builder<'a> {
11651165

11661166
if run_compiler.stage == 0 {
11671167
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
1168-
let cargo_clippy = self.initial_rustc.parent().unwrap().join("cargo-clippy");
1168+
let cargo_clippy = self.build.config.download_clippy();
11691169
let mut cmd = Command::new(cargo_clippy);
11701170
cmd.env("PATH", &path);
11711171
return cmd;

src/bootstrap/src/core/download.rs

+26
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,32 @@ enum DownloadSource {
375375

376376
/// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions.
377377
impl Config {
378+
pub(crate) fn download_clippy(&self) -> PathBuf {
379+
self.verbose("downloading stage0 clippy artifacts");
380+
381+
let date = &self.stage0_metadata.compiler.date;
382+
let version = &self.stage0_metadata.compiler.version;
383+
let host = self.build;
384+
385+
let bin_root = self.out.join(host.triple).join("stage0");
386+
let clippy_stamp = bin_root.join(".clippy-stamp");
387+
let cargo_clippy = bin_root.join("bin").join(exe("cargo-clippy", host));
388+
if cargo_clippy.exists() && !program_out_of_date(&clippy_stamp, &date) {
389+
return cargo_clippy;
390+
}
391+
392+
let filename = format!("clippy-{version}-{host}.tar.xz");
393+
self.download_component(DownloadSource::Dist, filename, "clippy-preview", date, "stage0");
394+
if self.should_fix_bins_and_dylibs() {
395+
self.fix_bin_or_dylib(&cargo_clippy);
396+
self.fix_bin_or_dylib(&cargo_clippy.with_file_name(exe("clippy-driver", host)));
397+
}
398+
399+
cargo_clippy
400+
}
401+
402+
/// NOTE: rustfmt is a completely different toolchain than the bootstrap compiler, so it can't
403+
/// reuse target directories or artifacts
378404
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
379405
let RustfmtMetadata { date, version } = self.stage0_metadata.rustfmt.as_ref()?;
380406
let channel = format!("{version}-{date}");

0 commit comments

Comments
 (0)