Skip to content

Commit 6586074

Browse files
committed
Auto merge of #50062 - varkor:xpy-check-rustdoc, r=Mark-Simulacrum
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
2 parents 85f5dd4 + 261da71 commit 6586074

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

src/bootstrap/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ 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,
314+
check::Rustdoc),
314315
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
315316
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
316317
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,

src/bootstrap/check.rs

+58-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::{self, 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,54 @@ 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+
builder.ensure(tool::CleanTools {
237+
compiler,
238+
target,
239+
mode: Mode::Tool,
240+
});
241+
}
242+
}
243+
193244
/// Cargo's output path for the standard library in a given stage, compiled
194245
/// by a particular compiler for the specified target.
195246
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
@@ -217,3 +268,9 @@ fn codegen_backend_stamp(builder: &Builder,
217268
builder.cargo_out(compiler, Mode::Librustc, target)
218269
.join(format!(".librustc_trans-{}-check.stamp", backend))
219270
}
271+
272+
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
273+
/// compiler for the specified target.
274+
pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
275+
builder.cargo_out(compiler, Mode::Tool, target).join(".rustdoc-check.stamp")
276+
}

0 commit comments

Comments
 (0)