Skip to content

Add rustdoc to x.py check #50062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}