Skip to content

Commit baf940d

Browse files
committed
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.
1 parent 8a28d94 commit baf940d

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'a> Builder<'a> {
310310
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
311311
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
312312
native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
313-
Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend),
313+
Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, check::Rustdoc),
314314
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
315315
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
316316
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,

src/bootstrap/check.rs

+52-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
1414
use builder::{RunConfig, Builder, ShouldRun, Step};
15+
use tool::prepare_tool_cargo;
1516
use {Compiler, Mode};
1617
use cache::{INTERNER, Interned};
1718
use std::path::PathBuf;
@@ -41,6 +42,7 @@ impl Step for Std {
4142

4243
let out_dir = builder.stage_out(compiler, Mode::Libstd);
4344
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
45+
4446
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
4547
std_cargo(builder, &compiler, target, &mut cargo);
4648

@@ -170,11 +172,12 @@ impl Step for Test {
170172
}
171173

172174
fn run(self, builder: &Builder) {
173-
let target = self.target;
174175
let compiler = builder.compiler(0, builder.config.build);
176+
let target = self.target;
175177

176178
let out_dir = builder.stage_out(compiler, Mode::Libtest);
177179
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
180+
178181
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
179182
test_cargo(builder, &compiler, target, &mut cargo);
180183

@@ -190,6 +193,48 @@ impl Step for Test {
190193
}
191194
}
192195

196+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
197+
pub struct Rustdoc {
198+
pub target: Interned<String>,
199+
}
200+
201+
impl Step for Rustdoc {
202+
type Output = ();
203+
const ONLY_HOSTS: bool = true;
204+
const DEFAULT: bool = true;
205+
206+
fn should_run(run: ShouldRun) -> ShouldRun {
207+
run.path("src/tools/rustdoc")
208+
}
209+
210+
fn make_run(run: RunConfig) {
211+
run.builder.ensure(Rustdoc {
212+
target: run.target,
213+
});
214+
}
215+
216+
fn run(self, builder: &Builder) {
217+
let compiler = builder.compiler(0, builder.config.build);
218+
let target = self.target;
219+
220+
let mut cargo = prepare_tool_cargo(builder,
221+
compiler,
222+
target,
223+
"check",
224+
"src/tools/rustdoc");
225+
226+
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
227+
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
228+
run_cargo(builder,
229+
&mut cargo,
230+
&rustdoc_stamp(builder, compiler, target),
231+
true);
232+
233+
let libdir = builder.sysroot_libdir(compiler, target);
234+
add_to_sysroot(&builder, &libdir, &rustdoc_stamp(builder, compiler, target));
235+
}
236+
}
237+
193238
/// Cargo's output path for the standard library in a given stage, compiled
194239
/// by a particular compiler for the specified target.
195240
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
@@ -217,3 +262,9 @@ fn codegen_backend_stamp(builder: &Builder,
217262
builder.cargo_out(compiler, Mode::Librustc, target)
218263
.join(format!(".librustc_trans-{}-check.stamp", backend))
219264
}
265+
266+
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
267+
/// compiler for the specified target.
268+
pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
269+
builder.cargo_out(compiler, Mode::Tool, target).join(".rustdoc-check.stamp")
270+
}

0 commit comments

Comments
 (0)