Update rustbook to support new test linking in reference

This commit is contained in:
Eric Huss 2024-10-23 10:52:12 -07:00
parent 87fb4eaa9d
commit df8551b60a
2 changed files with 16 additions and 2 deletions

View File

@ -170,7 +170,14 @@ fn run(self, builder: &Builder<'_>) {
builder.add_rustc_lib_path(compiler, &mut rustbook_cmd); 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 { for lang in &self.languages {
let out = out.join(lang); let out = out.join(lang);

View File

@ -22,6 +22,11 @@ fn main() {
.required(false) .required(false)
.value_parser(clap::value_parser!(String)); .value_parser(clap::value_parser!(String));
let root_arg = arg!(--"rust-root" <ROOT_DIR>
"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\ let dir_arg = arg!([dir] "Root directory for the book\n\
(Defaults to the current directory when omitted)") (Defaults to the current directory when omitted)")
.value_parser(clap::value_parser!(PathBuf)); .value_parser(clap::value_parser!(PathBuf));
@ -37,6 +42,7 @@ fn main() {
.about("Build the book from the markdown files") .about("Build the book from the markdown files")
.arg(d_arg) .arg(d_arg)
.arg(l_arg) .arg(l_arg)
.arg(root_arg)
.arg(&dir_arg), .arg(&dir_arg),
) )
.subcommand( .subcommand(
@ -96,7 +102,8 @@ pub fn build(args: &ArgMatches) -> Result3<()> {
} }
if book.config.get_preprocessor("spec").is_some() { if book.config.get_preprocessor("spec").is_some() {
book.with_preprocessor(Spec::new()); let rust_root = args.get_one::<PathBuf>("rust-root").cloned();
book.with_preprocessor(Spec::new(rust_root)?);
} }
book.build()?; book.build()?;