Skip to content

Commit bc49c3b

Browse files
Allow to pass "compiler" arguments to doc subcommand
1 parent e846f9c commit bc49c3b

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

src/bootstrap/doc.rs

+44-10
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl Step for Rustc {
537537

538538
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
539539
let builder = run.builder;
540-
run.krate("rustc-main").default_condition(builder.config.docs)
540+
run.krate("rustc-main").path("compiler").default_condition(builder.config.docs)
541541
}
542542

543543
fn make_run(run: RunConfig<'_>) {
@@ -553,9 +553,24 @@ impl Step for Rustc {
553553
fn run(self, builder: &Builder<'_>) {
554554
let stage = self.stage;
555555
let target = self.target;
556+
let mut is_explicit_request = false;
556557
builder.info(&format!("Documenting stage{} compiler ({})", stage, target));
557558

558-
if !builder.config.compiler_docs {
559+
let paths = builder
560+
.paths
561+
.iter()
562+
.map(components_simplified)
563+
.filter_map(|path| {
564+
if path.get(0) == Some(&"compiler") {
565+
is_explicit_request = true;
566+
path.get(1).map(|p| p.to_owned())
567+
} else {
568+
None
569+
}
570+
})
571+
.collect::<Vec<_>>();
572+
573+
if !builder.config.compiler_docs && !is_explicit_request {
559574
builder.info("\tskipping - compiler/librustdoc docs disabled");
560575
return;
561576
}
@@ -603,15 +618,34 @@ impl Step for Rustc {
603618
cargo.rustdocflag("--extern-html-root-url");
604619
cargo.rustdocflag("ena=https://docs.rs/ena/latest/");
605620

606-
// Find dependencies for top level crates.
607621
let mut compiler_crates = HashSet::new();
608-
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
609-
compiler_crates.extend(
610-
builder
611-
.in_tree_crates(root_crate, Some(target))
612-
.into_iter()
613-
.map(|krate| krate.name),
614-
);
622+
623+
if paths.is_empty() {
624+
// Find dependencies for top level crates.
625+
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
626+
compiler_crates.extend(
627+
builder
628+
.in_tree_crates(root_crate, Some(target))
629+
.into_iter()
630+
.map(|krate| krate.name),
631+
);
632+
}
633+
} else {
634+
for root_crate in paths {
635+
if !builder.src.join("compiler").join(&root_crate).exists() {
636+
builder.info(&format!(
637+
"\tskipping - compiler/{} (unknown compiler crate)",
638+
root_crate
639+
));
640+
} else {
641+
compiler_crates.extend(
642+
builder
643+
.in_tree_crates(root_crate, Some(target))
644+
.into_iter()
645+
.map(|krate| krate.name),
646+
);
647+
}
648+
}
615649
}
616650

617651
for krate in &compiler_crates {

0 commit comments

Comments
 (0)