Skip to content

Commit

Permalink
Allow changing rustdoc which builds the book.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jul 27, 2017
1 parent 4e5333c commit 3b90551
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Mode;
use build_helper::up_to_date;

use util::{cp_r, symlink_dir};
use builder::{Builder, RunConfig, ShouldRun, Step};
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
use tool::Tool;
use compile;
use cache::{INTERNER, Interned};
Expand Down Expand Up @@ -176,6 +176,7 @@ impl Step for RustbookSrc {

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct TheBook {
compiler: Compiler,
target: Interned<String>,
name: &'static str,
}
Expand All @@ -191,6 +192,7 @@ impl Step for TheBook {

fn make_run(run: RunConfig) {
run.builder.ensure(TheBook {
compiler: run.builder.compiler(run.builder.top_stage, run.host),
target: run.target,
name: "book",
});
Expand Down Expand Up @@ -223,7 +225,7 @@ impl Step for TheBook {
// build the index page
let index = format!("{}/index.md", name);
println!("Documenting book index ({})", target);
invoke_rustdoc(builder, target, &index);
invoke_rustdoc(builder, self.compiler, target, &index);

// build the redirect pages
println!("Documenting book redirect pages ({})", target);
Expand All @@ -232,12 +234,12 @@ impl Step for TheBook {
let path = file.path();
let path = path.to_str().unwrap();

invoke_rustdoc(builder, target, path);
invoke_rustdoc(builder, self.compiler, target, path);
}
}
}

fn invoke_rustdoc(builder: &Builder, target: Interned<String>, markdown: &str) {
fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned<String>, markdown: &str) {
let build = builder.build;
let out = build.doc_out(target);

Expand All @@ -258,7 +260,7 @@ fn invoke_rustdoc(builder: &Builder, target: Interned<String>, markdown: &str) {
t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
}

let mut cmd = builder.rustdoc_cmd(builder.compiler(0, build.build));
let mut cmd = builder.rustdoc_cmd(compiler);

let out = out.join("book");

Expand All @@ -279,6 +281,7 @@ fn invoke_rustdoc(builder: &Builder, target: Interned<String>, markdown: &str) {

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Standalone {
compiler: Compiler,
target: Interned<String>,
}

Expand All @@ -293,6 +296,7 @@ impl Step for Standalone {

fn make_run(run: RunConfig) {
run.builder.ensure(Standalone {
compiler: run.builder.compiler(run.builder.top_stage, run.host),
target: run.target,
});
}
Expand All @@ -308,12 +312,11 @@ impl Step for Standalone {
fn run(self, builder: &Builder) {
let build = builder.build;
let target = self.target;
let compiler = self.compiler;
println!("Documenting standalone ({})", target);
let out = build.doc_out(target);
t!(fs::create_dir_all(&out));

let compiler = builder.compiler(0, build.build);

let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc");
let full_toc = build.src.join("src/doc/full-toc.inc");
Expand Down Expand Up @@ -405,6 +408,7 @@ impl Step for Std {
let out = build.doc_out(target);
t!(fs::create_dir_all(&out));
let compiler = builder.compiler(stage, build.build);
let rustdoc = builder.rustdoc(compiler);
let compiler = if build.force_use_stage1(compiler, target) {
builder.compiler(1, compiler.host)
} else {
Expand All @@ -414,7 +418,6 @@ impl Step for Std {
builder.ensure(compile::Std { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Libstd)
.join(target).join("doc");
let rustdoc = builder.rustdoc(compiler);

// Here what we're doing is creating a *symlink* (directory junction on
// Windows) to the final output location. This is not done as an
Expand Down Expand Up @@ -490,6 +493,7 @@ impl Step for Test {
let out = build.doc_out(target);
t!(fs::create_dir_all(&out));
let compiler = builder.compiler(stage, build.build);
let rustdoc = builder.rustdoc(compiler);
let compiler = if build.force_use_stage1(compiler, target) {
builder.compiler(1, compiler.host)
} else {
Expand All @@ -502,7 +506,6 @@ impl Step for Test {
builder.ensure(compile::Test { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Libtest)
.join(target).join("doc");
let rustdoc = builder.rustdoc(compiler);

// See docs in std above for why we symlink
let my_out = build.crate_doc_out(target);
Expand Down Expand Up @@ -551,6 +554,7 @@ impl Step for Rustc {
let out = build.doc_out(target);
t!(fs::create_dir_all(&out));
let compiler = builder.compiler(stage, build.build);
let rustdoc = builder.rustdoc(compiler);
let compiler = if build.force_use_stage1(compiler, target) {
builder.compiler(1, compiler.host)
} else {
Expand All @@ -563,7 +567,6 @@ impl Step for Rustc {
builder.ensure(compile::Rustc { compiler, target });
let out_dir = build.stage_out(compiler, Mode::Librustc)
.join(target).join("doc");
let rustdoc = builder.rustdoc(compiler);

// See docs in std above for why we symlink
let my_out = build.crate_doc_out(target);
Expand Down

0 comments on commit 3b90551

Please sign in to comment.