about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-04-18 19:46:58 +0100
committervarkor <github@varkor.com>2018-04-19 19:06:34 +0100
commitbaf940d58087dfe7bba3c675215c34c774b778ae (patch)
tree54aa7675b3012ae406c6dd1d9046d2dde03e8184
parent8a28d94ea1b6c19b7e1d41ef9b33ccb73951f654 (diff)
Add rustdoc to x.py check
This can often encounter errors after modifying rustc, so it's useful to include it in the steps that are checked.
-rw-r--r--src/bootstrap/builder.rs2
-rw-r--r--src/bootstrap/check.rs53
2 files changed, 53 insertions, 2 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 7ac9b146fe5..cc501d6f9ba 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -310,7 +310,7 @@ impl<'a> Builder<'a> {
                 tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
                 tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
                 native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
-            Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend),
+            Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, check::Rustdoc),
             Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
                 test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
                 test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index e7c6ec888df..4c84be4ed2e 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -12,6 +12,7 @@
 
 use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
 use builder::{RunConfig, Builder, ShouldRun, Step};
+use tool::prepare_tool_cargo;
 use {Compiler, Mode};
 use cache::{INTERNER, Interned};
 use std::path::PathBuf;
@@ -41,6 +42,7 @@ impl Step for Std {
 
         let out_dir = builder.stage_out(compiler, Mode::Libstd);
         builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
+
         let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
         std_cargo(builder, &compiler, target, &mut cargo);
 
@@ -170,11 +172,12 @@ impl Step for Test {
     }
 
     fn run(self, builder: &Builder) {
-        let target = self.target;
         let compiler = builder.compiler(0, builder.config.build);
+        let target = self.target;
 
         let out_dir = builder.stage_out(compiler, Mode::Libtest);
         builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
+
         let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
         test_cargo(builder, &compiler, target, &mut cargo);
 
@@ -190,6 +193,48 @@ impl Step for Test {
     }
 }
 
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct Rustdoc {
+    pub target: Interned<String>,
+}
+
+impl Step for Rustdoc {
+    type Output = ();
+    const ONLY_HOSTS: bool = true;
+    const DEFAULT: bool = true;
+
+    fn should_run(run: ShouldRun) -> ShouldRun {
+        run.path("src/tools/rustdoc")
+    }
+
+    fn make_run(run: RunConfig) {
+        run.builder.ensure(Rustdoc {
+            target: run.target,
+        });
+    }
+
+    fn run(self, builder: &Builder) {
+        let compiler = builder.compiler(0, builder.config.build);
+        let target = self.target;
+
+        let mut cargo = prepare_tool_cargo(builder,
+                                           compiler,
+                                           target,
+                                           "check",
+                                           "src/tools/rustdoc");
+
+        let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
+        println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
+        run_cargo(builder,
+                  &mut cargo,
+                  &rustdoc_stamp(builder, compiler, target),
+                  true);
+
+        let libdir = builder.sysroot_libdir(compiler, target);
+        add_to_sysroot(&builder, &libdir, &rustdoc_stamp(builder, compiler, target));
+    }
+}
+
 /// Cargo's output path for the standard library in a given stage, compiled
 /// by a particular compiler for the specified target.
 pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
@@ -217,3 +262,9 @@ fn codegen_backend_stamp(builder: &Builder,
     builder.cargo_out(compiler, Mode::Librustc, target)
          .join(format!(".librustc_trans-{}-check.stamp", backend))
 }
+
+/// Cargo's output path for rustdoc in a given stage, compiled by a particular
+/// compiler for the specified target.
+pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
+    builder.cargo_out(compiler, Mode::Tool, target).join(".rustdoc-check.stamp")
+}