refactor tool_doc! so that it can accept additional arguments.

Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
ozkanonur 2023-06-03 10:25:44 +03:00
parent dff88b2064
commit cde54ffc99

View File

@ -746,7 +746,15 @@ impl Step for Rustc {
} }
macro_rules! tool_doc { macro_rules! tool_doc {
($tool: ident, $should_run: literal, $path: literal, $(rustc_tool = $rustc_tool:literal, )? $(in_tree = $in_tree:literal, )? [$($krate: literal),+ $(,)?] $(,)?) => { (
$tool: ident,
$should_run: literal,
$path: literal,
$(rustc_tool = $rustc_tool:literal, )?
$(in_tree = $in_tree:literal, )?
[$($extra_arg: literal),+ $(,)?]
$(,)?
) => {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $tool { pub struct $tool {
target: TargetSelection, target: TargetSelection,
@ -834,9 +842,9 @@ macro_rules! tool_doc {
cargo.arg("-Zskip-rustdoc-fingerprint"); cargo.arg("-Zskip-rustdoc-fingerprint");
// Only include compiler crates, no dependencies of those, such as `libc`. // Only include compiler crates, no dependencies of those, such as `libc`.
cargo.arg("--no-deps"); cargo.arg("--no-deps");
cargo.arg("--lib");
$( $(
cargo.arg("-p").arg($krate); cargo.arg($extra_arg);
)+ )+
cargo.rustdocflag("--document-private-items"); cargo.rustdocflag("--document-private-items");
@ -852,15 +860,20 @@ macro_rules! tool_doc {
} }
} }
tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"],); tool_doc!(
Rustdoc,
"rustdoc-tool",
"src/tools/rustdoc",
["-p", "rustdoc", "-p", "rustdoc-json-types"]
);
tool_doc!( tool_doc!(
Rustfmt, Rustfmt,
"rustfmt-nightly", "rustfmt-nightly",
"src/tools/rustfmt", "src/tools/rustfmt",
["rustfmt-nightly", "rustfmt-config_proc_macro"], ["-p", "rustfmt-nightly", "-p", "rustfmt-config_proc_macro"],
); );
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]); tool_doc!(Clippy, "clippy", "src/tools/clippy", ["-p", "clippy_utils"]);
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"]); tool_doc!(Miri, "miri", "src/tools/miri", ["-p", "miri"]);
tool_doc!( tool_doc!(
Cargo, Cargo,
"cargo", "cargo",
@ -868,25 +881,44 @@ tool_doc!(
rustc_tool = false, rustc_tool = false,
in_tree = false, in_tree = false,
[ [
"-p",
"cargo", "cargo",
"-p",
"cargo-platform", "cargo-platform",
"-p",
"cargo-util", "cargo-util",
"-p",
"crates-io", "crates-io",
"-p",
"cargo-test-macro", "cargo-test-macro",
"-p",
"cargo-test-support", "cargo-test-support",
"-p",
"cargo-credential", "cargo-credential",
"-p",
"cargo-credential-1password", "cargo-credential-1password",
"-p",
"mdman", "mdman",
// FIXME: this trips a license check in tidy. // FIXME: this trips a license check in tidy.
// "-p",
// "resolver-tests", // "resolver-tests",
// FIXME: we should probably document these, but they're different per-platform so we can't use `tool_doc`. // FIXME: we should probably document these, but they're different per-platform so we can't use `tool_doc`.
// "-p",
// "cargo-credential-gnome-secret", // "cargo-credential-gnome-secret",
// "-p",
// "cargo-credential-macos-keychain", // "cargo-credential-macos-keychain",
// "-p",
// "cargo-credential-wincred", // "cargo-credential-wincred",
] ]
); );
tool_doc!(Tidy, "tidy", "src/tools/tidy", rustc_tool = false, ["tidy"]); tool_doc!(Tidy, "tidy", "src/tools/tidy", rustc_tool = false, ["-p", "tidy"]);
tool_doc!(Bootstrap, "bootstrap", "src/bootstrap", rustc_tool = false, ["bootstrap"]); tool_doc!(
Bootstrap,
"bootstrap",
"src/bootstrap",
rustc_tool = false,
["--lib", "-p", "bootstrap"]
);
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorIndex { pub struct ErrorIndex {