diff --git a/.gitmodules b/.gitmodules index 6244b3c095186..fbebccf408fb6 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/CONTRIBUTING.md b/CONTRIBUTING.md index c424ca7ab009e..cdac8e696c8e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -298,6 +298,32 @@ Speaking of tests, Rust has a comprehensive test suite. More information about it can be found [here](https://github.com/rust-lang/rust-wiki-backup/blob/master/Note-testsuite.md). +### External Dependencies + +Currently building Rust will also build the following external projects: + +* [clippy](https://github.com/rust-lang-nursery/rust-clippy) + +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. + +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. + ## Writing Documentation Documentation improvements are very welcome. The source of `doc.rust-lang.org` diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 298f6a004a20a..722b3d16e9d19 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -248,7 +248,7 @@ impl<'a> Builder<'a> { 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 e759f1a3e6f85..0ad5bb8d2f673 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -340,6 +340,44 @@ impl Step for Cargo { } } +#[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 = false; + 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 0000000000000..4402bc70a3b17 --- /dev/null +++ b/src/tools/clippy @@ -0,0 +1 @@ +Subproject commit 4402bc70a3b175c38994bbc802bee41ddc59165b diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 020570e61dc63..731a3d96cff9d 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))