Skip to content

Commit b28cf75

Browse files
committed
Auto merge of #41853 - Keruspe:install, r=alexcrichton
rustbuild: add support for --bindir and --sysconfdir This depends on rust-lang/rust-installer#59 and we'll need to udpate the rust-installer submodule once it gets merged for it to work Fixes #41644
2 parents 4d09a0e + 08cc29e commit b28cf75

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

configure

+3
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
519519
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
520520
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
521521
valopt_nosave docdir "${CFG_PREFIX}/share/doc/rust" "install documentation in PATH"
522+
valopt_nosave bindir "${CFG_PREFIX}/bin" "install binaries"
522523

523524
# On Windows this determines root of the subtree for target libraries.
524525
# Host runtime libs always go to 'bin'.
@@ -710,6 +711,7 @@ envopt LDFLAGS
710711
CFG_PREFIX=${CFG_PREFIX%/}
711712
CFG_MANDIR=${CFG_MANDIR%/}
712713
CFG_DOCDIR=${CFG_DOCDIR%/}
714+
CFG_BINDIR=${CFG_BINDIR%/}
713715
CFG_HOST="$(echo $CFG_HOST | tr ',' ' ')"
714716
CFG_TARGET="$(echo $CFG_TARGET | tr ',' ' ')"
715717

@@ -750,6 +752,7 @@ putvar CFG_X86_64_LINUX_ANDROID_NDK
750752
putvar CFG_NACL_CROSS_PATH
751753
putvar CFG_MANDIR
752754
putvar CFG_DOCDIR
755+
putvar CFG_BINDIR
753756
putvar CFG_USING_LIBCPP
754757

755758
msg

