diff --git a/src/Cargo.lock b/src/Cargo.lock index 1df8bcf74cd8f..e193cc612c52d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -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]] diff --git a/src/Cargo.toml b/src/Cargo.toml index 6e81ec67260d8..4b84272df9812 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -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", diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7be391e542027..2f6e3ca9253f8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -256,7 +256,7 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { } } - /// 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 @@ impl<'a> Builder<'a> { .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 @@ impl<'a> Builder<'a> { // 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"); } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index d2e181f94c62b..b04e4de774453 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -119,7 +119,7 @@ impl Step for Linkcheck { } fn make_run(run: RunConfig) { - run.builder.ensure(Linkcheck { host: run.host }); + run.builder.ensure(Linkcheck { host: run.target }); } } @@ -140,7 +140,7 @@ impl Step for Cargotest { fn make_run(run: RunConfig) { run.builder.ensure(Cargotest { stage: run.builder.top_stage, - host: run.host, + host: run.target, }); } @@ -194,7 +194,7 @@ impl Step for Cargo { 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 @@ impl Step for Rls { 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 @@ impl Step for Compiletest { 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 @@ impl Step for RemoteCopyLibs { 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); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 2e808c6568472..92a42b59212b4 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -719,15 +719,6 @@ impl Step for Assemble { 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 } } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e9256c6b3f2b6..c322d75dd5b45 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -413,6 +413,9 @@ impl Step for Rustc { 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 @@ impl Step for Cargo { // 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 @@ impl Step for Rls { 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); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 249ed2a2223a5..1ee578bb62b19 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -21,13 +21,12 @@ use std::fs::{self, File}; 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 @@ impl Step for RustbookSrc { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct TheBook { + compiler: Compiler, target: Interned, name: &'static str, } @@ -192,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.builder.build.build), target: run.target, name: "book", }); @@ -224,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); @@ -233,21 +234,17 @@ 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, markdown: &str) { +fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned, 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, 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, markdown: &str) { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Standalone { + compiler: Compiler, target: Interned, } @@ -300,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.builder.build.build), target: run.target, }); } @@ -315,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"); @@ -357,8 +353,7 @@ impl Step for Standalone { 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 @@ 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 { @@ -422,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 @@ -498,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 { @@ -510,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); @@ -559,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 { @@ -571,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); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index f32cddbafc3e7..862b3e2b1edb0 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -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 std::process::Command; 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, - pub mode: Mode, +struct CleanTools { + compiler: Compiler, + target: Interned, + mode: Mode, } impl Step for CleanTools { @@ -41,12 +42,10 @@ impl Step for CleanTools { /// `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 @@ impl Step for CleanTools { } #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct ToolBuild { - pub stage: u32, - pub target: Interned, - pub tool: &'static str, - pub mode: Mode, +struct ToolBuild { + compiler: Compiler, + target: Interned, + tool: &'static str, + mode: Mode, } impl Step for ToolBuild { @@ -79,12 +78,11 @@ impl Step for ToolBuild { /// `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 @@ impl Step for ToolBuild { 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 @@ macro_rules! tool { match tool { $(Tool::$name => self.ensure($name { - stage: 0, + compiler: self.compiler(0, self.build.build), target: self.build.build, }), )+ @@ -152,7 +150,7 @@ macro_rules! tool { $( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $name { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -165,14 +163,14 @@ macro_rules! tool { 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 @@ tool!( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RemoteTestServer { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -211,14 +209,14 @@ impl Step for RemoteTestServer { 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 @@ 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 { + 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, } @@ -244,7 +295,7 @@ impl Step for Cargo { 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 @@ impl Step for Cargo { // 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 @@ impl Step for Cargo { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rls { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -286,7 +337,7 @@ impl Step for Rls { 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 @@ impl Step for Rls { // 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, diff --git a/src/driver/driver.rs b/src/driver/driver.rs deleted file mode 100644 index e74652d85d788..0000000000000 --- a/src/driver/driver.rs +++ /dev/null @@ -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 or the MIT license -// , 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() -} diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 68f03d32e83cf..f9400e68a16c5 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -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] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 6c092d01a01d1..64240d26894d0 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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)] diff --git a/src/rustc/Cargo.toml b/src/rustc/Cargo.toml index dce1a0a8ec858..4452f4a2f446b 100644 --- a/src/rustc/Cargo.toml +++ b/src/rustc/Cargo.toml @@ -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"] diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index cc95e1b893052..0d6b350a1d431 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -93,7 +93,7 @@ pub struct Config { pub rustc_path: PathBuf, // The rustdoc executable - pub rustdoc_path: PathBuf, + pub rustdoc_path: Option, // The python executable to use for LLDB pub lldb_python: String, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 91f80a7afecdc..6fa758aeabe4d 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -67,7 +67,7 @@ pub fn parse_config(args: Vec ) -> 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 @@ pub fn parse_config(args: Vec ) -> Config { 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)); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index c6dc78ef5057d..9369656170873 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1192,7 +1192,8 @@ actual:\n\ 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 @@ actual:\n\ .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)) diff --git a/src/tools/error_index_generator/Cargo.toml b/src/tools/error_index_generator/Cargo.toml index 5c5ca273e9ca3..7f8783c9d89be 100644 --- a/src/tools/error_index_generator/Cargo.toml +++ b/src/tools/error_index_generator/Cargo.toml @@ -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" diff --git a/src/tools/rustdoc/Cargo.toml b/src/tools/rustdoc/Cargo.toml new file mode 100644 index 0000000000000..b6edb76d7f98f --- /dev/null +++ b/src/tools/rustdoc/Cargo.toml @@ -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" } diff --git a/src/rustc/rustdoc.rs b/src/tools/rustdoc/main.rs similarity index 83% rename from src/rustc/rustdoc.rs rename to src/tools/rustdoc/main.rs index a4f43c42623d3..9c37e249ba8cc 100644 --- a/src/rustc/rustdoc.rs +++ b/src/tools/rustdoc/main.rs @@ -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() }