diff --git a/mk/crates.mk b/mk/crates.mk index b7bb7c1083d..f7fd74e8c9f 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -125,7 +125,7 @@ TOOL_DEPS_error_index_generator := rustdoc syntax serialize TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs TOOL_SOURCE_rustc := $(S)src/driver/driver.rs -TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs +TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs TOOL_SOURCE_error_index_generator := $(S)src/error_index_generator/main.rs ONLY_RLIB_core := 1 diff --git a/src/bootstrap/build/compile.rs b/src/bootstrap/build/compile.rs index fb0a840bfa2..a027ac0fd60 100644 --- a/src/bootstrap/build/compile.rs +++ b/src/bootstrap/build/compile.rs @@ -298,3 +298,28 @@ fn add_to_sysroot(out_dir: &Path, sysroot_dst: &Path) { sysroot_dst.join(path.file_name().unwrap()))); } } + +/// Build a tool in `src/tools` +/// +/// This will build the specified tool with the specified `host` compiler in +/// `stage` into the normal cargo output directory. +pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) { + println!("Building stage{} tool {} ({})", stage, tool, host); + + let compiler = Compiler::new(stage, host); + + // FIXME: need to clear out previous tool and ideally deps, may require + // isolating output directories or require a pseudo shim step to + // clear out all the info. + // + // Maybe when libstd is compiled it should clear out the rustc of the + // corresponding stage? + // let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target); + // build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target)); + + let mut cargo = build.cargo(stage, &compiler, Mode::Tool, None, "build"); + cargo.arg("--manifest-path") + .arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool))); + build.run(&mut cargo); +} + diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 05920a480a9..8449c237816 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -165,6 +165,9 @@ impl Build { Rustc { stage } => { compile::assemble_rustc(self, stage, target.target); } + ToolRustbook { stage } => { + compile::tool(self, stage, target.target, "rustbook"); + } DocBook { stage } => { doc::rustbook(self, stage, target.target, "book", &doc_out); } @@ -303,15 +306,9 @@ impl Build { /// Get the specified tool next to the specified compiler fn tool(&self, compiler: &Compiler, tool: &str) -> PathBuf { - if compiler.is_snapshot(self) { - assert!(tool == "rustdoc", "no tools other than rustdoc in stage0"); - let mut rustdoc = self.rustc.clone(); - rustdoc.pop(); - rustdoc.push(exe("rustdoc", &self.config.build)); - return rustdoc - } - let (stage, host) = (compiler.stage, compiler.host); - self.cargo_out(stage - 1, host, false, host).join(exe(tool, host)) + self.stage_out(compiler.stage, compiler.host, false) + .join(self.cargo_dir()) + .join(exe(tool, compiler.host)) } /// Get a `Command` which is ready to run `tool` in `stage` built for @@ -322,8 +319,8 @@ impl Build { let host = compiler.host; let stage = compiler.stage; let paths = vec![ - self.cargo_out(stage - 1, host, true, host).join("deps"), - self.cargo_out(stage - 1, host, false, host).join("deps"), + self.cargo_out(stage, host, true, host).join("deps"), + self.cargo_out(stage, host, false, host).join("deps"), ]; add_lib_path(paths, &mut cmd); return cmd @@ -354,7 +351,6 @@ impl Build { } if stage > 0 { features.push_str(" rustdoc"); - features.push_str(" rustbook"); } return features } diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index e47c7311ae4..23c678df9ac 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -45,6 +45,9 @@ macro_rules! targets { host: &'a str }), + // Various tools that we can build as part of the build. + (tool_rustbook, ToolRustbook { stage: u32 }), + // Steps for long-running native builds. Ideally these wouldn't // actually exist and would be part of build scripts, but for now // these are here. @@ -255,7 +258,9 @@ impl<'a> Step<'a> { } Source::DocBook { stage } | Source::DocNomicon { stage } | - Source::DocStyle { stage } | + Source::DocStyle { stage } => { + vec![self.tool_rustbook(stage)] + } Source::DocStandalone { stage } => { vec![self.rustc(stage)] } @@ -269,6 +274,8 @@ impl<'a> Step<'a> { } Source::Check { stage, compiler: _ } => { vec![] + Source::ToolRustbook { stage } => { + vec![self.librustc(stage, self.compiler(stage))] } } } diff --git a/src/rustbook/Cargo.toml b/src/rustbook/Cargo.toml deleted file mode 100644 index c684c474efa..00000000000 --- a/src/rustbook/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -authors = ["The Rust Project Developers"] -name = "rustbook" -version = "0.0.0" - -[lib] -name = "rustbook" -path = "main.rs" -crate-type = ["dylib"] - -[dependencies] -rustc_back = { path = "../librustc_back" } -rustdoc = { path = "../librustdoc" } diff --git a/src/rustc/Cargo.lock b/src/rustc/Cargo.lock index e4432720ab4..a2718351640 100644 --- a/src/rustc/Cargo.lock +++ b/src/rustc/Cargo.lock @@ -2,7 +2,6 @@ name = "rustc-main" version = "0.0.0" dependencies = [ - "rustbook 0.0.0", "rustc_back 0.0.0", "rustc_driver 0.0.0", "rustdoc 0.0.0", @@ -66,14 +65,6 @@ dependencies = [ "serialize 0.0.0", ] -[[package]] -name = "rustbook" -version = "0.0.0" -dependencies = [ - "rustc_back 0.0.0", - "rustdoc 0.0.0", -] - [[package]] name = "rustc" version = "0.0.0" diff --git a/src/rustc/Cargo.toml b/src/rustc/Cargo.toml index 9fcefd9d3a4..f1abf35cbc0 100644 --- a/src/rustc/Cargo.toml +++ b/src/rustc/Cargo.toml @@ -11,10 +11,6 @@ path = "rustc.rs" name = "rustdoc" path = "rustdoc.rs" -[[bin]] -name = "rustbook" -path = "rustbook.rs" - [profile.release] opt-level = 2 @@ -27,7 +23,6 @@ debug-assertions = false # All optional dependencies so the features passed to this Cargo.toml select # what should actually be built. [dependencies] -rustbook = { path = "../rustbook", optional = true } rustc_back = { path = "../librustc_back" } rustc_driver = { path = "../librustc_driver" } rustdoc = { path = "../librustdoc", optional = true } diff --git a/src/rustc/rustbook.rs b/src/rustc/rustbook.rs deleted file mode 100644 index 6f78f78bc55..00000000000 --- a/src/rustc/rustbook.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 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. - -extern crate rustbook; - -fn main() { rustbook::main() } - diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock new file mode 100644 index 00000000000..e541ce4b2b8 --- /dev/null +++ b/src/tools/rustbook/Cargo.lock @@ -0,0 +1,4 @@ +[root] +name = "rustbook" +version = "0.0.0" + diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml new file mode 100644 index 00000000000..956392ca540 --- /dev/null +++ b/src/tools/rustbook/Cargo.toml @@ -0,0 +1,8 @@ +[package] +authors = ["The Rust Project Developers"] +name = "rustbook" +version = "0.0.0" + +[[bin]] +name = "rustbook" +path = "main.rs" diff --git a/src/rustbook/book.rs b/src/tools/rustbook/book.rs similarity index 100% rename from src/rustbook/book.rs rename to src/tools/rustbook/book.rs diff --git a/src/rustbook/build.rs b/src/tools/rustbook/build.rs similarity index 99% rename from src/rustbook/build.rs rename to src/tools/rustbook/build.rs index 4b6d67d2d26..70ed98519f9 100644 --- a/src/rustbook/build.rs +++ b/src/tools/rustbook/build.rs @@ -160,7 +160,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { // Copy js for playpen let mut playpen = try!(File::create(tgt.join("playpen.js"))); - let js = include_bytes!("../librustdoc/html/static/playpen.js"); + let js = include_bytes!("../../librustdoc/html/static/playpen.js"); try!(playpen.write_all(js)); Ok(()) } diff --git a/src/rustbook/error.rs b/src/tools/rustbook/error.rs similarity index 100% rename from src/rustbook/error.rs rename to src/tools/rustbook/error.rs diff --git a/src/rustbook/help.rs b/src/tools/rustbook/help.rs similarity index 100% rename from src/rustbook/help.rs rename to src/tools/rustbook/help.rs diff --git a/src/rustbook/main.rs b/src/tools/rustbook/main.rs similarity index 100% rename from src/rustbook/main.rs rename to src/tools/rustbook/main.rs diff --git a/src/rustbook/serve.rs b/src/tools/rustbook/serve.rs similarity index 100% rename from src/rustbook/serve.rs rename to src/tools/rustbook/serve.rs diff --git a/src/rustbook/static/rustbook.css b/src/tools/rustbook/static/rustbook.css similarity index 100% rename from src/rustbook/static/rustbook.css rename to src/tools/rustbook/static/rustbook.css diff --git a/src/rustbook/static/rustbook.js b/src/tools/rustbook/static/rustbook.js similarity index 100% rename from src/rustbook/static/rustbook.js rename to src/tools/rustbook/static/rustbook.js diff --git a/src/rustbook/subcommand.rs b/src/tools/rustbook/subcommand.rs similarity index 100% rename from src/rustbook/subcommand.rs rename to src/tools/rustbook/subcommand.rs diff --git a/src/rustbook/term.rs b/src/tools/rustbook/term.rs similarity index 100% rename from src/rustbook/term.rs rename to src/tools/rustbook/term.rs diff --git a/src/rustbook/test.rs b/src/tools/rustbook/test.rs similarity index 100% rename from src/rustbook/test.rs rename to src/tools/rustbook/test.rs