Skip to content

Commit

Permalink
Auto merge of #50062 - varkor:xpy-check-rustdoc, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Add rustdoc to x.py check

Modifying rustc can often cause errors in rustdoc, so it's useful to include it in the steps that are checked.

One thing that I was unsure about was when to call `clear_if_dirty` (both in this step, and in other steps in relation to this one) — we want to be sure rustdoc will always be rechecked after modifying previous steps — but does this belong in rustdoc, or the other steps?

Fixes #49917.

r? @Mark-Simulacrum
  • Loading branch information
bors committed Apr 20, 2018
2 parents 85f5dd4 + 261da71 commit 6586074
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ 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,
Expand Down
59 changes: 58 additions & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{self, prepare_tool_cargo};
use {Compiler, Mode};
use cache::{INTERNER, Interned};
use std::path::PathBuf;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -190,6 +193,54 @@ 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));

builder.ensure(tool::CleanTools {
compiler,
target,
mode: Mode::Tool,
});
}
}

/// 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 {
Expand Down Expand Up @@ -217,3 +268,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")
}

0 comments on commit 6586074

Please sign in to comment.