Auto merge of #43482 - Mark-Simulacrum:single-rustdoc, r=alexcrichton

Compile rustdoc on-demand

Fixes #43284, fixes #38318, and fixes #39505.

Doesn't directly help with https://github.com/rust-lang/rust/issues/42686, since we need to rebuild just as much. In fact, this hurts it, since `./x.py doc --stage 0` will now fail. I'm not sure if it did before, but with these changes it runs into the problem where we attempt to use artifacts from bootstrap rustc with a non-bootstrap rustdoc, running into version conflicts. I believe this is solvable, but leaving for a future PR.

This means that rustdoc will no longer be compiled when compiling rustc, by default. However, it is still built from `./x.py build` (for hosts, but not targets, since we don't produce compiler toolchains for them) and will be built for doc tests and crate tests.

After this, the recommended workflow if you want a rustdoc is: `./x.py build --stage 1 src/tools/rustdoc` which will give you a working rustdoc in `build/triple/stage1/bin/rustdoc`. Note that you can add `src/libstd` onto the command to compile libstd as well so that the rustdoc can easily compile crates in the wild. `./x.py doc --stage 1 src/libstd` will document `libstd` with a freshly built rustdoc (if necessary), and will not rebuild rustc on modifications to rustdoc.

r? @alexcrichton
This commit is contained in:
bors 2017-07-27 17:07:58 +00:00
commit 5cc1baa290
18 changed files with 181 additions and 144 deletions

25
src/Cargo.lock generated
View File

@ -439,6 +439,9 @@ dependencies = [
[[package]]
name = "error_index_generator"
version = "0.0.0"
dependencies = [
"rustdoc 0.0.0",
]
[[package]]
name = "filetime"
@ -1222,7 +1225,6 @@ version = "0.0.0"
dependencies = [
"rustc_back 0.0.0",
"rustc_driver 0.0.0",
"rustdoc 0.0.0",
]
[[package]]
@ -1560,25 +1562,18 @@ dependencies = [
name = "rustdoc"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"build_helper 0.1.0",
"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)",
"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)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_driver 0.0.0",
"rustc_errors 0.0.0",
"rustc_lint 0.0.0",
"rustc_metadata 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]]
name = "rustdoc-tool"
version = "0.0.0"
dependencies = [
"rustdoc 0.0.0",
]
[[package]]

View File

@ -16,6 +16,7 @@ members = [
"tools/remote-test-server",
"tools/rust-installer",
"tools/cargo",
"tools/rustdoc",
"tools/rls",
# FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude
"tools/rls/test_data/borrow_error",

View File

@ -256,7 +256,7 @@ macro_rules! describe {
compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
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,
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,
check::Cargotest, check::Cargo, check::Rls, check::Docs, check::ErrorIndex,
@ -412,12 +412,23 @@ pub fn rustc(&self, compiler: Compiler) -> PathBuf {
}
}
/// Get the `rustdoc` executable next to the specified compiler
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
let mut rustdoc = self.rustc(compiler);
rustdoc.pop();
rustdoc.push(exe("rustdoc", &compiler.host));
rustdoc
self.ensure(tool::Rustdoc { target_compiler: compiler })
}
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("CFG_RELEASE_CHANNEL", &self.build.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(compiler));
cmd
}
/// Prepares an invocation of `cargo` to be run.
@ -469,7 +480,11 @@ pub fn cargo(&self,
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
.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(" "));
if mode != Mode::Tool {
@ -560,6 +575,9 @@ pub fn cargo(&self,
// FIXME: should update code to not require this env var
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);
// Set this for all builds to make sure doc builds also get it.
cargo.env("CFG_RELEASE_CHANNEL", &self.build.config.channel);
if self.is_verbose() {
cargo.arg("-v");
}

View File

@ -119,7 +119,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
}
fn make_run(run: RunConfig) {
run.builder.ensure(Linkcheck { host: run.host });
run.builder.ensure(Linkcheck { host: run.target });
}
}
@ -140,7 +140,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(Cargotest {
stage: run.builder.top_stage,
host: run.host,
host: run.target,
});
}
@ -194,7 +194,7 @@ fn run(self, builder: &Builder) {
let build = builder.build;
let compiler = builder.compiler(self.stage, self.host);
builder.ensure(tool::Cargo { stage: self.stage, target: self.host });
builder.ensure(tool::Cargo { compiler, target: self.host });
let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
if !build.fail_fast {
@ -240,7 +240,7 @@ fn run(self, builder: &Builder) {
let host = self.host;
let compiler = builder.compiler(stage, host);
builder.ensure(tool::Rls { stage: self.stage, target: self.host });
builder.ensure(tool::Rls { compiler, target: self.host });
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
@ -562,7 +562,12 @@ fn run(self, builder: &Builder) {
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
// Avoid depending on rustdoc when we don't need it.
if mode == "rustdoc" || mode == "run-make" {
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
}
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
@ -809,8 +814,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) {
}
println!("doc tests for: {}", markdown.display());
let mut cmd = Command::new(builder.rustdoc(compiler));
builder.add_rustc_lib_path(compiler, &mut cmd);
let mut cmd = builder.rustdoc_cmd(compiler);
build.add_rust_test_threads(&mut cmd);
cmd.arg("--test");
cmd.arg(markdown);
@ -1165,7 +1169,7 @@ fn run(self, builder: &Builder) {
println!("REMOTE copy libs to emulator ({})", target);
t!(fs::create_dir_all(build.out.join("tmp")));
let server = builder.ensure(tool::RemoteTestServer { stage: compiler.stage, target });
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
// Spawn the emulator and wait for it to come online
let tool = builder.tool_exe(Tool::RemoteTestClient);

View File

@ -719,15 +719,6 @@ fn run(self, builder: &Builder) -> Compiler {
let _ = fs::remove_file(&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
}
}

View File

@ -413,6 +413,9 @@ fn prepare_image(builder: &Builder, compiler: Compiler, image: &Path) {
t!(fs::create_dir_all(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
if libdir != "bin" {
for entry in t!(src.join(libdir).read_dir()).map(|e| t!(e)) {
@ -963,7 +966,10 @@ fn run(self, builder: &Builder) -> PathBuf {
// Prepare the image directory
t!(fs::create_dir_all(image.join("share/zsh/site-functions")));
t!(fs::create_dir_all(image.join("etc/bash_completion.d")));
let cargo = builder.ensure(tool::Cargo { stage, target });
let cargo = builder.ensure(tool::Cargo {
compiler: builder.compiler(stage, build.build),
target
});
install(&cargo, &image.join("bin"), 0o755);
for man in t!(etc.join("man").read_dir()) {
let man = t!(man);
@ -1046,7 +1052,10 @@ fn run(self, builder: &Builder) -> PathBuf {
t!(fs::create_dir_all(&image));
// Prepare the image directory
let rls = builder.ensure(tool::Rls { stage, target });
let rls = builder.ensure(tool::Rls {
compiler: builder.compiler(stage, build.build),
target
});
install(&rls, &image.join("bin"), 0o755);
let doc = image.join("share/doc/rls");
install(&src.join("README.md"), &doc, 0o644);

View File

@ -21,13 +21,12 @@
use std::io::prelude::*;
use std::io;
use std::path::{PathBuf, Path};
use std::process::Command;
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};
@ -177,6 +176,7 @@ fn run(self, builder: &Builder) {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct TheBook {
compiler: Compiler,
target: Interned<String>,
name: &'static str,
}
@ -192,6 +192,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(TheBook {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
name: "book",
});
@ -224,7 +225,7 @@ fn run(self, builder: &Builder) {
// 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);
@ -233,21 +234,17 @@ fn run(self, builder: &Builder) {
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);
let compiler = builder.compiler(0, build.build);
let path = build.src.join("src/doc").join(markdown);
let rustdoc = builder.rustdoc(compiler);
let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc");
@ -263,9 +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 = Command::new(&rustdoc);
builder.add_rustc_lib_path(compiler, &mut cmd);
let mut cmd = builder.rustdoc_cmd(compiler);
let out = out.join("book");
@ -286,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>,
}
@ -300,6 +296,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(Standalone {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
});
}
@ -315,12 +312,11 @@ fn make_run(run: RunConfig) {
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");
@ -357,8 +353,7 @@ fn run(self, builder: &Builder) {
continue
}
let mut cmd = Command::new(&rustdoc);
builder.add_rustc_lib_path(compiler, &mut cmd);
let mut cmd = builder.rustdoc_cmd(compiler);
cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon)
@ -413,6 +408,7 @@ fn run(self, builder: &Builder) {
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 {
@ -422,7 +418,6 @@ fn run(self, builder: &Builder) {
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
@ -498,6 +493,7 @@ fn run(self, builder: &Builder) {
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 {
@ -510,7 +506,6 @@ fn run(self, builder: &Builder) {
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);
@ -559,6 +554,7 @@ fn run(self, builder: &Builder) {
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 {
@ -571,7 +567,6 @@ fn run(self, builder: &Builder) {
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);

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fs;
use std::env;
use std::path::PathBuf;
use std::process::Command;
@ -15,17 +16,17 @@
use Mode;
use Compiler;
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 native;
use channel::GitInfo;
use cache::Interned;
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct CleanTools {
pub stage: u32,
pub target: Interned<String>,
pub mode: Mode,
struct CleanTools {
compiler: Compiler,
target: Interned<String>,
mode: Mode,
}
impl Step for CleanTools {
@ -41,12 +42,10 @@ fn should_run(run: ShouldRun) -> ShouldRun {
/// `stage` into the normal cargo output directory.
fn run(self, builder: &Builder) {
let build = builder.build;
let stage = self.stage;
let compiler = self.compiler;
let target = self.target;
let mode = self.mode;
let compiler = builder.compiler(stage, build.build);
let stamp = match mode {
Mode::Libstd => libstd_stamp(build, compiler, target),
Mode::Libtest => libtest_stamp(build, compiler, target),
@ -59,11 +58,11 @@ fn run(self, builder: &Builder) {
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ToolBuild {
pub stage: u32,
pub target: Interned<String>,
pub tool: &'static str,
pub mode: Mode,
struct ToolBuild {
compiler: Compiler,
target: Interned<String>,
tool: &'static str,
mode: Mode,
}
impl Step for ToolBuild {
@ -79,12 +78,11 @@ fn should_run(run: ShouldRun) -> ShouldRun {
/// `stage` into the normal cargo output directory.
fn run(self, builder: &Builder) -> PathBuf {
let build = builder.build;
let stage = self.stage;
let compiler = self.compiler;
let target = self.target;
let tool = self.tool;
let compiler = builder.compiler(stage, build.build);
builder.ensure(CleanTools { stage, target, mode: self.mode });
builder.ensure(CleanTools { compiler, target, mode: self.mode });
match self.mode {
Mode::Libstd => builder.ensure(compile::Std { compiler, target }),
Mode::Libtest => builder.ensure(compile::Test { compiler, target }),
@ -92,8 +90,8 @@ fn run(self, builder: &Builder) -> PathBuf {
Mode::Tool => panic!("unexpected Mode::Tool for tool build")
}
let _folder = build.fold_output(|| format!("stage{}-{}", stage, tool));
println!("Building stage{} tool {} ({})", stage, tool, target);
let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);
let mut cargo = builder.cargo(compiler, Mode::Tool, target, "build");
let dir = build.src.join("src/tools").join(tool);
@ -141,7 +139,7 @@ pub fn tool_exe(&self, tool: Tool) -> PathBuf {
match tool {
$(Tool::$name =>
self.ensure($name {
stage: 0,
compiler: self.compiler(0, self.build.build),
target: self.build.build,
}),
)+
@ -152,7 +150,7 @@ pub fn tool_exe(&self, tool: Tool) -> PathBuf {
$(
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $name {
pub stage: u32,
pub compiler: Compiler,
pub target: Interned<String>,
}
@ -165,14 +163,14 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure($name {
stage: run.builder.top_stage,
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
});
}
fn run(self, builder: &Builder) -> PathBuf {
builder.ensure(ToolBuild {
stage: self.stage,
compiler: self.compiler,
target: self.target,
tool: $tool_name,
mode: $mode,
@ -198,7 +196,7 @@ fn run(self, builder: &Builder) -> PathBuf {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RemoteTestServer {
pub stage: u32,
pub compiler: Compiler,
pub target: Interned<String>,
}
@ -211,14 +209,14 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(RemoteTestServer {
stage: run.builder.top_stage,
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
});
}
fn run(self, builder: &Builder) -> PathBuf {
builder.ensure(ToolBuild {
stage: self.stage,
compiler: self.compiler,
target: self.target,
tool: "remote-test-server",
mode: Mode::Libstd,
@ -226,9 +224,62 @@ fn run(self, builder: &Builder) -> PathBuf {
}
}
#[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 {
builder.compiler(0, builder.build.build)
} else {
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
// compilers, which isn't what we want.
builder.compiler(target_compiler.stage - 1, builder.build.build)
};
let tool_rustdoc = builder.ensure(ToolBuild {
compiler: build_compiler,
target: target_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)]
pub struct Cargo {
pub stage: u32,
pub compiler: Compiler,
pub target: Interned<String>,
}
@ -244,7 +295,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(Cargo {
stage: run.builder.top_stage,
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
});
}
@ -256,11 +307,11 @@ fn run(self, builder: &Builder) -> PathBuf {
// Cargo depends on procedural macros, which requires a full host
// compiler to be available, so we need to depend on that.
builder.ensure(compile::Rustc {
compiler: builder.compiler(self.stage, builder.build.build),
compiler: self.compiler,
target: builder.build.build,
});
builder.ensure(ToolBuild {
stage: self.stage,
compiler: self.compiler,
target: self.target,
tool: "cargo",
mode: Mode::Librustc,
@ -270,7 +321,7 @@ fn run(self, builder: &Builder) -> PathBuf {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rls {
pub stage: u32,
pub compiler: Compiler,
pub target: Interned<String>,
}
@ -286,7 +337,7 @@ fn should_run(run: ShouldRun) -> ShouldRun {
fn make_run(run: RunConfig) {
run.builder.ensure(Rls {
stage: run.builder.top_stage,
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
});
}
@ -298,11 +349,11 @@ fn run(self, builder: &Builder) -> PathBuf {
// RLS depends on procedural macros, which requires a full host
// compiler to be available, so we need to depend on that.
builder.ensure(compile::Rustc {
compiler: builder.compiler(self.stage, builder.build.build),
compiler: self.compiler,
target: builder.build.build,
});
builder.ensure(ToolBuild {
stage: self.stage,
compiler: self.compiler,
target: self.target,
tool: "rls",
mode: Mode::Librustc,

View File

@ -1,22 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(rustc, feature(rustc_private))]
#![cfg_attr(rustdoc, feature(rustdoc))]
#[cfg(rustdoc)]
extern crate rustdoc as this;
#[cfg(rustc)]
extern crate rustc_driver as this;
fn main() {
this::main()
}

View File

@ -7,25 +7,10 @@ build = "build.rs"
[lib]
name = "rustdoc"
path = "lib.rs"
crate-type = ["dylib"]
[dependencies]
arena = { path = "../libarena" }
env_logger = { version = "0.4", default-features = false }
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 }
[build-dependencies]

View File

@ -17,6 +17,7 @@
html_playground_url = "https://play.rust-lang.org/")]
#![deny(warnings)]
#![feature(rustc_private)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(libc)]

View File

@ -7,16 +7,11 @@ version = "0.0.0"
name = "rustc"
path = "rustc.rs"
[[bin]]
name = "rustdoc"
path = "rustdoc.rs"
# All optional dependencies so the features passed to this Cargo.toml select
# what should actually be built.
[dependencies]
rustc_back = { path = "../librustc_back" }
rustc_driver = { path = "../librustc_driver" }
rustdoc = { path = "../librustdoc" }
[features]
jemalloc = ["rustc_back/jemalloc"]

View File

@ -93,7 +93,7 @@ pub struct Config {
pub rustc_path: PathBuf,
// The rustdoc executable
pub rustdoc_path: PathBuf,
pub rustdoc_path: Option<PathBuf>,
// The python executable to use for LLDB
pub lldb_python: String,

View File

@ -67,7 +67,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
.reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
.optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
.reqopt("", "lldb-python", "path to python to use for doc tests", "PATH")
.reqopt("", "docck-python", "path to python to use for doc tests", "PATH")
.optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM")
@ -157,7 +157,7 @@ fn make_absolute(path: PathBuf) -> PathBuf {
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
rustc_path: opt_path(matches, "rustc-path"),
rustdoc_path: opt_path(matches, "rustdoc-path"),
rustdoc_path: matches.opt_str("rustdoc-path").map(PathBuf::from),
lldb_python: matches.opt_str("lldb-python").unwrap(),
docck_python: matches.opt_str("docck-python").unwrap(),
valgrind_path: matches.opt_str("valgrind-path"),
@ -210,7 +210,7 @@ pub fn log_config(config: &Config) {
logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path.display()));
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
logv(c, format!("src_base: {:?}", config.src_base.display()));
logv(c, format!("build_base: {:?}", config.build_base.display()));
logv(c, format!("stage_id: {}", config.stage_id));

View File

@ -1192,7 +1192,8 @@ fn document(&self, out_dir: &Path) -> ProcRes {
self.testpaths.file.to_str().unwrap().to_owned()];
args.extend(self.props.compile_flags.iter().cloned());
let args = ProcArgs {
prog: self.config.rustdoc_path.to_str().unwrap().to_owned(),
prog: self.config.rustdoc_path
.as_ref().expect("--rustdoc-path passed").to_str().unwrap().to_owned(),
args: args,
};
self.compose_and_run_compiler(args, None)
@ -2163,7 +2164,8 @@ fn run_rmake_test(&self) {
.env("S", src_root)
.env("RUST_BUILD_STAGE", &self.config.stage_id)
.env("RUSTC", cwd.join(&self.config.rustc_path))
.env("RUSTDOC", cwd.join(&self.config.rustdoc_path))
.env("RUSTDOC",
cwd.join(&self.config.rustdoc_path.as_ref().expect("--rustdoc-path passed")))
.env("TMPDIR", &tmpdir)
.env("LD_LIB_PATH_ENVVAR", procsrv::dylib_env_var())
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))

View File

@ -3,6 +3,9 @@ authors = ["The Rust Project Developers"]
name = "error_index_generator"
version = "0.0.0"
[dependencies]
rustdoc = { path = "../../librustdoc" }
[[bin]]
name = "error_index_generator"
path = "main.rs"

View 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" }

View File

@ -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
// http://rust-lang.org/COPYRIGHT.
//
@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_private)]
extern crate rustdoc;
fn main() { rustdoc::main() }