Add support for docdir, libdir and mandir.
This commit is contained in:
parent
a580f8f80d
commit
fa230825c1
|
@ -79,6 +79,9 @@ pub struct Config {
|
|||
// Fallback musl-root for all targets
|
||||
pub musl_root: Option<PathBuf>,
|
||||
pub prefix: Option<String>,
|
||||
pub docdir: Option<String>,
|
||||
pub libdir: Option<String>,
|
||||
pub mandir: Option<String>,
|
||||
pub codegen_tests: bool,
|
||||
pub nodejs: Option<PathBuf>,
|
||||
}
|
||||
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue