Rollup merge of #42067 - Keruspe:master, r=alexcrichton
rustbuild: install improvements Install rust-analysis and rust-src to get in par with what we can get from rustup. Allow bypassing the vendoring of dependencies. When we only build to install and not to redistribute dist tarballs, that part is not necessary, so avoid trying to install cargo-vendor.
This commit is contained in:
commit
abd1a000ee
@ -21,83 +21,110 @@ use std::process::Command;
|
||||
use Build;
|
||||
use dist::{sanitize_sh, tmpdir};
|
||||
|
||||
/// Installs everything.
|
||||
pub fn install(build: &Build, stage: u32, host: &str) {
|
||||
let prefix_default = PathBuf::from("/usr/local");
|
||||
let sysconfdir_default = PathBuf::from("/etc");
|
||||
let docdir_default = PathBuf::from("share/doc/rust");
|
||||
let bindir_default = PathBuf::from("bin");
|
||||
let libdir_default = PathBuf::from("lib");
|
||||
let mandir_default = PathBuf::from("share/man");
|
||||
let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default);
|
||||
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
|
||||
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
|
||||
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
|
||||
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
|
||||
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);
|
||||
|
||||
let sysconfdir = prefix.join(sysconfdir);
|
||||
let docdir = prefix.join(docdir);
|
||||
let bindir = prefix.join(bindir);
|
||||
let libdir = prefix.join(libdir);
|
||||
let mandir = prefix.join(mandir);
|
||||
|
||||
let destdir = env::var_os("DESTDIR").map(PathBuf::from);
|
||||
|
||||
let prefix = add_destdir(&prefix, &destdir);
|
||||
let sysconfdir = add_destdir(&sysconfdir, &destdir);
|
||||
let docdir = add_destdir(&docdir, &destdir);
|
||||
let bindir = add_destdir(&bindir, &destdir);
|
||||
let libdir = add_destdir(&libdir, &destdir);
|
||||
let mandir = add_destdir(&mandir, &destdir);
|
||||
|
||||
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", &build.rust_package_vers(),
|
||||
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
|
||||
&mandir, &empty_dir);
|
||||
}
|
||||
|
||||
for target in build.config.target.iter() {
|
||||
install_sh(&build, "std", "rust-std", &build.rust_package_vers(),
|
||||
stage, target, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
|
||||
&mandir, &empty_dir);
|
||||
}
|
||||
|
||||
if build.config.extended {
|
||||
install_sh(&build, "cargo", "cargo", &build.cargo_package_vers(),
|
||||
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
|
||||
&mandir, &empty_dir);
|
||||
install_sh(&build, "rls", "rls", &build.rls_package_vers(),
|
||||
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
|
||||
&mandir, &empty_dir);
|
||||
}
|
||||
|
||||
install_sh(&build, "rustc", "rustc", &build.rust_package_vers(),
|
||||
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
|
||||
&mandir, &empty_dir);
|
||||
|
||||
t!(fs::remove_dir_all(&empty_dir));
|
||||
pub struct Installer<'a> {
|
||||
build: &'a Build,
|
||||
prefix: PathBuf,
|
||||
sysconfdir: PathBuf,
|
||||
docdir: PathBuf,
|
||||
bindir: PathBuf,
|
||||
libdir: PathBuf,
|
||||
mandir: PathBuf,
|
||||
}
|
||||
|
||||
fn install_sh(build: &Build, package: &str, name: &str, version: &str, stage: u32, host: &str,
|
||||
prefix: &Path, sysconfdir: &Path, docdir: &Path, bindir: &Path, libdir: &Path,
|
||||
mandir: &Path, empty_dir: &Path) {
|
||||
println!("Install {} stage{} ({})", package, stage, host);
|
||||
let package_name = format!("{}-{}-{}", name, version, host);
|
||||
impl<'a> Installer<'a> {
|
||||
pub fn new(build: &'a Build) -> Installer<'a> {
|
||||
let prefix_default = PathBuf::from("/usr/local");
|
||||
let sysconfdir_default = PathBuf::from("/etc");
|
||||
let docdir_default = PathBuf::from("share/doc/rust");
|
||||
let bindir_default = PathBuf::from("bin");
|
||||
let libdir_default = PathBuf::from("lib");
|
||||
let mandir_default = PathBuf::from("share/man");
|
||||
let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default);
|
||||
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
|
||||
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
|
||||
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
|
||||
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
|
||||
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);
|
||||
|
||||
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!("--sysconfdir={}", sanitize_sh(sysconfdir)))
|
||||
.arg(format!("--docdir={}", sanitize_sh(docdir)))
|
||||
.arg(format!("--bindir={}", sanitize_sh(bindir)))
|
||||
.arg(format!("--libdir={}", sanitize_sh(libdir)))
|
||||
.arg(format!("--mandir={}", sanitize_sh(mandir)))
|
||||
.arg("--disable-ldconfig");
|
||||
build.run(&mut cmd);
|
||||
let sysconfdir = prefix.join(sysconfdir);
|
||||
let docdir = prefix.join(docdir);
|
||||
let bindir = prefix.join(bindir);
|
||||
let libdir = prefix.join(libdir);
|
||||
let mandir = prefix.join(mandir);
|
||||
|
||||
let destdir = env::var_os("DESTDIR").map(PathBuf::from);
|
||||
|
||||
let prefix = add_destdir(&prefix, &destdir);
|
||||
let sysconfdir = add_destdir(&sysconfdir, &destdir);
|
||||
let docdir = add_destdir(&docdir, &destdir);
|
||||
let bindir = add_destdir(&bindir, &destdir);
|
||||
let libdir = add_destdir(&libdir, &destdir);
|
||||
let mandir = add_destdir(&mandir, &destdir);
|
||||
|
||||
Installer {
|
||||
build,
|
||||
prefix,
|
||||
sysconfdir,
|
||||
docdir,
|
||||
bindir,
|
||||
libdir,
|
||||
mandir,
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs everything.
|
||||
pub fn install(&self, stage: u32, host: &str) {
|
||||
let empty_dir = self.build.out.join("tmp/empty_dir");
|
||||
t!(fs::create_dir_all(&empty_dir));
|
||||
|
||||
if self.build.config.docs {
|
||||
self.install_sh("docs", "rust-docs", &self.build.rust_package_vers(),
|
||||
stage, Some(host), &empty_dir);
|
||||
}
|
||||
|
||||
for target in self.build.config.target.iter() {
|
||||
self.install_sh("std", "rust-std", &self.build.rust_package_vers(),
|
||||
stage, Some(target), &empty_dir);
|
||||
}
|
||||
|
||||
if self.build.config.extended {
|
||||
self.install_sh("cargo", "cargo", &self.build.cargo_package_vers(),
|
||||
stage, Some(host), &empty_dir);
|
||||
self.install_sh("rls", "rls", &self.build.rls_package_vers(),
|
||||
stage, Some(host), &empty_dir);
|
||||
self.install_sh("analysis", "rust-analysis", &self.build.rust_package_vers(),
|
||||
stage, Some(host), &empty_dir);
|
||||
self.install_sh("src", "rust-src", &self.build.rust_package_vers(),
|
||||
stage, None, &empty_dir);
|
||||
}
|
||||
|
||||
self.install_sh("rustc", "rustc", &self.build.rust_package_vers(),
|
||||
stage, Some(host), &empty_dir);
|
||||
|
||||
t!(fs::remove_dir_all(&empty_dir));
|
||||
}
|
||||
|
||||
fn install_sh(&self, package: &str, name: &str, version: &str,
|
||||
stage: u32, host: Option<&str>, empty_dir: &Path) {
|
||||
println!("Install {} stage{} ({:?})", package, stage, host);
|
||||
let package_name = if let Some(host) = host {
|
||||
format!("{}-{}-{}", name, version, host)
|
||||
} else {
|
||||
format!("{}-{}", name, version)
|
||||
};
|
||||
|
||||
let mut cmd = Command::new("sh");
|
||||
cmd.current_dir(empty_dir)
|
||||
.arg(sanitize_sh(&tmpdir(self.build).join(&package_name).join("install.sh")))
|
||||
.arg(format!("--prefix={}", sanitize_sh(&self.prefix)))
|
||||
.arg(format!("--sysconfdir={}", sanitize_sh(&self.sysconfdir)))
|
||||
.arg(format!("--docdir={}", sanitize_sh(&self.docdir)))
|
||||
.arg(format!("--bindir={}", sanitize_sh(&self.bindir)))
|
||||
.arg(format!("--libdir={}", sanitize_sh(&self.libdir)))
|
||||
.arg(format!("--mandir={}", sanitize_sh(&self.mandir)))
|
||||
.arg("--disable-ldconfig");
|
||||
self.build.run(&mut cmd);
|
||||
}
|
||||
}
|
||||
|
||||
fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
|
||||
|
@ -761,7 +761,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
|
||||
.run(move |s| dist::rls(build, s.stage, s.target));
|
||||
rules.dist("install", "path/to/nowhere")
|
||||
.dep(|s| s.name("default:dist"))
|
||||
.run(move |s| install::install(build, s.stage, s.target));
|
||||
.run(move |s| install::Installer::new(build).install(s.stage, s.target));
|
||||
rules.dist("dist-cargo", "cargo")
|
||||
.host(true)
|
||||
.only_host_build(true)
|
||||
|
Loading…
Reference in New Issue
Block a user