Skip to content

Commit 9d694b5

Browse files
committed
support custom clippy
Similar to cargo, rustc, and rustfmt, this adds the support of using custom clippy on bootstrap. It’s designed for those who want to test their own clippy builds or avoid downloading the stage0 clippy. Signed-off-by: onur-ozkan <[email protected]>
1 parent 3f121b9 commit 9d694b5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/bootstrap/src/core/builder.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,12 @@ impl<'a> Builder<'a> {
12981298

12991299
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
13001300
if run_compiler.stage == 0 {
1301-
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
1302-
let cargo_clippy = self.build.config.download_clippy();
1301+
let cargo_clippy = self
1302+
.config
1303+
.initial_cargo_clippy
1304+
.clone()
1305+
.unwrap_or_else(|| self.build.config.download_clippy());
1306+
13031307
let mut cmd = command(cargo_clippy);
13041308
cmd.env("CARGO", &self.initial_cargo);
13051309
return cmd;

src/bootstrap/src/core/config/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ pub struct Config {
344344
// These are either the stage0 downloaded binaries or the locally installed ones.
345345
pub initial_cargo: PathBuf,
346346
pub initial_rustc: PathBuf,
347+
pub initial_cargo_clippy: Option<PathBuf>,
347348

348349
#[cfg(not(test))]
349350
initial_rustfmt: RefCell<RustfmtState>,
@@ -834,6 +835,7 @@ define_config! {
834835
cargo: Option<PathBuf> = "cargo",
835836
rustc: Option<PathBuf> = "rustc",
836837
rustfmt: Option<PathBuf> = "rustfmt",
838+
cargo_clippy: Option<PathBuf> = "cargo-clippy",
837839
docs: Option<bool> = "docs",
838840
compiler_docs: Option<bool> = "compiler-docs",
839841
library_docs_private_items: Option<bool> = "library-docs-private-items",
@@ -1439,6 +1441,7 @@ impl Config {
14391441
cargo,
14401442
rustc,
14411443
rustfmt,
1444+
cargo_clippy,
14421445
docs,
14431446
compiler_docs,
14441447
library_docs_private_items,
@@ -1491,6 +1494,14 @@ impl Config {
14911494
config.out = absolute(&config.out).expect("can't make empty path absolute");
14921495
}
14931496

1497+
if cargo_clippy.is_some() && rustc.is_none() {
1498+
println!(
1499+
"WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict."
1500+
);
1501+
}
1502+
1503+
config.initial_cargo_clippy = cargo_clippy;
1504+
14941505
config.initial_rustc = if let Some(rustc) = rustc {
14951506
if !flags.skip_stage0_validation {
14961507
config.check_stage0_version(&rustc, "rustc");

0 commit comments

Comments
 (0)