Skip to content

Commit 1766992

Browse files
committed
Add clippy as a submodule
1 parent c774c95 commit 1766992

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333
[submodule "src/libcompiler_builtins"]
3434
path = src/libcompiler_builtins
3535
url = https://github.com/rust-lang-nursery/compiler-builtins
36+
[submodule "src/tools/clippy"]
37+
path = src/tools/clippy
38+
url = https://github.com/rust-lang-nursery/rust-clippy.git

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'a> Builder<'a> {
248248
compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
249249
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
250250
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
251-
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc,
251+
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
252252
native::Llvm),
253253
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
254254
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,

src/bootstrap/tool.rs

+38
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,44 @@ impl Step for Cargo {
340340
}
341341
}
342342

343+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
344+
pub struct Clippy {
345+
pub compiler: Compiler,
346+
pub target: Interned<String>,
347+
}
348+
349+
impl Step for Clippy {
350+
type Output = PathBuf;
351+
const DEFAULT: bool = true;
352+
const ONLY_HOSTS: bool = true;
353+
354+
fn should_run(run: ShouldRun) -> ShouldRun {
355+
run.path("src/tools/clippy")
356+
}
357+
358+
fn make_run(run: RunConfig) {
359+
run.builder.ensure(Clippy {
360+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
361+
target: run.target,
362+
});
363+
}
364+
365+
fn run(self, builder: &Builder) -> PathBuf {
366+
// Clippy depends on procedural macros (serde), which requires a full host
367+
// compiler to be available, so we need to depend on that.
368+
builder.ensure(compile::Rustc {
369+
compiler: self.compiler,
370+
target: builder.build.build,
371+
});
372+
builder.ensure(ToolBuild {
373+
compiler: self.compiler,
374+
target: self.target,
375+
tool: "clippy",
376+
mode: Mode::Librustc,
377+
})
378+
}
379+
}
380+
343381
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
344382
pub struct Rls {
345383
pub compiler: Compiler,

src/tools/clippy

Submodule clippy added at 7cdaeae

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn filter_dirs(path: &Path) -> bool {
6262
"src/rt/hoedown",
6363
"src/tools/cargo",
6464
"src/tools/rls",
65+
"src/tools/clippy",
6566
"src/tools/rust-installer",
6667
];
6768
skip.iter().any(|p| path.ends_with(p))

0 commit comments

Comments
 (0)