Build rustdoc on-demand.
Rustdoc is no longer compiled in every stage, alongside rustc, instead it is only compiled when requested, and generally only for the last stage.
This commit is contained in:
parent
fe0eca0d3f
commit
e2e9b40e9a
14 changed files with 106 additions and 67 deletions
25
src/Cargo.lock
generated
25
src/Cargo.lock
generated
|
@ -439,6 +439,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "error_index_generator"
|
name = "error_index_generator"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"rustdoc 0.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
|
@ -1222,7 +1225,6 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc_back 0.0.0",
|
"rustc_back 0.0.0",
|
||||||
"rustc_driver 0.0.0",
|
"rustc_driver 0.0.0",
|
||||||
"rustdoc 0.0.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1560,25 +1562,18 @@ dependencies = [
|
||||||
name = "rustdoc"
|
name = "rustdoc"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arena 0.0.0",
|
|
||||||
"build_helper 0.1.0",
|
"build_helper 0.1.0",
|
||||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc 0.0.0",
|
]
|
||||||
"rustc_back 0.0.0",
|
|
||||||
"rustc_data_structures 0.0.0",
|
[[package]]
|
||||||
"rustc_driver 0.0.0",
|
name = "rustdoc-tool"
|
||||||
"rustc_errors 0.0.0",
|
version = "0.0.0"
|
||||||
"rustc_lint 0.0.0",
|
dependencies = [
|
||||||
"rustc_metadata 0.0.0",
|
"rustdoc 0.0.0",
|
||||||
"rustc_resolve 0.0.0",
|
|
||||||
"rustc_trans 0.0.0",
|
|
||||||
"rustc_typeck 0.0.0",
|
|
||||||
"serialize 0.0.0",
|
|
||||||
"syntax 0.0.0",
|
|
||||||
"syntax_pos 0.0.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -16,6 +16,7 @@ members = [
|
||||||
"tools/remote-test-server",
|
"tools/remote-test-server",
|
||||||
"tools/rust-installer",
|
"tools/rust-installer",
|
||||||
"tools/cargo",
|
"tools/cargo",
|
||||||
|
"tools/rustdoc",
|
||||||
"tools/rls",
|
"tools/rls",
|
||||||
# FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude
|
# FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude
|
||||||
"tools/rls/test_data/borrow_error",
|
"tools/rls/test_data/borrow_error",
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl<'a> Builder<'a> {
|
||||||
compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
|
compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
|
||||||
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
|
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
|
||||||
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
|
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
|
||||||
tool::RustInstaller, tool::Cargo, tool::Rls),
|
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc),
|
||||||
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
|
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
|
||||||
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,
|
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,
|
||||||
check::Cargotest, check::Cargo, check::Rls, check::Docs, check::ErrorIndex,
|
check::Cargotest, check::Cargo, check::Rls, check::Docs, check::ErrorIndex,
|
||||||
|
@ -412,12 +412,22 @@ impl<'a> Builder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `rustdoc` executable next to the specified compiler
|
|
||||||
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
|
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
|
||||||
let mut rustdoc = self.rustc(compiler);
|
self.ensure(tool::Rustdoc { target_compiler: compiler })
|
||||||
rustdoc.pop();
|
}
|
||||||
rustdoc.push(exe("rustdoc", &compiler.host));
|
|
||||||
rustdoc
|
pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command {
|
||||||
|
let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc"));
|
||||||
|
cmd
|
||||||
|
.env("RUSTC_STAGE", compiler.stage.to_string())
|
||||||
|
.env("RUSTC_SYSROOT", if compiler.is_snapshot(&self.build) {
|
||||||
|
INTERNER.intern_path(self.build.rustc_snapshot_libdir())
|
||||||
|
} else {
|
||||||
|
self.sysroot(compiler)
|
||||||
|
})
|
||||||
|
.env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
|
||||||
|
.env("RUSTDOC_REAL", self.rustdoc(compiler));
|
||||||
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepares an invocation of `cargo` to be run.
|
/// Prepares an invocation of `cargo` to be run.
|
||||||
|
@ -469,7 +479,11 @@ impl<'a> Builder<'a> {
|
||||||
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
|
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
|
||||||
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
|
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
|
||||||
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
|
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
|
||||||
.env("RUSTDOC_REAL", self.rustdoc(compiler))
|
.env("RUSTDOC_REAL", if cmd == "doc" || cmd == "test" {
|
||||||
|
self.rustdoc(compiler)
|
||||||
|
} else {
|
||||||
|
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
|
||||||
|
})
|
||||||
.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
|
.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
|
||||||
|
|
||||||
if mode != Mode::Tool {
|
if mode != Mode::Tool {
|
||||||
|
|
|
@ -809,8 +809,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("doc tests for: {}", markdown.display());
|
println!("doc tests for: {}", markdown.display());
|
||||||
let mut cmd = Command::new(builder.rustdoc(compiler));
|
let mut cmd = builder.rustdoc_cmd(compiler);
|
||||||
builder.add_rustc_lib_path(compiler, &mut cmd);
|
|
||||||
build.add_rust_test_threads(&mut cmd);
|
build.add_rust_test_threads(&mut cmd);
|
||||||
cmd.arg("--test");
|
cmd.arg("--test");
|
||||||
cmd.arg(markdown);
|
cmd.arg(markdown);
|
||||||
|
|
|
@ -719,15 +719,6 @@ impl Step for Assemble {
|
||||||
let _ = fs::remove_file(&compiler);
|
let _ = fs::remove_file(&compiler);
|
||||||
copy(&rustc, &compiler);
|
copy(&rustc, &compiler);
|
||||||
|
|
||||||
// See if rustdoc exists to link it into place
|
|
||||||
let rustdoc = exe("rustdoc", &*host);
|
|
||||||
let rustdoc_src = out_dir.join(&rustdoc);
|
|
||||||
let rustdoc_dst = bindir.join(&rustdoc);
|
|
||||||
if fs::metadata(&rustdoc_src).is_ok() {
|
|
||||||
let _ = fs::remove_file(&rustdoc_dst);
|
|
||||||
copy(&rustdoc_src, &rustdoc_dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
target_compiler
|
target_compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,6 +413,9 @@ impl Step for Rustc {
|
||||||
t!(fs::create_dir_all(image.join("bin")));
|
t!(fs::create_dir_all(image.join("bin")));
|
||||||
cp_r(&src.join("bin"), &image.join("bin"));
|
cp_r(&src.join("bin"), &image.join("bin"));
|
||||||
|
|
||||||
|
install(&builder.ensure(tool::Rustdoc { target_compiler: compiler }),
|
||||||
|
&image.join("bin"), 0o755);
|
||||||
|
|
||||||
// Copy runtime DLLs needed by the compiler
|
// Copy runtime DLLs needed by the compiler
|
||||||
if libdir != "bin" {
|
if libdir != "bin" {
|
||||||
for entry in t!(src.join(libdir).read_dir()).map(|e| t!(e)) {
|
for entry in t!(src.join(libdir).read_dir()).map(|e| t!(e)) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ use std::fs::{self, File};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{PathBuf, Path};
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use Mode;
|
use Mode;
|
||||||
use build_helper::up_to_date;
|
use build_helper::up_to_date;
|
||||||
|
@ -242,12 +241,8 @@ fn invoke_rustdoc(builder: &Builder, target: Interned<String>, markdown: &str) {
|
||||||
let build = builder.build;
|
let build = builder.build;
|
||||||
let out = build.doc_out(target);
|
let out = build.doc_out(target);
|
||||||
|
|
||||||
let compiler = builder.compiler(0, build.build);
|
|
||||||
|
|
||||||
let path = build.src.join("src/doc").join(markdown);
|
let path = build.src.join("src/doc").join(markdown);
|
||||||
|
|
||||||
let rustdoc = builder.rustdoc(compiler);
|
|
||||||
|
|
||||||
let favicon = build.src.join("src/doc/favicon.inc");
|
let favicon = build.src.join("src/doc/favicon.inc");
|
||||||
let footer = build.src.join("src/doc/footer.inc");
|
let footer = build.src.join("src/doc/footer.inc");
|
||||||
|
|
||||||
|
@ -263,9 +258,7 @@ fn invoke_rustdoc(builder: &Builder, target: Interned<String>, markdown: &str) {
|
||||||
t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
|
t!(t!(File::create(&version_info)).write_all(info.as_bytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut cmd = Command::new(&rustdoc);
|
let mut cmd = builder.rustdoc_cmd(builder.compiler(0, build.build));
|
||||||
|
|
||||||
builder.add_rustc_lib_path(compiler, &mut cmd);
|
|
||||||
|
|
||||||
let out = out.join("book");
|
let out = out.join("book");
|
||||||
|
|
||||||
|
@ -357,8 +350,7 @@ impl Step for Standalone {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut cmd = Command::new(&rustdoc);
|
let mut cmd = builder.rustdoc_cmd(compiler);
|
||||||
builder.add_rustc_lib_path(compiler, &mut cmd);
|
|
||||||
cmd.arg("--html-after-content").arg(&footer)
|
cmd.arg("--html-after-content").arg(&footer)
|
||||||
.arg("--html-before-content").arg(&version_info)
|
.arg("--html-before-content").arg(&version_info)
|
||||||
.arg("--html-in-header").arg(&favicon)
|
.arg("--html-in-header").arg(&favicon)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
use std::fs;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
@ -15,7 +16,7 @@ use std::process::Command;
|
||||||
use Mode;
|
use Mode;
|
||||||
use Compiler;
|
use Compiler;
|
||||||
use builder::{Step, RunConfig, ShouldRun, Builder};
|
use builder::{Step, RunConfig, ShouldRun, Builder};
|
||||||
use util::{exe, add_lib_path};
|
use util::{copy, exe, add_lib_path};
|
||||||
use compile::{self, libtest_stamp, libstd_stamp, librustc_stamp};
|
use compile::{self, libtest_stamp, libstd_stamp, librustc_stamp};
|
||||||
use native;
|
use native;
|
||||||
use channel::GitInfo;
|
use channel::GitInfo;
|
||||||
|
@ -223,6 +224,56 @@ impl Step for RemoteTestServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
|
pub struct Rustdoc {
|
||||||
|
pub target_compiler: Compiler,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Step for Rustdoc {
|
||||||
|
type Output = PathBuf;
|
||||||
|
const DEFAULT: bool = true;
|
||||||
|
const ONLY_HOSTS: bool = true;
|
||||||
|
|
||||||
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
||||||
|
run.path("src/tools/rustdoc")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_run(run: RunConfig) {
|
||||||
|
run.builder.ensure(Rustdoc {
|
||||||
|
target_compiler: run.builder.compiler(run.builder.top_stage, run.host),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(self, builder: &Builder) -> PathBuf {
|
||||||
|
let target_compiler = self.target_compiler;
|
||||||
|
let build_compiler = if target_compiler.stage == 0 {
|
||||||
|
target_compiler
|
||||||
|
} else {
|
||||||
|
builder.compiler(target_compiler.stage - 1, target_compiler.host)
|
||||||
|
};
|
||||||
|
|
||||||
|
let tool_rustdoc = builder.ensure(ToolBuild {
|
||||||
|
compiler: build_compiler,
|
||||||
|
target: build_compiler.host,
|
||||||
|
tool: "rustdoc",
|
||||||
|
mode: Mode::Librustc,
|
||||||
|
});
|
||||||
|
|
||||||
|
// don't create a stage0-sysroot/bin directory.
|
||||||
|
if target_compiler.stage > 0 {
|
||||||
|
let sysroot = builder.sysroot(target_compiler);
|
||||||
|
let bindir = sysroot.join("bin");
|
||||||
|
t!(fs::create_dir_all(&bindir));
|
||||||
|
let bin_rustdoc = bindir.join(exe("rustdoc", &*target_compiler.host));
|
||||||
|
let _ = fs::remove_file(&bin_rustdoc);
|
||||||
|
copy(&tool_rustdoc, &bin_rustdoc);
|
||||||
|
bin_rustdoc
|
||||||
|
} else {
|
||||||
|
tool_rustdoc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct Cargo {
|
pub struct Cargo {
|
||||||
pub compiler: Compiler,
|
pub compiler: Compiler,
|
||||||
|
|
|
@ -7,25 +7,10 @@ build = "build.rs"
|
||||||
[lib]
|
[lib]
|
||||||
name = "rustdoc"
|
name = "rustdoc"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
crate-type = ["dylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arena = { path = "../libarena" }
|
|
||||||
env_logger = { version = "0.4", default-features = false }
|
env_logger = { version = "0.4", default-features = false }
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
rustc = { path = "../librustc" }
|
|
||||||
rustc_back = { path = "../librustc_back" }
|
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
|
||||||
rustc_driver = { path = "../librustc_driver" }
|
|
||||||
rustc_errors = { path = "../librustc_errors" }
|
|
||||||
rustc_lint = { path = "../librustc_lint" }
|
|
||||||
rustc_metadata = { path = "../librustc_metadata" }
|
|
||||||
rustc_resolve = { path = "../librustc_resolve" }
|
|
||||||
rustc_typeck = { path = "../librustc_typeck" }
|
|
||||||
rustc_trans = { path = "../librustc_trans" }
|
|
||||||
serialize = { path = "../libserialize" }
|
|
||||||
syntax = { path = "../libsyntax" }
|
|
||||||
syntax_pos = { path = "../libsyntax_pos" }
|
|
||||||
pulldown-cmark = { version = "0.0.14", default-features = false }
|
pulldown-cmark = { version = "0.0.14", default-features = false }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
html_playground_url = "https://play.rust-lang.org/")]
|
html_playground_url = "https://play.rust-lang.org/")]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
|
#![feature(rustc_private)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
|
|
|
@ -7,16 +7,11 @@ version = "0.0.0"
|
||||||
name = "rustc"
|
name = "rustc"
|
||||||
path = "rustc.rs"
|
path = "rustc.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "rustdoc"
|
|
||||||
path = "rustdoc.rs"
|
|
||||||
|
|
||||||
# All optional dependencies so the features passed to this Cargo.toml select
|
# All optional dependencies so the features passed to this Cargo.toml select
|
||||||
# what should actually be built.
|
# what should actually be built.
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc_back = { path = "../librustc_back" }
|
rustc_back = { path = "../librustc_back" }
|
||||||
rustc_driver = { path = "../librustc_driver" }
|
rustc_driver = { path = "../librustc_driver" }
|
||||||
rustdoc = { path = "../librustdoc" }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
jemalloc = ["rustc_back/jemalloc"]
|
jemalloc = ["rustc_back/jemalloc"]
|
||||||
|
|
|
@ -3,6 +3,9 @@ authors = ["The Rust Project Developers"]
|
||||||
name = "error_index_generator"
|
name = "error_index_generator"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rustdoc = { path = "../../librustdoc" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "error_index_generator"
|
name = "error_index_generator"
|
||||||
path = "main.rs"
|
path = "main.rs"
|
||||||
|
|
11
src/tools/rustdoc/Cargo.toml
Normal file
11
src/tools/rustdoc/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "rustdoc-tool"
|
||||||
|
version = "0.0.0"
|
||||||
|
authors = ["The Rust Project Developers"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "rustdoc"
|
||||||
|
path = "main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rustdoc = { path = "../../librustdoc" }
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
|
@ -8,8 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate rustdoc;
|
extern crate rustdoc;
|
||||||
|
|
||||||
fn main() { rustdoc::main() }
|
fn main() { rustdoc::main() }
|
Loading…
Add table
Add a link
Reference in a new issue