From 1766992662cfed57047760b908fc1afc2bcaede0 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 14:27:20 +0200 Subject: [PATCH] Add clippy as a submodule --- .gitmodules | 3 +++ src/bootstrap/builder.rs | 2 +- src/bootstrap/tool.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/tools/clippy | 1 + src/tools/tidy/src/lib.rs | 1 + 5 files changed, 44 insertions(+), 1 deletion(-) create mode 160000 src/tools/clippy diff --git a/.gitmodules b/.gitmodules index 6244b3c0951..fbebccf408f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,3 +33,6 @@ [submodule "src/libcompiler_builtins"] path = src/libcompiler_builtins url = https://github.com/rust-lang-nursery/compiler-builtins +[submodule "src/tools/clippy"] + path = src/tools/clippy + url = https://github.com/rust-lang-nursery/rust-clippy.git diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 91dddc7b5bc..40b0ec483c9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -248,7 +248,7 @@ macro_rules! describe { compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex, tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest, tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient, - tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, + tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy, native::Llvm), Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest, check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck, diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d798e8de3df..fe175117483 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -340,6 +340,44 @@ fn run(self, builder: &Builder) -> PathBuf { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Clippy { + pub compiler: Compiler, + pub target: Interned, +} + +impl Step for Clippy { + type Output = PathBuf; + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("src/tools/clippy") + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Clippy { + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + target: run.target, + }); + } + + fn run(self, builder: &Builder) -> PathBuf { + // Clippy depends on procedural macros (serde), which requires a full host + // compiler to be available, so we need to depend on that. + builder.ensure(compile::Rustc { + compiler: self.compiler, + target: builder.build.build, + }); + builder.ensure(ToolBuild { + compiler: self.compiler, + target: self.target, + tool: "clippy", + mode: Mode::Librustc, + }) + } +} + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rls { pub compiler: Compiler, diff --git a/src/tools/clippy b/src/tools/clippy new file mode 160000 index 00000000000..7cdaeae1b87 --- /dev/null +++ b/src/tools/clippy @@ -0,0 +1 @@ +Subproject commit 7cdaeae1b877ca03b26ccb9b82754b826b03da5d diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 020570e61dc..731a3d96cff 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -62,6 +62,7 @@ fn filter_dirs(path: &Path) -> bool { "src/rt/hoedown", "src/tools/cargo", "src/tools/rls", + "src/tools/clippy", "src/tools/rust-installer", ]; skip.iter().any(|p| path.ends_with(p)) -- 2.44.0