diff options
| author | onur-ozkan <work@onurozkan.dev> | 2024-08-26 08:28:26 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2024-08-26 08:28:26 +0300 |
| commit | 9d694b583e3c4e899f61cb2086e2ed9627ec3619 (patch) | |
| tree | 9a69fb115e61c7ef2519e2ff6f63c4ac6d881c82 /src/bootstrap | |
| parent | 3f121b9461cce02a703a0e7e450568849dfaa074 (diff) | |
| download | rust-9d694b583e3c4e899f61cb2086e2ed9627ec3619.tar.gz rust-9d694b583e3c4e899f61cb2086e2ed9627ec3619.zip | |
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 <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/builder.rs | 8 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 11 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index ff0d1f3a725..d7398b76cc9 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1298,8 +1298,12 @@ impl<'a> Builder<'a> { pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand { if run_compiler.stage == 0 { - // `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy. - let cargo_clippy = self.build.config.download_clippy(); + let cargo_clippy = self + .config + .initial_cargo_clippy + .clone() + .unwrap_or_else(|| self.build.config.download_clippy()); + let mut cmd = command(cargo_clippy); cmd.env("CARGO", &self.initial_cargo); return cmd; diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index ce23b7735f8..cf87f1ff947 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -344,6 +344,7 @@ pub struct Config { // These are either the stage0 downloaded binaries or the locally installed ones. pub initial_cargo: PathBuf, pub initial_rustc: PathBuf, + pub initial_cargo_clippy: Option<PathBuf>, #[cfg(not(test))] initial_rustfmt: RefCell<RustfmtState>, @@ -834,6 +835,7 @@ define_config! { cargo: Option<PathBuf> = "cargo", rustc: Option<PathBuf> = "rustc", rustfmt: Option<PathBuf> = "rustfmt", + cargo_clippy: Option<PathBuf> = "cargo-clippy", docs: Option<bool> = "docs", compiler_docs: Option<bool> = "compiler-docs", library_docs_private_items: Option<bool> = "library-docs-private-items", @@ -1439,6 +1441,7 @@ impl Config { cargo, rustc, rustfmt, + cargo_clippy, docs, compiler_docs, library_docs_private_items, @@ -1491,6 +1494,14 @@ impl Config { config.out = absolute(&config.out).expect("can't make empty path absolute"); } + if cargo_clippy.is_some() && rustc.is_none() { + println!( + "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." + ); + } + + config.initial_cargo_clippy = cargo_clippy; + config.initial_rustc = if let Some(rustc) = rustc { if !flags.skip_stage0_validation { config.check_stage0_version(&rustc, "rustc"); |
