mirror of
https://github.com/rust-lang/rust
synced 2024-07-21 02:15:40 +00:00
Build an RLS package as part of the dist target
This commit is contained in:
parent
7da12c8541
commit
c55325e0f7
|
@ -393,6 +393,7 @@ pub fn rust_src(build: &Build) {
|
|||
"man",
|
||||
"src",
|
||||
"cargo",
|
||||
"rls",
|
||||
];
|
||||
|
||||
let filter_fn = move |path: &Path| {
|
||||
|
@ -593,6 +594,43 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {
|
|||
build.run(&mut cmd);
|
||||
}
|
||||
|
||||
pub fn rls(build: &Build, stage: u32, target: &str) {
|
||||
println!("Dist RLS stage{} ({})", stage, target);
|
||||
let compiler = Compiler::new(stage, &build.config.build);
|
||||
|
||||
let src = build.src.join("rls");
|
||||
let release_num = build.rls_release_num();
|
||||
let name = format!("rls-{}", build.package_vers(&release_num));
|
||||
|
||||
let tmp = tmpdir(build);
|
||||
let image = tmp.join("rls-image");
|
||||
drop(fs::remove_dir_all(&image));
|
||||
t!(fs::create_dir_all(&image));
|
||||
|
||||
// Prepare the image directory
|
||||
let rls = build.cargo_out(&compiler, Mode::Tool, target)
|
||||
.join(exe("rls", target));
|
||||
install(&rls, &image.join("bin"), 0o755);
|
||||
let doc = image.join("share/doc/rls");
|
||||
install(&src.join("README.md"), &doc, 0o644);
|
||||
install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
||||
install(&src.join("LICENSE-APACHE"), &doc, 0o644);
|
||||
|
||||
// Generate the installer tarball
|
||||
let mut cmd = Command::new("sh");
|
||||
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
|
||||
.arg("--product-name=Rust")
|
||||
.arg("--rel-manifest-dir=rustlib")
|
||||
.arg("--success-message=RLS-ready-to-serve.")
|
||||
.arg(format!("--image-dir={}", sanitize_sh(&image)))
|
||||
.arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
|
||||
.arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
|
||||
.arg(format!("--package-name={}-{}", name, target))
|
||||
.arg("--component-name=rls")
|
||||
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
||||
build.run(&mut cmd);
|
||||
}
|
||||
|
||||
/// Creates a combined installer for the specified target in the provided stage.
|
||||
pub fn extended(build: &Build, stage: u32, target: &str) {
|
||||
println!("Dist extended stage{} ({})", stage, target);
|
||||
|
@ -604,6 +642,11 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
let cargo_installer = dist.join(format!("{}-{}.tar.gz",
|
||||
pkgname(build, "cargo"),
|
||||
target));
|
||||
let rls_installer = dist.join(format!("{}.tar.gz",
|
||||
pkgname(build, "rls")));
|
||||
let analysis_installer = dist.join(format!("{}-{}.tar.gz",
|
||||
pkgname(build, "rust-analysis"),
|
||||
target));
|
||||
let docs_installer = dist.join(format!("{}-{}.tar.gz",
|
||||
pkgname(build, "rust-docs"),
|
||||
target));
|
||||
|
@ -631,9 +674,11 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
|
||||
// the std files during uninstall. To do this ensure that rustc comes
|
||||
// before rust-std in the list below.
|
||||
let mut input_tarballs = format!("{},{},{},{}",
|
||||
let mut input_tarballs = format!("{},{},{},{},{},{}",
|
||||
sanitize_sh(&rustc_installer),
|
||||
sanitize_sh(&cargo_installer),
|
||||
sanitize_sh(&rls_installer),
|
||||
sanitize_sh(&analysis_installer),
|
||||
sanitize_sh(&docs_installer),
|
||||
sanitize_sh(&std_installer));
|
||||
if target.contains("pc-windows-gnu") {
|
||||
|
@ -675,6 +720,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
let _ = fs::remove_dir_all(&pkg);
|
||||
t!(fs::create_dir_all(pkg.join("rustc")));
|
||||
t!(fs::create_dir_all(pkg.join("cargo")));
|
||||
t!(fs::create_dir_all(pkg.join("rls")));
|
||||
t!(fs::create_dir_all(pkg.join("rust-analysis")));
|
||||
t!(fs::create_dir_all(pkg.join("rust-docs")));
|
||||
t!(fs::create_dir_all(pkg.join("rust-std")));
|
||||
|
||||
|
@ -682,6 +729,10 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
&pkg.join("rustc"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "cargo"), target)),
|
||||
&pkg.join("cargo"));
|
||||
cp_r(&work.join(pkgname(build, "rls")),
|
||||
&pkg.join("rls"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target)),
|
||||
&pkg.join("rust-analysis"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-docs"), target)),
|
||||
&pkg.join("rust-docs"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-std"), target)),
|
||||
|
@ -689,6 +740,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("rustc"), 0o755);
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("cargo"), 0o755);
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("rls"), 0o755);
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("rust-analysis"), 0o755);
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("rust-docs"), 0o755);
|
||||
install(&etc.join("pkg/postinstall"), &pkg.join("rust-std"), 0o755);
|
||||
|
||||
|
@ -702,6 +755,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
};
|
||||
pkgbuild("rustc");
|
||||
pkgbuild("cargo");
|
||||
pkgbuild("rls");
|
||||
pkgbuild("rust-analysis");
|
||||
pkgbuild("rust-docs");
|
||||
pkgbuild("rust-std");
|
||||
|
||||
|
@ -727,6 +782,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
let _ = fs::remove_dir_all(&exe);
|
||||
t!(fs::create_dir_all(exe.join("rustc")));
|
||||
t!(fs::create_dir_all(exe.join("cargo")));
|
||||
t!(fs::create_dir_all(exe.join("rls")));
|
||||
t!(fs::create_dir_all(exe.join("rust-analysis")));
|
||||
t!(fs::create_dir_all(exe.join("rust-docs")));
|
||||
t!(fs::create_dir_all(exe.join("rust-std")));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rustc"), target))
|
||||
|
@ -735,6 +792,12 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "cargo"), target))
|
||||
.join("cargo"),
|
||||
&exe.join("cargo"));
|
||||
cp_r(&work.join(pkgname(build, "rls"))
|
||||
.join("rls"),
|
||||
&exe.join("rls"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target))
|
||||
.join("rust-analysis"),
|
||||
&exe.join("rust-analysis"));
|
||||
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-docs"), target))
|
||||
.join("rust-docs"),
|
||||
&exe.join("rust-docs"));
|
||||
|
@ -744,6 +807,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
|
||||
t!(fs::remove_file(exe.join("rustc/manifest.in")));
|
||||
t!(fs::remove_file(exe.join("cargo/manifest.in")));
|
||||
t!(fs::remove_file(exe.join("rls/manifest.in")));
|
||||
t!(fs::remove_file(exe.join("rust-analysis/manifest.in")));
|
||||
t!(fs::remove_file(exe.join("rust-docs/manifest.in")));
|
||||
t!(fs::remove_file(exe.join("rust-std/manifest.in")));
|
||||
|
||||
|
@ -800,6 +865,26 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
.arg("-var").arg("var.DocsDir")
|
||||
.arg("-out").arg(exe.join("DocsGroup.wxs"))
|
||||
.arg("-t").arg(etc.join("msi/squash-components.xsl")));
|
||||
build.run(Command::new(&heat)
|
||||
.current_dir(&exe)
|
||||
.arg("dir")
|
||||
.arg("rls")
|
||||
.args(&heat_flags)
|
||||
.arg("-cg").arg("RlsGroup")
|
||||
.arg("-dr").arg("Rls")
|
||||
.arg("-var").arg("var.RlsDir")
|
||||
.arg("-out").arg(exe.join("RlsGroup.wxs"))
|
||||
.arg("-t").arg(etc.join("msi/squash-components.xsl")));
|
||||
build.run(Command::new(&heat)
|
||||
.current_dir(&exe)
|
||||
.arg("dir")
|
||||
.arg("rust-analysis")
|
||||
.args(&heat_flags)
|
||||
.arg("-cg").arg("AnalysisGroup")
|
||||
.arg("-dr").arg("Analysis")
|
||||
.arg("-var").arg("var.AnalysisDir")
|
||||
.arg("-out").arg(exe.join("AnalysisGroup.wxs"))
|
||||
.arg("-t").arg(etc.join("msi/squash-components.xsl")));
|
||||
build.run(Command::new(&heat)
|
||||
.current_dir(&exe)
|
||||
.arg("dir")
|
||||
|
@ -840,6 +925,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
.arg("-nologo")
|
||||
.arg("-dRustcDir=rustc")
|
||||
.arg("-dDocsDir=rust-docs")
|
||||
.arg("-dRlsDir=rls")
|
||||
.arg("-dAnalysisDir=rust-analysis")
|
||||
.arg("-dCargoDir=cargo")
|
||||
.arg("-dStdDir=rust-std")
|
||||
.arg("-arch").arg(&arch)
|
||||
|
@ -857,6 +944,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
candle(&etc.join("msi/rustwelcomedlg.wxs"));
|
||||
candle("RustcGroup.wxs".as_ref());
|
||||
candle("DocsGroup.wxs".as_ref());
|
||||
candle("RlsGroup.wxs".as_ref());
|
||||
candle("AnalysisGroup.wxs".as_ref());
|
||||
candle("CargoGroup.wxs".as_ref());
|
||||
candle("StdGroup.wxs".as_ref());
|
||||
|
||||
|
@ -879,6 +968,8 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
|
|||
.arg("rustwelcomedlg.wixobj")
|
||||
.arg("RustcGroup.wixobj")
|
||||
.arg("DocsGroup.wixobj")
|
||||
.arg("RlsGroup.wixobj")
|
||||
.arg("AnalysisGroup.wixobj")
|
||||
.arg("CargoGroup.wixobj")
|
||||
.arg("StdGroup.wixobj")
|
||||
.current_dir(&exe);
|
||||
|
|
|
@ -1044,6 +1044,21 @@ fn cargo_release_num(&self) -> String {
|
|||
panic!("failed to find version in cargo's Cargo.toml")
|
||||
}
|
||||
|
||||
/// Returns the `a.b.c` version that the RLS is at.
|
||||
fn rls_release_num(&self) -> String {
|
||||
let mut toml = String::new();
|
||||
t!(t!(File::open(self.src.join("rls/Cargo.toml"))).read_to_string(&mut toml));
|
||||
for line in toml.lines() {
|
||||
let prefix = "version = \"";
|
||||
let suffix = "\"";
|
||||
if line.starts_with(prefix) && line.ends_with(suffix) {
|
||||
return line[prefix.len()..line.len() - suffix.len()].to_string()
|
||||
}
|
||||
}
|
||||
|
||||
panic!("failed to find version in the RLS's Cargo.toml")
|
||||
}
|
||||
|
||||
/// Returns whether unstable features should be enabled for the compiler
|
||||
/// we're building.
|
||||
fn unstable_features(&self) -> bool {
|
||||
|
|
|
@ -570,6 +570,10 @@ fn crate_rule<'a, 'b>(build: &'a Build,
|
|||
.host(&build.config.build)
|
||||
})
|
||||
.run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
|
||||
rules.build("tool-rls", "rls")
|
||||
.host(true)
|
||||
.dep(|s| s.name("libstd"))
|
||||
.run(move |s| compile::tool(build, s.stage, s.target, "rls"));
|
||||
|
||||
// ========================================================================
|
||||
// Documentation targets
|
||||
|
@ -694,6 +698,11 @@ fn crate_rule<'a, 'b>(build: &'a Build,
|
|||
.default(true)
|
||||
.only_host_build(true)
|
||||
.run(move |s| dist::analysis(build, &s.compiler(), s.target));
|
||||
rules.dist("dist-rls", "rls")
|
||||
.host(true)
|
||||
.only_host_build(true)
|
||||
.dep(|s| s.name("tool-rls"))
|
||||
.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));
|
||||
|
@ -711,6 +720,8 @@ fn crate_rule<'a, 'b>(build: &'a Build,
|
|||
.dep(|d| d.name("dist-mingw"))
|
||||
.dep(|d| d.name("dist-docs"))
|
||||
.dep(|d| d.name("dist-cargo"))
|
||||
.dep(|d| d.name("dist-rls"))
|
||||
.dep(|d| d.name("dist-analysis"))
|
||||
.run(move |s| dist::extended(build, s.stage, s.target));
|
||||
|
||||
rules.dist("dist-sign", "hash-and-sign")
|
||||
|
|
Loading…
Reference in a new issue