about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-03-07 22:32:37 -0800
committerAlex Crichton <alex@alexcrichton.com>2016-03-08 11:52:09 -0800
commitee6df13f0c25ce567b12459d1f34216334832920 (patch)
tree80bf720f072bb03c7aa1b165f6f5e09e452543f7
parent4d3d29dff34b7e041a8947fab13e1a43a714ad12 (diff)
downloadrust-ee6df13f0c25ce567b12459d1f34216334832920.tar.gz
rust-ee6df13f0c25ce567b12459d1f34216334832920.zip
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.
-rw-r--r--mk/crates.mk2
-rw-r--r--src/bootstrap/build/compile.rs25
-rw-r--r--src/bootstrap/build/mod.rs20
-rw-r--r--src/bootstrap/build/step.rs9
-rw-r--r--src/rustbook/Cargo.toml13
-rw-r--r--src/rustc/Cargo.lock9
-rw-r--r--src/rustc/Cargo.toml5
-rw-r--r--src/rustc/rustbook.rs14
-rw-r--r--src/tools/rustbook/Cargo.lock4
-rw-r--r--src/tools/rustbook/Cargo.toml8
-rw-r--r--src/tools/rustbook/book.rs (renamed from src/rustbook/book.rs)0
-rw-r--r--src/tools/rustbook/build.rs (renamed from src/rustbook/build.rs)2
-rw-r--r--src/tools/rustbook/error.rs (renamed from src/rustbook/error.rs)0
-rw-r--r--src/tools/rustbook/help.rs (renamed from src/rustbook/help.rs)0
-rw-r--r--src/tools/rustbook/main.rs (renamed from src/rustbook/main.rs)0
-rw-r--r--src/tools/rustbook/serve.rs (renamed from src/rustbook/serve.rs)0
-rw-r--r--src/tools/rustbook/static/rustbook.css (renamed from src/rustbook/static/rustbook.css)0
-rw-r--r--src/tools/rustbook/static/rustbook.js (renamed from src/rustbook/static/rustbook.js)0
-rw-r--r--src/tools/rustbook/subcommand.rs (renamed from src/rustbook/subcommand.rs)0
-rw-r--r--src/tools/rustbook/term.rs (renamed from src/rustbook/term.rs)0
-rw-r--r--src/tools/rustbook/test.rs (renamed from src/rustbook/test.rs)0
21 files changed, 55 insertions, 56 deletions
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",
@@ -67,14 +66,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "rustbook"
-version = "0.0.0"
-dependencies = [
- "rustc_back 0.0.0",
- "rustdoc 0.0.0",
-]
-
-[[package]]
 name = "rustc"
 version = "0.0.0"
 dependencies = [
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 <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() }
-
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
index 36a37dba1fa..36a37dba1fa 100644
--- a/src/rustbook/book.rs
+++ b/src/tools/rustbook/book.rs
diff --git a/src/rustbook/build.rs b/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
index e896dee2791..e896dee2791 100644
--- a/src/rustbook/error.rs
+++ b/src/tools/rustbook/error.rs
diff --git a/src/rustbook/help.rs b/src/tools/rustbook/help.rs
index c90c2b93609..c90c2b93609 100644
--- a/src/rustbook/help.rs
+++ b/src/tools/rustbook/help.rs
diff --git a/src/rustbook/main.rs b/src/tools/rustbook/main.rs
index bd4fc899293..bd4fc899293 100644
--- a/src/rustbook/main.rs
+++ b/src/tools/rustbook/main.rs
diff --git a/src/rustbook/serve.rs b/src/tools/rustbook/serve.rs
index 2fa7b7eed7b..2fa7b7eed7b 100644
--- a/src/rustbook/serve.rs
+++ b/src/tools/rustbook/serve.rs
diff --git a/src/rustbook/static/rustbook.css b/src/tools/rustbook/static/rustbook.css
index ba0151fa2ed..ba0151fa2ed 100644
--- a/src/rustbook/static/rustbook.css
+++ b/src/tools/rustbook/static/rustbook.css
diff --git a/src/rustbook/static/rustbook.js b/src/tools/rustbook/static/rustbook.js
index d8ab15260ed..d8ab15260ed 100644
--- a/src/rustbook/static/rustbook.js
+++ b/src/tools/rustbook/static/rustbook.js
diff --git a/src/rustbook/subcommand.rs b/src/tools/rustbook/subcommand.rs
index a66c2b4f302..a66c2b4f302 100644
--- a/src/rustbook/subcommand.rs
+++ b/src/tools/rustbook/subcommand.rs
diff --git a/src/rustbook/term.rs b/src/tools/rustbook/term.rs
index cdd25e67c8f..cdd25e67c8f 100644
--- a/src/rustbook/term.rs
+++ b/src/tools/rustbook/term.rs
diff --git a/src/rustbook/test.rs b/src/tools/rustbook/test.rs
index 72df0768e7b..72df0768e7b 100644
--- a/src/rustbook/test.rs
+++ b/src/tools/rustbook/test.rs