rustbuild: Move rustbook to a `src/tools` directory

We've actually got quite a few tools that are compiled as part of our build,
let's start housing them all in a `tools` directory.
This commit is contained in:
Alex Crichton 2016-03-07 22:32:37 -08:00
parent 4d3d29dff3
commit ee6df13f0c
21 changed files with 55 additions and 56 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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
}

View File

@ -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))]
}
}
}

View File

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

9
src/rustc/Cargo.lock generated
View File

@ -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"

View File

@ -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 }

View File

@ -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 <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.
extern crate rustbook;
fn main() { rustbook::main() }

4
src/tools/rustbook/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[root]
name = "rustbook"
version = "0.0.0"

View File

@ -0,0 +1,8 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustbook"
version = "0.0.0"
[[bin]]
name = "rustbook"
path = "main.rs"

View File

@ -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(())
}