rustbuild: Fixup calling rustdoc in various stages

The stage0 rustdoc comes from the snapshot, and we need a shim like with `rustc`
to pass `--cfg` for now.
This commit is contained in:
Alex Crichton 2016-03-07 23:11:05 -08:00
parent 0788cd23ea
commit f7b7535fd7
6 changed files with 76 additions and 11 deletions

View file

@ -325,4 +325,3 @@ pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) {
.arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool)));
build.run(&mut cargo);
}

View file

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::path::Path;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::Path;
use std::process::Command;
use build::{Build, Compiler, Mode};
use build::util::{up_to_date, cp_r};
@ -69,7 +70,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
}
let html = out.join(filename).with_extension("html");
let rustdoc = build.tool(&compiler, "rustdoc");
let rustdoc = build.rustdoc(&compiler);
if up_to_date(&path, &html) &&
up_to_date(&footer, &html) &&
up_to_date(&favicon, &html) &&
@ -79,7 +80,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
continue
}
let mut cmd = build.tool_cmd(&compiler, "rustdoc");
let mut cmd = Command::new(&rustdoc);
cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon)
@ -108,10 +109,9 @@ pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
let compiler = Compiler::new(stage, host);
let out_dir = build.stage_out(stage, host, Mode::Libstd)
.join(host).join("doc");
let rustdoc = build.tool(&compiler, "rustdoc");
if !up_to_date(&rustdoc, &out_dir.join("std/index.html")) {
t!(fs::remove_dir_all(&out_dir));
}
let rustdoc = build.rustdoc(&compiler);
build.clear_if_dirty(&out_dir, &rustdoc);
let mut cargo = build.cargo(stage, &compiler, Mode::Libstd, Some(host),
"doc");
@ -127,7 +127,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
let compiler = Compiler::new(stage, host);
let out_dir = build.stage_out(stage, host, Mode::Librustc)
.join(host).join("doc");
let rustdoc = build.tool(&compiler, "rustdoc");
let rustdoc = build.rustdoc(&compiler);
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
t!(fs::remove_dir_all(&out_dir));
}

View file

@ -275,7 +275,8 @@ impl Build {
.env("RUSTC_SYSROOT", self.sysroot(stage, host))
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir())
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
.env("RUSTDOC", self.tool(compiler, "rustdoc"));
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
.env("RUSTDOC_REAL", self.rustdoc(compiler));
if let Some(target) = target {
cargo.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
@ -317,13 +318,26 @@ impl Build {
}
}
/// Get the specified tool next to the specified compiler
/// Get the specified tool built by the specified compiler
fn tool(&self, compiler: &Compiler, tool: &str) -> PathBuf {
self.stage_out(compiler.stage, compiler.host, Mode::Tool)
.join(self.cargo_dir())
.join(exe(tool, compiler.host))
}
/// Get the `rustdoc` executable next to the specified compiler
fn rustdoc(&self, compiler: &Compiler) -> PathBuf {
let root = if compiler.is_snapshot(self) {
let mut rustdoc = self.rustc.clone();
rustdoc.pop();
rustdoc
} else {
let (stage, host) = (compiler.stage, compiler.host);
self.cargo_out(stage - 1, host, Mode::Librustc, host)
};
root.join(exe("rustdoc", compiler.host))
}
/// Get a `Command` which is ready to run `tool` in `stage` built for
/// `host`.
#[allow(dead_code)] // this will be used soon