about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAhmed Charles <acharles@outlook.com>2016-10-05 21:19:01 -0700
committerAhmed Charles <acharles@outlook.com>2016-10-05 22:42:40 -0700
commita580f8f80d0563dc849529cb5908c4c618f272df (patch)
tree0a88be68b635c8ef8f10acc68324839a262f458a
parente6985b2a6daa5acb84f364f6e6ddfdf170c28f2b (diff)
downloadrust-a580f8f80d0563dc849529cb5908c4c618f272df.tar.gz
rust-a580f8f80d0563dc849529cb5908c4c618f272df.zip
Install docs, std and rustc using results from dist.
-rw-r--r--src/bootstrap/dist.rs6
-rw-r--r--src/bootstrap/install.rs32
2 files changed, 32 insertions, 6 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 31b7db168b4..465abf15750 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -27,7 +27,7 @@ use {Build, Compiler};
 use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
 use regex::{RegexSet, quote};
 
-fn package_vers(build: &Build) -> &str {
+pub fn package_vers(build: &Build) -> &str {
     match &build.config.channel[..] {
         "stable" => &build.release,
         "beta" => "beta",
@@ -40,7 +40,7 @@ fn distdir(build: &Build) -> PathBuf {
     build.out.join("dist")
 }
 
-fn tmpdir(build: &Build) -> PathBuf {
+pub fn tmpdir(build: &Build) -> PathBuf {
     build.out.join("tmp/dist")
 }
 
@@ -418,7 +418,7 @@ fn chmod(_path: &Path, _perms: u32) {}
 
 // We have to run a few shell scripts, which choke quite a bit on both `\`
 // characters and on `C:\` paths, so normalize both of them away.
-fn sanitize_sh(path: &Path) -> String {
+pub fn sanitize_sh(path: &Path) -> String {
     let path = path.to_str().unwrap().replace("\\", "/");
     return change_drive(&path).unwrap_or(path);
 
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 8bad3dfb41e..1c714620a01 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -13,10 +13,36 @@
 //! This module is responsible for installing the standard library,
 //! compiler, and documentation.
 
+use std::fs;
+use std::path::Path;
+use std::process::Command;
+
 use Build;
+use dist::{package_vers, sanitize_sh, tmpdir};
 
 /// Installs everything.
-pub fn install(_: &Build, stage: u32, host: &str) {
-    println!("Install everything stage{} ({})", stage, host);
-    println!("Note: install currently does nothing.");
+pub fn install(build: &Build, stage: u32, host: &str) {
+    let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x))
+        .unwrap_or(Path::new("/usr/local"));
+    let empty_dir = build.out.join("tmp/empty_dir");
+    t!(fs::create_dir_all(&empty_dir));
+    if build.config.docs {
+        install_sh(&build, "docs", "rust-docs", stage, host, prefix, &empty_dir);
+    }
+    install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir);
+    install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir);
+    t!(fs::remove_dir_all(&empty_dir));
+}
+
+fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str,
+              prefix: &Path, empty_dir: &Path) {
+    println!("Install {} stage{} ({})", package, stage, host);
+    let package_name = format!("{}-{}-{}", name, package_vers(build), host);
+
+    let mut cmd = Command::new("sh");
+    cmd.current_dir(empty_dir)
+       .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
+       .arg(format!("--prefix={}", sanitize_sh(&prefix)))
+       .arg("--disable-ldconfig");
+    build.run(&mut cmd);
 }