Skip to content

Commit

Permalink
Install docs, std and rustc using results from dist.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedcharles committed Oct 6, 2016
1 parent e6985b2 commit a580f8f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/bootstrap/dist.rs
Expand Up @@ -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",
Expand All @@ -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")
}

Expand Down Expand Up @@ -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);

Expand Down
32 changes: 29 additions & 3 deletions src/bootstrap/install.rs
Expand Up @@ -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);
}

0 comments on commit a580f8f

Please sign in to comment.