From 7b04f7fa637ece96da6da7f5a96ded9598b2bf36 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sun, 12 Mar 2017 02:45:20 +0000 Subject: [PATCH 1/2] rustbuild: Fix compiler docs * Make sure std docs are generated before compiler docs so rustdoc uses relative links. * Don't document the rustc and rustdoc binary crates as they overwrite the real rustc and rustdoc crates. --- src/bootstrap/doc.rs | 16 ++++++++++------ src/bootstrap/step.rs | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 5a5cfe0c682..db8ed579cec 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -168,9 +168,7 @@ pub fn std(build: &Build, stage: u32, target: &str) { // We don't want to build docs for internal std dependencies unless // in compiler-docs mode. When not in that mode, we whitelist the crates // for which docs must be built. - if build.config.compiler_docs { - cargo.arg("-p").arg("std"); - } else { + if !build.config.compiler_docs { cargo.arg("--no-deps"); for krate in &["alloc", "collections", "core", "std", "std_unicode"] { cargo.arg("-p").arg(krate); @@ -244,9 +242,15 @@ pub fn rustc(build: &Build, stage: u32, target: &str) { .arg(build.src.join("src/rustc/Cargo.toml")) .arg("--features").arg(build.rustc_features()); - // Like with libstd above if compiler docs aren't enabled then we're not - // documenting internal dependencies, so we have a whitelist. - if !build.config.compiler_docs { + if build.config.compiler_docs { + // src/rustc/Cargo.toml contains bin crates called rustc and rustdoc + // which would otherwise overwrite the docs for the real rustc and + // rustdoc lib crates. + cargo.arg("-p").arg("rustc_driver") + .arg("-p").arg("rustdoc"); + } else { + // Like with libstd above if compiler docs aren't enabled then we're not + // documenting internal dependencies, so we have a whitelist. cargo.arg("--no-deps"); for krate in &["proc_macro"] { cargo.arg("-p").arg(krate); diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 39f07459d42..8fe3a0d897f 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -633,12 +633,16 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { for (krate, path, default) in krates("test") { rules.doc(&krate.doc_step, path) .dep(|s| s.name("libtest-link")) + // Needed so rustdoc generates relative links to std. + .dep(|s| s.name("doc-crate-std")) .default(default && build.config.compiler_docs) .run(move |s| doc::test(build, s.stage, s.target)); } for (krate, path, default) in krates("rustc-main") { rules.doc(&krate.doc_step, path) .dep(|s| s.name("librustc-link")) + // Needed so rustdoc generates relative links to std. + .dep(|s| s.name("doc-crate-std")) .host(true) .default(default && build.config.docs) .run(move |s| doc::rustc(build, s.stage, s.target)); From 0e0bac914c9324a8ac72769810aaff00d758f0d7 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sun, 12 Mar 2017 05:09:10 +0000 Subject: [PATCH 2/2] rustbuild: Fix tests Use the same step names as the actual build. --- src/bootstrap/step.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 8fe3a0d897f..6b047c62d99 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -1217,20 +1217,20 @@ mod tests { name: "std".to_string(), deps: Vec::new(), path: cwd.join("src/std"), - doc_step: "doc-std".to_string(), + doc_step: "doc-crate-std".to_string(), build_step: "build-crate-std".to_string(), - test_step: "test-std".to_string(), - bench_step: "bench-std".to_string(), + test_step: "test-crate-std".to_string(), + bench_step: "bench-crate-std".to_string(), version: String::new(), }); build.crates.insert("test".to_string(), ::Crate { name: "test".to_string(), deps: Vec::new(), path: cwd.join("src/test"), - doc_step: "doc-test".to_string(), + doc_step: "doc-crate-test".to_string(), build_step: "build-crate-test".to_string(), - test_step: "test-test".to_string(), - bench_step: "bench-test".to_string(), + test_step: "test-crate-test".to_string(), + bench_step: "bench-crate-test".to_string(), version: String::new(), }); build.crates.insert("rustc-main".to_string(), ::Crate { @@ -1238,10 +1238,10 @@ mod tests { deps: Vec::new(), version: String::new(), path: cwd.join("src/rustc-main"), - doc_step: "doc-rustc-main".to_string(), + doc_step: "doc-crate-rustc-main".to_string(), build_step: "build-crate-rustc-main".to_string(), - test_step: "test-rustc-main".to_string(), - bench_step: "bench-rustc-main".to_string(), + test_step: "test-crate-rustc-main".to_string(), + bench_step: "bench-crate-rustc-main".to_string(), }); return build }