Skip to content

Commit a580f8f

Browse files
committed
Install docs, std and rustc using results from dist.
1 parent e6985b2 commit a580f8f

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/bootstrap/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use {Build, Compiler};
2727
use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
2828
use regex::{RegexSet, quote};
2929

30-
fn package_vers(build: &Build) -> &str {
30+
pub fn package_vers(build: &Build) -> &str {
3131
match &build.config.channel[..] {
3232
"stable" => &build.release,
3333
"beta" => "beta",
@@ -40,7 +40,7 @@ fn distdir(build: &Build) -> PathBuf {
4040
build.out.join("dist")
4141
}
4242

43-
fn tmpdir(build: &Build) -> PathBuf {
43+
pub fn tmpdir(build: &Build) -> PathBuf {
4444
build.out.join("tmp/dist")
4545
}
4646

@@ -418,7 +418,7 @@ fn chmod(_path: &Path, _perms: u32) {}
418418

419419
// We have to run a few shell scripts, which choke quite a bit on both `\`
420420
// characters and on `C:\` paths, so normalize both of them away.
421-
fn sanitize_sh(path: &Path) -> String {
421+
pub fn sanitize_sh(path: &Path) -> String {
422422
let path = path.to_str().unwrap().replace("\\", "/");
423423
return change_drive(&path).unwrap_or(path);
424424

src/bootstrap/install.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,36 @@
1313
//! This module is responsible for installing the standard library,
1414
//! compiler, and documentation.
1515
16+
use std::fs;
17+
use std::path::Path;
18+
use std::process::Command;
19+
1620
use Build;
21+
use dist::{package_vers, sanitize_sh, tmpdir};
1722

1823
/// Installs everything.
19-
pub fn install(_: &Build, stage: u32, host: &str) {
20-
println!("Install everything stage{} ({})", stage, host);
21-
println!("Note: install currently does nothing.");
24+
pub fn install(build: &Build, stage: u32, host: &str) {
25+
let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x))
26+
.unwrap_or(Path::new("/usr/local"));
27+
let empty_dir = build.out.join("tmp/empty_dir");
28+
t!(fs::create_dir_all(&empty_dir));
29+
if build.config.docs {
30+
install_sh(&build, "docs", "rust-docs", stage, host, prefix, &empty_dir);
31+
}
32+
install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir);
33+
install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir);
34+
t!(fs::remove_dir_all(&empty_dir));
35+
}
36+
37+
fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str,
38+
prefix: &Path, empty_dir: &Path) {
39+
println!("Install {} stage{} ({})", package, stage, host);
40+
let package_name = format!("{}-{}-{}", name, package_vers(build), host);
41+
42+
let mut cmd = Command::new("sh");
43+
cmd.current_dir(empty_dir)
44+
.arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
45+
.arg(format!("--prefix={}", sanitize_sh(&prefix)))
46+
.arg("--disable-ldconfig");
47+
build.run(&mut cmd);
2248
}

0 commit comments

Comments
 (0)