From df8551b60aa2b3442ccda21ac5a8bcabd2a7d67c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 23 Oct 2024 10:52:12 -0700 Subject: [PATCH] Update rustbook to support new test linking in reference --- src/bootstrap/src/core/build_steps/doc.rs | 9 ++++++++- src/tools/rustbook/src/main.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index ca2b8742647..69ec832a44a 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -170,7 +170,14 @@ fn run(self, builder: &Builder<'_>) { builder.add_rustc_lib_path(compiler, &mut rustbook_cmd); } - rustbook_cmd.arg("build").arg(&src).arg("-d").arg(&out).run(builder); + rustbook_cmd + .arg("build") + .arg(&src) + .arg("-d") + .arg(&out) + .arg("--rust-root") + .arg(&builder.src) + .run(builder); for lang in &self.languages { let out = out.join(lang); diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 2118af61396..f905b9277ff 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -22,6 +22,11 @@ fn main() { .required(false) .value_parser(clap::value_parser!(String)); + let root_arg = arg!(--"rust-root" +"Path to the root of the rust source tree") + .required(false) + .value_parser(clap::value_parser!(PathBuf)); + let dir_arg = arg!([dir] "Root directory for the book\n\ (Defaults to the current directory when omitted)") .value_parser(clap::value_parser!(PathBuf)); @@ -37,6 +42,7 @@ fn main() { .about("Build the book from the markdown files") .arg(d_arg) .arg(l_arg) + .arg(root_arg) .arg(&dir_arg), ) .subcommand( @@ -96,7 +102,8 @@ pub fn build(args: &ArgMatches) -> Result3<()> { } if book.config.get_preprocessor("spec").is_some() { - book.with_preprocessor(Spec::new()); + let rust_root = args.get_one::("rust-root").cloned(); + book.with_preprocessor(Spec::new(rust_root)?); } book.build()?;