diff options
| author | Tim Neumann <mail@timnn.me> | 2017-09-17 13:19:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-17 13:19:04 +0200 |
| commit | eea2f5596a0ee32d129d0dc9a64439cbe4bcf802 (patch) | |
| tree | 031201e53414a5c5bc28842a11c236e66d046f11 /src/bootstrap | |
| parent | 39710f8fccded5965f31add466e2fd20da4904ec (diff) | |
| parent | 368cab3b0357194f407060cd1a1d3339cf854c25 (diff) | |
| download | rust-eea2f5596a0ee32d129d0dc9a64439cbe4bcf802.tar.gz rust-eea2f5596a0ee32d129d0dc9a64439cbe4bcf802.zip | |
Rollup merge of #44533 - nrc:rustfmt-submod, r=alexcrichton
Add Rustfmt r? @alexcrichton
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/check.rs | 41 | ||||
| -rw-r--r-- | src/bootstrap/mk/Makefile.in | 1 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 34 |
4 files changed, 78 insertions, 2 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 4765546b184..7ff0154bf8b 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -249,11 +249,11 @@ impl<'a> Builder<'a> { tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest, tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient, tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy, - native::Llvm), + native::Llvm, tool::Rustfmt), 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::ErrorIndex, check::Distcheck, check::Rustfmt), 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 5853d5ae320..94bb89145fb 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -253,6 +253,47 @@ impl Step for Rls { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct Rustfmt { + stage: u32, + host: Interned<String>, +} + +impl Step for Rustfmt { + type Output = (); + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("src/tools/rustfmt") + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Rustfmt { + stage: run.builder.top_stage, + host: run.target, + }); + } + + /// Runs `cargo test` for rustfmt. + fn run(self, builder: &Builder) { + let build = builder.build; + let stage = self.stage; + let host = self.host; + let compiler = builder.compiler(stage, host); + + builder.ensure(tool::Rustfmt { compiler, target: self.host }); + let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); + cargo.arg("--manifest-path").arg(build.src.join("src/tools/rustfmt/Cargo.toml")); + + // Don't build tests dynamically, just a pain to work with + cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); + + builder.add_rustc_lib_path(compiler, &mut cargo); + + try_run(build, &mut cargo); + } +} + fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { // Configure PATH to find the right rustc. NB. we have to use PATH // and not RUSTC because the Cargo test suite has tests that will diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 67495b891f8..72be9c12e84 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -55,6 +55,7 @@ check-aux: src/tools/cargotest \ src/tools/cargo \ src/tools/rls \ + src/tools/rustfmt \ src/test/pretty \ src/test/run-pass/pretty \ src/test/run-fail/pretty \ diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index a4e9f682358..d082012acc1 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -445,6 +445,40 @@ impl Step for Rls { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Rustfmt { + pub compiler: Compiler, + pub target: Interned<String>, +} + +impl Step for Rustfmt { + type Output = PathBuf; + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + let builder = run.builder; + run.path("src/tools/rustfmt").default_condition(builder.build.config.extended) + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Rustfmt { + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + target: run.target, + }); + } + + fn run(self, builder: &Builder) -> PathBuf { + builder.ensure(ToolBuild { + compiler: self.compiler, + target: self.target, + tool: "rustfmt", + mode: Mode::Librustc, + path: "src/tools/rustfmt", + }) + } +} + impl<'a> Builder<'a> { /// Get a `Command` which is ready to run `tool` in `stage` built for /// `host`. |
