Skip to content

Commit fa23082

Browse files
committed
Add support for docdir, libdir and mandir.
1 parent a580f8f commit fa23082

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/bootstrap/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub struct Config {
7979
// Fallback musl-root for all targets
8080
pub musl_root: Option<PathBuf>,
8181
pub prefix: Option<String>,
82+
pub docdir: Option<String>,
83+
pub libdir: Option<String>,
84+
pub mandir: Option<String>,
8285
pub codegen_tests: bool,
8386
pub nodejs: Option<PathBuf>,
8487
}
@@ -357,6 +360,15 @@ impl Config {
357360
"CFG_PREFIX" => {
358361
self.prefix = Some(value.to_string());
359362
}
363+
"CFG_DOCDIR" => {
364+
self.docdir = Some(value.to_string());
365+
}
366+
"CFG_LIBDIR" => {
367+
self.libdir = Some(value.to_string());
368+
}
369+
"CFG_MANDIR" => {
370+
self.mandir = Some(value.to_string());
371+
}
360372
"CFG_LLVM_ROOT" if value.len() > 0 => {
361373
let target = self.target_config.entry(self.build.clone())
362374
.or_insert(Target::default());

src/bootstrap/install.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! compiler, and documentation.
1515
1616
use std::fs;
17+
use std::borrow::Cow;
1718
use std::path::Path;
1819
use std::process::Command;
1920

@@ -24,25 +25,37 @@ use dist::{package_vers, sanitize_sh, tmpdir};
2425
pub fn install(build: &Build, stage: u32, host: &str) {
2526
let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x))
2627
.unwrap_or(Path::new("/usr/local"));
28+
let docdir = build.config.docdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
29+
.unwrap_or(Cow::Owned(prefix.join("share/doc/rust")));
30+
let libdir = build.config.libdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
31+
.unwrap_or(Cow::Owned(prefix.join("lib")));
32+
let mandir = build.config.mandir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
33+
.unwrap_or(Cow::Owned(prefix.join("share/man")));
2734
let empty_dir = build.out.join("tmp/empty_dir");
2835
t!(fs::create_dir_all(&empty_dir));
2936
if build.config.docs {
30-
install_sh(&build, "docs", "rust-docs", stage, host, prefix, &empty_dir);
37+
install_sh(&build, "docs", "rust-docs", stage, host, prefix,
38+
&docdir, &libdir, &mandir, &empty_dir);
3139
}
32-
install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir);
33-
install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir);
40+
install_sh(&build, "std", "rust-std", stage, host, prefix,
41+
&docdir, &libdir, &mandir, &empty_dir);
42+
install_sh(&build, "rustc", "rustc", stage, host, prefix,
43+
&docdir, &libdir, &mandir, &empty_dir);
3444
t!(fs::remove_dir_all(&empty_dir));
3545
}
3646

3747
fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str,
38-
prefix: &Path, empty_dir: &Path) {
48+
prefix: &Path, docdir: &Path, libdir: &Path, mandir: &Path, empty_dir: &Path) {
3949
println!("Install {} stage{} ({})", package, stage, host);
4050
let package_name = format!("{}-{}-{}", name, package_vers(build), host);
4151

4252
let mut cmd = Command::new("sh");
4353
cmd.current_dir(empty_dir)
4454
.arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
45-
.arg(format!("--prefix={}", sanitize_sh(&prefix)))
55+
.arg(format!("--prefix={}", sanitize_sh(prefix)))
56+
.arg(format!("--docdir={}", sanitize_sh(docdir)))
57+
.arg(format!("--libdir={}", sanitize_sh(libdir)))
58+
.arg(format!("--mandir={}", sanitize_sh(mandir)))
4659
.arg("--disable-ldconfig");
4760
build.run(&mut cmd);
4861
}

0 commit comments

Comments
 (0)