From fa230825c1da8605d51a2ef8d6b672b60baeb692 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Wed, 5 Oct 2016 22:42:19 -0700 Subject: [PATCH] Add support for docdir, libdir and mandir. --- src/bootstrap/config.rs | 12 ++++++++++++ src/bootstrap/install.rs | 23 ++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index a8434c3efb358..e441d8d5ca733 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -79,6 +79,9 @@ pub struct Config { // Fallback musl-root for all targets pub musl_root: Option, pub prefix: Option, + pub docdir: Option, + pub libdir: Option, + pub mandir: Option, pub codegen_tests: bool, pub nodejs: Option, } @@ -357,6 +360,15 @@ impl Config { "CFG_PREFIX" => { self.prefix = Some(value.to_string()); } + "CFG_DOCDIR" => { + self.docdir = Some(value.to_string()); + } + "CFG_LIBDIR" => { + self.libdir = Some(value.to_string()); + } + "CFG_MANDIR" => { + self.mandir = Some(value.to_string()); + } "CFG_LLVM_ROOT" if value.len() > 0 => { let target = self.target_config.entry(self.build.clone()) .or_insert(Target::default()); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 1c714620a016f..9bc5a7c00abaf 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -14,6 +14,7 @@ //! compiler, and documentation. use std::fs; +use std::borrow::Cow; use std::path::Path; use std::process::Command; @@ -24,25 +25,37 @@ use dist::{package_vers, sanitize_sh, tmpdir}; 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 docdir = build.config.docdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) + .unwrap_or(Cow::Owned(prefix.join("share/doc/rust"))); + let libdir = build.config.libdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) + .unwrap_or(Cow::Owned(prefix.join("lib"))); + let mandir = build.config.mandir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x))) + .unwrap_or(Cow::Owned(prefix.join("share/man"))); 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, "docs", "rust-docs", stage, host, prefix, + &docdir, &libdir, &mandir, &empty_dir); } - install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir); - install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir); + install_sh(&build, "std", "rust-std", stage, host, prefix, + &docdir, &libdir, &mandir, &empty_dir); + install_sh(&build, "rustc", "rustc", stage, host, prefix, + &docdir, &libdir, &mandir, &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) { + prefix: &Path, docdir: &Path, libdir: &Path, mandir: &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(format!("--prefix={}", sanitize_sh(prefix))) + .arg(format!("--docdir={}", sanitize_sh(docdir))) + .arg(format!("--libdir={}", sanitize_sh(libdir))) + .arg(format!("--mandir={}", sanitize_sh(mandir))) .arg("--disable-ldconfig"); build.run(&mut cmd); }