Skip to content

Commit 1b0e9f5

Browse files
committed
Only generate documentation for local rustc crates.
1 parent 1392179 commit 1b0e9f5

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/bootstrap/doc.rs

+31-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
//! Everything here is basically just a shim around calling either `rustbook` or
1818
//! `rustdoc`.
1919
20+
use std::collections::HashSet;
2021
use std::fs::{self, File};
2122
use std::io::prelude::*;
2223
use std::io;
2324
use std::path::{PathBuf, Path};
2425

25-
use Mode;
26+
use {Build, Mode};
2627
use build_helper::up_to_date;
2728

2829
use util::{cp_r, symlink_dir};
@@ -704,15 +705,41 @@ impl Step for Rustc {
704705
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
705706
compile::rustc_cargo(build, &mut cargo);
706707

707-
// src/rustc/Cargo.toml contains a bin crate called rustc which
708-
// would otherwise overwrite the docs for the real rustc lib crate.
709-
cargo.arg("-p").arg("rustc_driver");
708+
// Only include compiler crates, no dependencies of those, such as `libc`.
709+
cargo.arg("--no-deps");
710+
711+
// Find dependencies for top level crates.
712+
let mut compiler_crates = HashSet::new();
713+
for root_crate in &["rustc", "rustc_driver"] {
714+
let interned_root_crate = INTERNER.intern_str(root_crate);
715+
find_compiler_crates(&build, &interned_root_crate, &mut compiler_crates);
716+
}
717+
718+
for krate in &compiler_crates {
719+
cargo.arg("-p").arg(krate);
720+
}
710721

711722
build.run(&mut cargo);
712723
cp_r(&my_out, &out);
713724
}
714725
}
715726

727+
fn find_compiler_crates(
728+
build: &Build,
729+
name: &Interned<String>,
730+
crates: &mut HashSet<Interned<String>>
731+
) {
732+
// Add current crate.
733+
crates.insert(*name);
734+
735+
// Look for dependencies.
736+
for dep in build.crates.get(name).unwrap().deps.iter() {
737+
if build.crates.get(dep).unwrap().is_local(build) {
738+
find_compiler_crates(build, dep, crates);
739+
}
740+
}
741+
}
742+
716743
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
717744
pub struct ErrorIndex {
718745
target: Interned<String>,

0 commit comments

Comments
 (0)