about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-11-28 18:10:44 -0500
committerJoshua Nelson <github@jyn.dev>2022-12-22 14:33:22 -0600
commitf94c926aecf226a12ffc5c7f09156390dde545ca (patch)
tree476cc5cbbc7f4a0b3af58dbe392451595262397b /src/bootstrap
parente5e4eef02d443eae5089a330e59a69a4f350db81 (diff)
downloadrust-f94c926aecf226a12ffc5c7f09156390dde545ca.tar.gz
rust-f94c926aecf226a12ffc5c7f09156390dde545ca.zip
Support documenting Cargo
The primary motivation is to have the cargo docs show up on https://doc.rust-lang.org/nightly/nightly-rustc/cargo, but as a nice side effect this makes `x doc cargo` work locally.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs1
-rw-r--r--src/bootstrap/doc.rs63
-rw-r--r--src/bootstrap/lib.rs1
3 files changed, 54 insertions, 11 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index b9d06a77966..eb03a45583e 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -702,6 +702,7 @@ impl<'a> Builder<'a> {
                 doc::RustdocBook,
                 doc::RustByExample,
                 doc::RustcBook,
+                doc::Cargo,
                 doc::CargoBook,
                 doc::Clippy,
                 doc::ClippyBook,
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 2c6fd1e1d4d..5838049aa5c 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -729,7 +729,7 @@ impl Step for Rustc {
 }
 
 macro_rules! tool_doc {
-    ($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => {
+    ($tool: ident, $should_run: literal, $path: literal, $(rustc_tool = $rustc_tool:literal, )? $(in_tree = $in_tree:literal, )? [$($krate: literal),+ $(,)?] $(,)?) => {
         #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
         pub struct $tool {
             target: TargetSelection,
@@ -763,13 +763,24 @@ macro_rules! tool_doc {
                 let out = builder.compiler_doc_out(target);
                 t!(fs::create_dir_all(&out));
 
-                // Build rustc docs so that we generate relative links.
-                builder.ensure(Rustc { stage, target });
-                // Rustdoc needs the rustc sysroot available to build.
-                // FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
-                // with strange errors, but only on a full bors test ...
                 let compiler = builder.compiler(stage, builder.config.build);
-                builder.ensure(compile::Rustc::new(compiler, target));
+                builder.ensure(compile::Std::new(compiler, target));
+
+                if true $(&& $rustc_tool)? {
+                    // Build rustc docs so that we generate relative links.
+                    builder.ensure(Rustc { stage, target });
+
+                    // Rustdoc needs the rustc sysroot available to build.
+                    // FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
+                    // with strange errors, but only on a full bors test ...
+                    builder.ensure(compile::Rustc::new(compiler, target));
+                }
+
+                let source_type = if true $(&& $in_tree)? {
+                    SourceType::InTree
+                } else {
+                    SourceType::Submodule
+                };
 
                 builder.info(
                     &format!(
@@ -781,9 +792,15 @@ macro_rules! tool_doc {
                 );
 
                 // Symlink compiler docs to the output directory of rustdoc documentation.
-                let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc");
-                t!(fs::create_dir_all(&out_dir));
-                t!(symlink_dir_force(&builder.config, &out, &out_dir));
+                let out_dirs = [
+                    builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc"),
+                    // Cargo uses a different directory for proc macros.
+                    builder.stage_out(compiler, Mode::ToolRustc).join("doc"),
+                ];
+                for out_dir in out_dirs {
+                    t!(fs::create_dir_all(&out_dir));
+                    t!(symlink_dir_force(&builder.config, &out, &out_dir));
+                }
 
                 // Build cargo command.
                 let mut cargo = prepare_tool_cargo(
@@ -793,7 +810,7 @@ macro_rules! tool_doc {
                     target,
                     "doc",
                     $path,
-                    SourceType::InTree,
+                    source_type,
                     &[],
                 );
 
@@ -824,6 +841,30 @@ tool_doc!(
 );
 tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
 tool_doc!(Miri, "miri", "src/tools/miri", ["miri"]);
+tool_doc!(
+    Cargo,
+    "cargo",
+    "src/tools/cargo",
+    rustc_tool = false,
+    in_tree = false,
+    [
+        "cargo",
+        "cargo-platform",
+        "cargo-util",
+        "crates-io",
+        "cargo-test-macro",
+        "cargo-test-support",
+        "cargo-credential",
+        "cargo-credential-1password",
+        "mdman",
+        // FIXME: this trips a license check in tidy.
+        // "resolver-tests",
+        // FIXME: we should probably document these, but they're different per-platform so we can't use `tool_doc`.
+        // "cargo-credential-gnome-secret",
+        // "cargo-credential-macos-keychain",
+        // "cargo-credential-wincred",
+    ]
+);
 
 #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
 pub struct ErrorIndex {
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 47fb4a38d05..35a58e11df9 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -202,6 +202,7 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
     (None, "bootstrap", None),
     (Some(Mode::Rustc), "parallel_compiler", None),
     (Some(Mode::ToolRustc), "parallel_compiler", None),
+    (Some(Mode::ToolRustc), "emulate_second_only_system", None),
     (Some(Mode::Codegen), "parallel_compiler", None),
     (Some(Mode::Std), "stdarch_intel_sde", None),
     (Some(Mode::Std), "no_fp_fmt_parse", None),