rustbuild: Cleanup book generation
The Cargo book can be generated the same way as the other books.
This commit is contained in:
parent
56446fef49
commit
870ca31408
@ -49,7 +49,7 @@ macro_rules! book {
|
|||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target: self.target,
|
target: self.target,
|
||||||
name: INTERNER.intern_str($book_name),
|
name: INTERNER.intern_str($book_name),
|
||||||
src: doc_src(builder),
|
src: INTERNER.intern_path(builder.src.join($path)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,6 +60,7 @@ macro_rules! book {
|
|||||||
// NOTE: When adding a book here, make sure to ALSO build the book by
|
// NOTE: When adding a book here, make sure to ALSO build the book by
|
||||||
// adding a build step in `src/bootstrap/builder.rs`!
|
// adding a build step in `src/bootstrap/builder.rs`!
|
||||||
book!(
|
book!(
|
||||||
|
CargoBook, "src/tools/cargo/src/doc", "cargo";
|
||||||
EditionGuide, "src/doc/edition-guide", "edition-guide";
|
EditionGuide, "src/doc/edition-guide", "edition-guide";
|
||||||
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
|
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
|
||||||
Nomicon, "src/doc/nomicon", "nomicon";
|
Nomicon, "src/doc/nomicon", "nomicon";
|
||||||
@ -69,10 +70,6 @@ book!(
|
|||||||
RustdocBook, "src/doc/rustdoc", "rustdoc";
|
RustdocBook, "src/doc/rustdoc", "rustdoc";
|
||||||
);
|
);
|
||||||
|
|
||||||
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
|
|
||||||
INTERNER.intern_path(builder.src.join("src/doc"))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct UnstableBook {
|
pub struct UnstableBook {
|
||||||
target: Interned<String>,
|
target: Interned<String>,
|
||||||
@ -96,48 +93,11 @@ impl Step for UnstableBook {
|
|||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target: self.target,
|
target: self.target,
|
||||||
name: INTERNER.intern_str("unstable-book"),
|
name: INTERNER.intern_str("unstable-book"),
|
||||||
src: builder.md_doc_out(self.target),
|
src: INTERNER.intern_path(builder.md_doc_out(self.target).join("unstable-book")),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
||||||
pub struct CargoBook {
|
|
||||||
target: Interned<String>,
|
|
||||||
name: Interned<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Step for CargoBook {
|
|
||||||
type Output = ();
|
|
||||||
const DEFAULT: bool = true;
|
|
||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
|
||||||
let builder = run.builder;
|
|
||||||
run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_run(run: RunConfig<'_>) {
|
|
||||||
run.builder.ensure(CargoBook { target: run.target, name: INTERNER.intern_str("cargo") });
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(self, builder: &Builder<'_>) {
|
|
||||||
let target = self.target;
|
|
||||||
let name = self.name;
|
|
||||||
let src = builder.src.join("src/tools/cargo/src/doc");
|
|
||||||
|
|
||||||
let out = builder.doc_out(target);
|
|
||||||
t!(fs::create_dir_all(&out));
|
|
||||||
|
|
||||||
let out = out.join(name);
|
|
||||||
|
|
||||||
builder.info(&format!("Cargo Book ({}) - {}", target, name));
|
|
||||||
|
|
||||||
let _ = fs::remove_dir_all(&out);
|
|
||||||
|
|
||||||
builder.run(builder.tool_cmd(Tool::Rustbook).arg("build").arg(&src).arg("-d").arg(out));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
struct RustbookSrc {
|
struct RustbookSrc {
|
||||||
target: Interned<String>,
|
target: Interned<String>,
|
||||||
@ -164,7 +124,6 @@ impl Step for RustbookSrc {
|
|||||||
t!(fs::create_dir_all(&out));
|
t!(fs::create_dir_all(&out));
|
||||||
|
|
||||||
let out = out.join(name);
|
let out = out.join(name);
|
||||||
let src = src.join(name);
|
|
||||||
let index = out.join("index.html");
|
let index = out.join("index.html");
|
||||||
let rustbook = builder.tool_exe(Tool::Rustbook);
|
let rustbook = builder.tool_exe(Tool::Rustbook);
|
||||||
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
||||||
@ -182,7 +141,6 @@ impl Step for RustbookSrc {
|
|||||||
pub struct TheBook {
|
pub struct TheBook {
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
target: Interned<String>,
|
target: Interned<String>,
|
||||||
name: &'static str,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step for TheBook {
|
impl Step for TheBook {
|
||||||
@ -198,7 +156,6 @@ impl Step for TheBook {
|
|||||||
run.builder.ensure(TheBook {
|
run.builder.ensure(TheBook {
|
||||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
|
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
|
||||||
target: run.target,
|
target: run.target,
|
||||||
name: "book",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,45 +163,30 @@ impl Step for TheBook {
|
|||||||
///
|
///
|
||||||
/// We need to build:
|
/// We need to build:
|
||||||
///
|
///
|
||||||
/// * Book (first edition)
|
/// * Book
|
||||||
/// * Book (second edition)
|
/// * Older edition redirects
|
||||||
/// * Version info and CSS
|
/// * Version info and CSS
|
||||||
/// * Index page
|
/// * Index page
|
||||||
/// * Redirect pages
|
/// * Redirect pages
|
||||||
fn run(self, builder: &Builder<'_>) {
|
fn run(self, builder: &Builder<'_>) {
|
||||||
let compiler = self.compiler;
|
let compiler = self.compiler;
|
||||||
let target = self.target;
|
let target = self.target;
|
||||||
let name = self.name;
|
|
||||||
|
|
||||||
// build book
|
// build book
|
||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target,
|
target,
|
||||||
name: INTERNER.intern_string(name.to_string()),
|
name: INTERNER.intern_str("book"),
|
||||||
src: doc_src(builder),
|
src: INTERNER.intern_path(builder.src.join("src/doc/book")),
|
||||||
});
|
});
|
||||||
|
|
||||||
// building older edition redirects
|
// building older edition redirects
|
||||||
|
for edition in &["first-edition", "second-edition", "2018-edition"] {
|
||||||
let source_name = format!("{}/first-edition", name);
|
|
||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target,
|
target,
|
||||||
name: INTERNER.intern_string(source_name),
|
name: INTERNER.intern_string(format!("book/{}", edition)),
|
||||||
src: doc_src(builder),
|
src: INTERNER.intern_path(builder.src.join("src/doc/book").join(edition)),
|
||||||
});
|
|
||||||
|
|
||||||
let source_name = format!("{}/second-edition", name);
|
|
||||||
builder.ensure(RustbookSrc {
|
|
||||||
target,
|
|
||||||
name: INTERNER.intern_string(source_name),
|
|
||||||
src: doc_src(builder),
|
|
||||||
});
|
|
||||||
|
|
||||||
let source_name = format!("{}/2018-edition", name);
|
|
||||||
builder.ensure(RustbookSrc {
|
|
||||||
target,
|
|
||||||
name: INTERNER.intern_string(source_name),
|
|
||||||
src: doc_src(builder),
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// build the version info page and CSS
|
// build the version info page and CSS
|
||||||
builder.ensure(Standalone { compiler, target });
|
builder.ensure(Standalone { compiler, target });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user