From 1766992662cfed57047760b908fc1afc2bcaede0 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 14:27:20 +0200 Subject: [PATCH 1/6] 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 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/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 91dddc7b5bc8a..40b0ec483c905 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 d798e8de3dffa..fe175117483ac 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 = 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 0000000000000..7cdaeae1b877c --- /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 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)) From 49fca85b1902e599f8c3dadece7de85ecc6cbd06 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 18:06:10 +0200 Subject: [PATCH 2/6] Document the process of updating external dependencies --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c54dfd33883d..8258b68841bbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -298,6 +298,31 @@ 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 checkout pulls/$id_of_your_pr/head +``` + +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` From f46777696cba5566b0312cfb37686e4840e2df5a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 18:14:16 +0200 Subject: [PATCH 3/6] Fetch the pull request before checkout --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8258b68841bbf..cac56203e740d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -309,7 +309,8 @@ 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 checkout pulls/$id_of_your_pr/head +git fetch origin pull/$id_of_your_pr/head +git checkout pull/$id_of_your_pr/head ``` within the submodule's directory. Don't forget to also add your changes with From b9e4bdbf6017739a0d9c1fa40532d1752021af14 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 18:28:10 +0200 Subject: [PATCH 4/6] Add a Cargo.lock to clippy --- src/tools/clippy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy b/src/tools/clippy index 7cdaeae1b877c..4402bc70a3b17 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 7cdaeae1b877ca03b26ccb9b82754b826b03da5d +Subproject commit 4402bc70a3b175c38994bbc802bee41ddc59165b From 93a918325633085aed955abf291d4dff4b1e0aa7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 15 Aug 2017 18:32:04 +0200 Subject: [PATCH 5/6] Update workflow to git oddities --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cac56203e740d..e58d8e124791d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -309,8 +309,8 @@ 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 -git checkout pull/$id_of_your_pr/head +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 From 20f1e6809e302e0a6353ccf744916b47a1f2535c Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 24 Aug 2017 09:22:17 +0200 Subject: [PATCH 6/6] Require adding clippy's path to the `x.py` invocation --- 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 fe175117483ac..10bfdf478d3d2 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -348,7 +348,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 {