diff options
| author | David Wood <david@davidtw.co> | 2018-03-22 14:57:28 +0000 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-03-22 17:21:30 +0000 |
| commit | 1b0e9f5af9283b003f5fce6f19ede145c1776684 (patch) | |
| tree | 2e43a2cc315a8d9a754c7e030feb2b8c8f83df0d | |
| parent | 1392179cdc9c96e75353771959c246553b918d57 (diff) | |
| download | rust-1b0e9f5af9283b003f5fce6f19ede145c1776684.tar.gz rust-1b0e9f5af9283b003f5fce6f19ede145c1776684.zip | |
Only generate documentation for local rustc crates.
| -rw-r--r-- | src/bootstrap/doc.rs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index ca45adb4649..e525bdb98fc 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -17,12 +17,13 @@ //! Everything here is basically just a shim around calling either `rustbook` or //! `rustdoc`. +use std::collections::HashSet; use std::fs::{self, File}; use std::io::prelude::*; use std::io; use std::path::{PathBuf, Path}; -use Mode; +use {Build, Mode}; use build_helper::up_to_date; use util::{cp_r, symlink_dir}; @@ -704,15 +705,41 @@ impl Step for Rustc { let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc"); compile::rustc_cargo(build, &mut cargo); - // src/rustc/Cargo.toml contains a bin crate called rustc which - // would otherwise overwrite the docs for the real rustc lib crate. - cargo.arg("-p").arg("rustc_driver"); + // Only include compiler crates, no dependencies of those, such as `libc`. + cargo.arg("--no-deps"); + + // Find dependencies for top level crates. + let mut compiler_crates = HashSet::new(); + for root_crate in &["rustc", "rustc_driver"] { + let interned_root_crate = INTERNER.intern_str(root_crate); + find_compiler_crates(&build, &interned_root_crate, &mut compiler_crates); + } + + for krate in &compiler_crates { + cargo.arg("-p").arg(krate); + } build.run(&mut cargo); cp_r(&my_out, &out); } } +fn find_compiler_crates( + build: &Build, + name: &Interned<String>, + crates: &mut HashSet<Interned<String>> +) { + // Add current crate. + crates.insert(*name); + + // Look for dependencies. + for dep in build.crates.get(name).unwrap().deps.iter() { + if build.crates.get(dep).unwrap().is_local(build) { + find_compiler_crates(build, dep, crates); + } + } +} + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { target: Interned<String>, |
