Skip to content

Commit

Permalink
Add rustdoc to x.py check
Browse files Browse the repository at this point in the history
This can often encounter errors after modifying rustc, so it's useful to include it in the steps that are checked.
  • Loading branch information
varkor committed Apr 19, 2018
1 parent 8a28d94 commit baf940d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -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,
Expand Down
53 changes: 52 additions & 1 deletion src/bootstrap/check.rs
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::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,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 {
Expand Down Expand Up @@ -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")
}

0 comments on commit baf940d

Please sign in to comment.