src/Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/config.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ pub struct Config {
9999
// Fallback musl-root for all targets
100100
pub musl_root: Option<PathBuf>,
101101
pub prefix: Option<PathBuf>,
102+
pub sysconfdir: Option<PathBuf>,
102103
pub docdir: Option<PathBuf>,
104+
pub bindir: Option<PathBuf>,
103105
pub libdir: Option<PathBuf>,
104106
pub libdir_relative: Option<PathBuf>,
105107
pub mandir: Option<PathBuf>,
@@ -165,9 +167,11 @@ struct Build {
165167
#[derive(RustcDecodable, Default, Clone)]
166168
struct Install {
167169
prefix: Option<String>,
168-
mandir: Option<String>,
170+
sysconfdir: Option<String>,
169171
docdir: Option<String>,
172+
bindir: Option<String>,
170173
libdir: Option<String>,
174+
mandir: Option<String>,
171175
}
172176

173177
/// TOML representation of how the LLVM build is configured.
@@ -315,9 +319,11 @@ impl Config {
315319

316320
if let Some(ref install) = toml.install {
317321
config.prefix = install.prefix.clone().map(PathBuf::from);
318-
config.mandir = install.mandir.clone().map(PathBuf::from);
322+
config.sysconfdir = install.sysconfdir.clone().map(PathBuf::from);
319323
config.docdir = install.docdir.clone().map(PathBuf::from);
324+
config.bindir = install.bindir.clone().map(PathBuf::from);
320325
config.libdir = install.libdir.clone().map(PathBuf::from);
326+
config.mandir = install.mandir.clone().map(PathBuf::from);
321327
}
322328

323329
if let Some(ref llvm) = toml.llvm {
@@ -523,9 +529,15 @@ impl Config {
523529
"CFG_PREFIX" => {
524530
self.prefix = Some(PathBuf::from(value));
525531
}
532+
"CFG_SYSCONFDIR" => {
533+
self.sysconfdir = Some(PathBuf::from(value));
534+
}
526535
"CFG_DOCDIR" => {
527536
self.docdir = Some(PathBuf::from(value));
528537
}
538+
"CFG_BINDIR" => {
539+
self.bindir = Some(PathBuf::from(value));
540+
}
529541
"CFG_LIBDIR" => {
530542
self.libdir = Some(PathBuf::from(value));
531543
}

src/bootstrap/config.toml.example

+10-3
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,22 @@
160160
# Instead of installing to /usr/local, install to this path instead.
161161
#prefix = "/usr/local"
162162

163+
# Where to install system configuration files
164+
# If this is a relative path, it will get installed in `prefix` above
165+
#sysconfdir = "/etc"
166+
167+
# Where to install documentation in `prefix` above
168+
#docdir = "share/doc/rust"
169+
170+
# Where to install binaries in `prefix` above
171+
#bindir = "bin"
172+
163173
# Where to install libraries in `prefix` above
164174
#libdir = "lib"
165175

166176
# Where to install man pages in `prefix` above
167177
#mandir = "share/man"
168178

169-
# Where to install documentation in `prefix` above
170-
#docdir = "share/doc/rust"
171-
172179
# =============================================================================
173180
# Options for compiling Rust code itself
174181
# =============================================================================

src/bootstrap/install.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -24,60 +24,76 @@ use dist::{sanitize_sh, tmpdir};
2424
/// Installs everything.
2525
pub fn install(build: &Build, stage: u32, host: &str) {
2626
let prefix_default = PathBuf::from("/usr/local");
27+
let sysconfdir_default = PathBuf::from("/etc");
2728
let docdir_default = PathBuf::from("share/doc/rust");
28-
let mandir_default = PathBuf::from("share/man");
29+
let bindir_default = PathBuf::from("bin");
2930
let libdir_default = PathBuf::from("lib");
31+
let mandir_default = PathBuf::from("share/man");
3032
let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default);
33+
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
3134
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
35+
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
3236
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
3337
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);
3438

39+
let sysconfdir = prefix.join(sysconfdir);
3540
let docdir = prefix.join(docdir);
41+
let bindir = prefix.join(bindir);
3642
let libdir = prefix.join(libdir);
3743
let mandir = prefix.join(mandir);
3844

3945
let destdir = env::var_os("DESTDIR").map(PathBuf::from);
4046

4147
let prefix = add_destdir(&prefix, &destdir);
48+
let sysconfdir = add_destdir(&sysconfdir, &destdir);
4249
let docdir = add_destdir(&docdir, &destdir);
50+
let bindir = add_destdir(&bindir, &destdir);
4351
let libdir = add_destdir(&libdir, &destdir);
4452
let mandir = add_destdir(&mandir, &destdir);
4553

4654
let empty_dir = build.out.join("tmp/empty_dir");
4755
t!(fs::create_dir_all(&empty_dir));
4856
if build.config.docs {
4957
install_sh(&build, "docs", "rust-docs", &build.rust_package_vers(),
50-
stage, host, &prefix, &docdir, &libdir, &mandir, &empty_dir);
58+
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
59+
&mandir, &empty_dir);
5160
}
5261

5362
for target in build.config.target.iter() {
5463
install_sh(&build, "std", "rust-std", &build.rust_package_vers(),
55-
stage, target, &prefix, &docdir, &libdir, &mandir, &empty_dir);
64+
stage, target, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
65+
&mandir, &empty_dir);
5666
}
5767

5868
if build.config.extended {
5969
install_sh(&build, "cargo", "cargo", &build.cargo_package_vers(),
60-
stage, host, &prefix, &docdir, &libdir, &mandir, &empty_dir);
70+
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
71+
&mandir, &empty_dir);
6172
install_sh(&build, "rls", "rls", &build.rls_package_vers(),
62-
stage, host, &prefix, &docdir, &libdir, &mandir, &empty_dir);
73+
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
74+
&mandir, &empty_dir);
6375
}
6476

6577
install_sh(&build, "rustc", "rustc", &build.rust_package_vers(),
66-
stage, host, &prefix, &docdir, &libdir, &mandir, &empty_dir);
78+
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
79+
&mandir, &empty_dir);
6780

6881
t!(fs::remove_dir_all(&empty_dir));
6982
}
7083

7184
fn install_sh(build: &Build, package: &str, name: &str, version: &str, stage: u32, host: &str,
72-
prefix: &Path, docdir: &Path, libdir: &Path, mandir: &Path, empty_dir: &Path) {
85+
prefix: &Path, sysconfdir: &Path, docdir: &Path, bindir: &Path, libdir: &Path,
86+
mandir: &Path, empty_dir: &Path) {
7387
println!("Install {} stage{} ({})", package, stage, host);
7488
let package_name = format!("{}-{}-{}", name, version, host);
7589

7690
let mut cmd = Command::new("sh");
7791
cmd.current_dir(empty_dir)
7892
.arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
7993
.arg(format!("--prefix={}", sanitize_sh(prefix)))
94+
.arg(format!("--sysconfdir={}", sanitize_sh(sysconfdir)))
8095
.arg(format!("--docdir={}", sanitize_sh(docdir)))
96+
.arg(format!("--bindir={}", sanitize_sh(bindir)))
8197
.arg(format!("--libdir={}", sanitize_sh(libdir)))
8298
.arg(format!("--mandir={}", sanitize_sh(mandir)))
8399
.arg("--disable-ldconfig");

0 commit comments

Comments
 (0)