From d64a0674231c12587ce6dc4295d5b78dec98c5a3 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 18 Sep 2017 13:13:57 +0200 Subject: [PATCH 1/2] Add clippy to `toolstate.toml` --- CONTRIBUTING.md | 16 ++------------ src/bootstrap/builder.rs | 2 +- src/bootstrap/check.rs | 44 ++++++++++++++++++++++++++++++++++++++ src/bootstrap/tool.rs | 4 ++-- src/bootstrap/toolstate.rs | 1 + src/tools/toolstate.toml | 15 ++++++++----- 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 741ced8f0912d..72144f22f5cae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -330,23 +330,11 @@ it can be found Currently building Rust will also build the following external projects: * [clippy](https://github.com/rust-lang-nursery/rust-clippy) +* [miri](https://github.com/solson/miri) If your changes break one of these projects, you need to fix them by opening a pull request against the broken project. When you have opened a pull request, -you can point the submodule at your pull request by calling - -``` -git fetch origin pull/$id_of_your_pr/head:my_pr -git checkout my_pr -``` - -within the submodule's directory. Don't forget to also add your changes with - -``` -git add path/to/submodule -``` - -outside the submodule. +you can disable the tool via `src/tools/toolstate.toml`. It can also be more convenient during development to set `submodules = false` in the `config.toml` to prevent `x.py` from resetting to the original branch. diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7d116f23ef581..8a6c998c932c2 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -254,7 +254,7 @@ impl<'a> Builder<'a> { Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest, check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc, check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs, - check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri), + check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy), Kind::Bench => describe!(check::Crate, check::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon, diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 25266fc538f1b..21e7a05236266 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -348,6 +348,50 @@ impl Step for Miri { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct Clippy { + host: Interned, +} + +impl Step for Clippy { + type Output = (); + const ONLY_HOSTS: bool = true; + const DEFAULT: bool = false; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("src/tools/clippy") + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Clippy { + host: run.target, + }); + } + + /// Runs `cargo test` for clippy. + fn run(self, builder: &Builder) { + let build = builder.build; + let host = self.host; + let compiler = builder.compiler(1, host); + + let _clippy = builder.ensure(tool::Clippy { compiler, target: self.host }); + let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); + cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml")); + + // Don't build tests dynamically, just a pain to work with + cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); + // clippy tests need to know about the stage sysroot + cargo.env("SYSROOT", builder.sysroot(compiler)); + + builder.add_rustc_lib_path(compiler, &mut cargo); + + try_run_expecting( + build, + &mut cargo, + builder.build.config.toolstate.clippy.passes(ToolState::Testing), + ); + } +} fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { // Configure PATH to find the right rustc. NB. we have to use PATH diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 1617351af4cf1..5edaf435eece9 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -378,7 +378,7 @@ pub struct Clippy { impl Step for Clippy { type Output = PathBuf; - const DEFAULT: bool = false; + const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -405,7 +405,7 @@ impl Step for Clippy { tool: "clippy", mode: Mode::Librustc, path: "src/tools/clippy", - expectation: BuildExpectation::None, + expectation: builder.build.config.toolstate.clippy.passes(ToolState::Compiling), }) } } diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 9556a8b52df67..0711c034602b5 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -45,4 +45,5 @@ impl Default for ToolState { /// This is created from `toolstate.toml`. pub struct ToolStates { pub miri: ToolState, + pub clippy: ToolState, } diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 697be4efadbc8..707b316190d65 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -10,15 +10,20 @@ # configures whether the tool is included in the Rust distribution. # # If a tool was working before your PR but is broken now, consider -# updating the tool within your PR. How to do that is described in +# opening a PR against the tool so that it works with your changes. +# If the tool stops compiling, change its state to `Broken`. If it +# still builds, change it to `Compiling`. +# How to do that is described in # "CONTRIBUTING.md#External Dependencies". If the effort required is not # warranted (e.g. due to the tool abusing some API that you changed, and -# fixing the tool would mean a significant refactoring), you can disable -# the tool here, by changing its state to `Broken`. Remember to ping -# the tool authors if you do not fix their tool, so they can proactively -# fix it, instead of being surprised by the breakage. +# fixing the tool would mean a significant refactoring) remember to ping +# the tool authors, so they can fix it, instead of being surprised by the +# breakage. # # Each tool has a list of people to ping # ping @oli-obk @RalfJung @eddyb miri = "Testing" + +# ping @Manishearth @llogiq @mcarton @oli-obk +clippy = "Broken" From 7d7e7d4b97fbf260d068cef5a2e449589ad49dc0 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 19 Sep 2017 16:08:19 +0200 Subject: [PATCH 2/2] Disable clippy building --- src/bootstrap/tool.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 5edaf435eece9..db794f6d6c72c 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -378,7 +378,7 @@ pub struct Clippy { impl Step for Clippy { type Output = PathBuf; - const DEFAULT: bool = true; + const DEFAULT: bool = false; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun {