From 7da12c8541c1977757f8f0e2368d3e5ef817de84 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 16 Mar 2017 13:06:53 +1300 Subject: [PATCH 1/5] Add the RLS as a submodule --- .gitmodules | 4 ++++ rls | 1 + 2 files changed, 5 insertions(+) create mode 160000 rls diff --git a/.gitmodules b/.gitmodules index 3533f0df5d1ce..4f29cef85700e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,7 @@ [submodule "book"] path = src/doc/book url = https://github.com/rust-lang/book.git +[submodule "rls"] + path = rls + url = https://github.com/rust-lang-nursery/rls.git + diff --git a/rls b/rls new file mode 160000 index 0000000000000..e24fc84bfc4b3 --- /dev/null +++ b/rls @@ -0,0 +1 @@ +Subproject commit e24fc84bfc4b3360a3d65d9adeab0f701140094d From c55325e0f7252d67bda60695497751b63f51931d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 17 Mar 2017 09:52:12 +1300 Subject: [PATCH 2/5] Build an RLS package as part of the dist target --- src/bootstrap/dist.rs | 93 ++++++++++++++++++++++++++++++++++++++++++- src/bootstrap/lib.rs | 15 +++++++ src/bootstrap/step.rs | 11 +++++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 6472b1a928caf..d2c9e248e03a8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -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); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 8303a40bb6965..81ab2b0d1cef2 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1044,6 +1044,21 @@ impl Build { 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 { diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 5560b5b0333c8..d1581576957dc 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -570,6 +570,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .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 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .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 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .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") From 223b280f31622e6292653c5b5a0755657e514524 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 28 Mar 2017 08:00:46 +1300 Subject: [PATCH 3/5] Reviewer changes --- rls | 2 +- src/bootstrap/dist.rs | 59 ++++------------------------ src/bootstrap/lib.rs | 26 +++--------- src/tools/build-manifest/src/main.rs | 5 +++ 4 files changed, 19 insertions(+), 73 deletions(-) diff --git a/rls b/rls index e24fc84bfc4b3..88fc39bd654c5 160000 --- a/rls +++ b/rls @@ -1 +1 @@ -Subproject commit e24fc84bfc4b3360a3d65d9adeab0f701140094d +Subproject commit 88fc39bd654c536b4f8f1cd1fc8245706f0284ec diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index d2c9e248e03a8..88a3441d42015 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -40,7 +40,7 @@ fn pkgname(build: &Build, component: &str) -> String { if component == "cargo" { format!("{}-{}", component, build.cargo_package_vers()) } else { - assert!(component.starts_with("rust")); + assert!(component.starts_with("rust") || component == "rls"); format!("{}-{}", component, build.rust_package_vers()) } } @@ -540,7 +540,7 @@ pub fn cargo(build: &Build, stage: u32, target: &str) { let src = build.src.join("cargo"); let etc = src.join("src/etc"); - let release_num = build.cargo_release_num(); + let release_num = build.release_num("cargo"); let name = pkgname(build, "cargo"); let version = build.cargo_info.version(build, &release_num); @@ -599,7 +599,7 @@ pub fn rls(build: &Build, stage: u32, target: &str) { let compiler = Compiler::new(stage, &build.config.build); let src = build.src.join("rls"); - let release_num = build.rls_release_num(); + let release_num = build.release_num("rls"); let name = format!("rls-{}", build.package_vers(&release_num)); let tmp = tmpdir(build); @@ -642,8 +642,9 @@ 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 rls_installer = dist.join(format!("{}-{}.tar.gz", + pkgname(build, "rls"), + target)); let analysis_installer = dist.join(format!("{}-{}.tar.gz", pkgname(build, "rust-analysis"), target)); @@ -720,8 +721,6 @@ 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"))); @@ -729,10 +728,6 @@ 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)), @@ -740,8 +735,6 @@ 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); @@ -755,8 +748,6 @@ pub fn extended(build: &Build, stage: u32, target: &str) { }; pkgbuild("rustc"); pkgbuild("cargo"); - pkgbuild("rls"); - pkgbuild("rust-analysis"); pkgbuild("rust-docs"); pkgbuild("rust-std"); @@ -782,8 +773,6 @@ 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)) @@ -792,12 +781,6 @@ 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")); @@ -807,8 +790,6 @@ 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"))); @@ -865,26 +846,6 @@ 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") @@ -925,8 +886,6 @@ 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) @@ -944,8 +903,6 @@ 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()); @@ -968,8 +925,6 @@ 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); @@ -1037,7 +992,7 @@ pub fn hash_and_sign(build: &Build) { cmd.arg(distdir(build)); cmd.arg(today.trim()); cmd.arg(build.rust_package_vers()); - cmd.arg(build.package_vers(&build.cargo_release_num())); + cmd.arg(build.package_vers(&build.release_num("cargo"))); cmd.arg(addr); t!(fs::create_dir_all(distdir(build))); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 81ab2b0d1cef2..f9981f76ad845 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1017,7 +1017,7 @@ impl Build { /// Returns the value of `package_vers` above for Cargo fn cargo_package_vers(&self) -> String { - self.package_vers(&self.cargo_release_num()) + self.package_vers(&self.release_num("cargo")) } /// Returns the `version` string associated with this compiler for Rust @@ -1029,10 +1029,11 @@ impl Build { self.rust_info.version(self, channel::CFG_RELEASE_NUM) } - /// Returns the `a.b.c` version that Cargo is at. - fn cargo_release_num(&self) -> String { + /// Returns the `a.b.c` version that the given package is at. + fn release_num(&self, package: &str) -> String { let mut toml = String::new(); - t!(t!(File::open(self.src.join("cargo/Cargo.toml"))).read_to_string(&mut toml)); + let toml_file_name = self.src.join(&format!("{}/Cargo.toml", package)); + t!(t!(File::open(toml_file_name)).read_to_string(&mut toml)); for line in toml.lines() { let prefix = "version = \""; let suffix = "\""; @@ -1041,22 +1042,7 @@ impl Build { } } - 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") + panic!("failed to find version in {}'s Cargo.toml", package) } /// Returns whether unstable features should be enabled for the compiler diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index adddd7b7e89b0..eab2dc75af8d0 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -225,6 +225,7 @@ impl Builder { self.package("rust-src", &mut manifest.pkg, &["*"]); if self.rust_release == "nightly" { + self.package("rls", &mut manifest.pkg, HOSTS); self.package("rust-analysis", &mut manifest.pkg, TARGETS); } @@ -277,6 +278,10 @@ impl Builder { pkg: "rust-analysis".to_string(), target: target.to_string(), }); + extensions.push(Component { + pkg: "rls".to_string(), + target: host.to_string(), + }); } } extensions.push(Component { From 5766d526a250c92792ec877a65003d43683c94e5 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 5 Apr 2017 11:34:14 +1200 Subject: [PATCH 4/5] Remove --enable-save-analysis configure flag --- cargo | 2 +- configure | 1 - rls | 2 +- src/bootstrap/config.rs | 4 ---- src/bootstrap/config.toml.example | 3 --- src/bootstrap/dist.rs | 8 +++----- src/bootstrap/install.rs | 5 ----- src/bootstrap/lib.rs | 2 +- src/ci/run.sh | 1 - 9 files changed, 6 insertions(+), 22 deletions(-) diff --git a/cargo b/cargo index 4729175045b41..4e95c6b41eca3 160000 --- a/cargo +++ b/cargo @@ -1 +1 @@ -Subproject commit 4729175045b41b688ab903120860866ce7a22ba9 +Subproject commit 4e95c6b41eca3388f54dd5f7787366ad2df637b5 diff --git a/configure b/configure index d6dded6dc5f7b..35b376d5f27b8 100755 --- a/configure +++ b/configure @@ -445,7 +445,6 @@ opt dist-host-only 0 "only install bins for the host architecture" opt inject-std-version 1 "inject the current compiler version of libstd into programs" opt llvm-version-check 1 "check if the LLVM version is supported, build anyway" opt codegen-tests 1 "run the src/test/codegen tests" -opt save-analysis 0 "save API analysis data" opt option-checking 1 "complain about unrecognized options in this configure script" opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)" opt locked-deps 0 "force Cargo.lock to be up to date" diff --git a/rls b/rls index 88fc39bd654c5..016cbc514cf44 160000 --- a/rls +++ b/rls @@ -1 +1 @@ -Subproject commit 88fc39bd654c536b4f8f1cd1fc8245706f0284ec +Subproject commit 016cbc514cf44a2bd3fe806e8afa6b9c50287373 diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 52ebf401aefd6..693114d01ad9c 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -74,7 +74,6 @@ pub struct Config { pub rustc_default_ar: Option, pub rust_optimize_tests: bool, pub rust_debuginfo_tests: bool, - pub rust_save_analysis: bool, pub rust_dist_src: bool, pub build: String, @@ -226,7 +225,6 @@ struct Rust { optimize_tests: Option, debuginfo_tests: Option, codegen_tests: Option, - save_analysis: Option, } /// TOML representation of how each build target is configured. @@ -352,7 +350,6 @@ impl Config { set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); - set(&mut config.rust_save_analysis, rust.save_analysis); set(&mut config.rust_rpath, rust.rpath); set(&mut config.debug_jemalloc, rust.debug_jemalloc); set(&mut config.use_jemalloc, rust.use_jemalloc); @@ -460,7 +457,6 @@ impl Config { ("LOCAL_REBUILD", self.local_rebuild), ("NINJA", self.ninja), ("CODEGEN_TESTS", self.codegen_tests), - ("SAVE_ANALYSIS", self.rust_save_analysis), ("LOCKED_DEPS", self.locked_deps), ("VENDOR", self.vendor), ("FULL_BOOTSTRAP", self.full_bootstrap), diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 6b2cc6eb6474c..fad79022043e3 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -234,9 +234,6 @@ # saying that the FileCheck executable is missing, you may want to disable this. #codegen-tests = true -# Flag indicating whether the API analysis data should be saved. -#save-analysis = false - # ============================================================================= # Options for specific targets # diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 88a3441d42015..e786d69555a10 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -315,15 +315,12 @@ pub fn rust_src_location(build: &Build) -> PathBuf { /// Creates a tarball of save-analysis metadata, if available. pub fn analysis(build: &Build, compiler: &Compiler, target: &str) { - if !build.config.rust_save_analysis { - return - } - + assert!(build.config.extended); println!("Dist analysis"); if compiler.host != build.config.build { println!("\tskipping, not a build host"); - return + return; } // Package save-analysis from stage1 if not doing a full bootstrap, as the @@ -595,6 +592,7 @@ pub fn cargo(build: &Build, stage: u32, target: &str) { } pub fn rls(build: &Build, stage: u32, target: &str) { + assert!(build.config.extended); println!("Dist RLS stage{} ({})", stage, target); let compiler = Compiler::new(stage, &build.config.build); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 25082e3a9d095..d508616e4b1cc 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -55,11 +55,6 @@ pub fn install(build: &Build, stage: u32, host: &str) { &docdir, &libdir, &mandir, &empty_dir); } - if build.config.rust_save_analysis { - install_sh(&build, "analysis", "rust-analysis", 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)); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f9981f76ad845..e91664ac8aba7 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -545,7 +545,7 @@ impl Build { .env(format!("CFLAGS_{}", target), self.cflags(target).join(" ")); } - if self.config.rust_save_analysis && compiler.is_final_stage(self) { + if self.config.extended && compiler.is_final_stage(self) { cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string()); } diff --git a/src/ci/run.sh b/src/ci/run.sh index 6c6a49ada15d9..c6510120b47ae 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -42,7 +42,6 @@ fi if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=nightly" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-save-analysis" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" From 13d008d1e8b671e78c92e61b42ae7b82f5736121 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 10 Apr 2017 11:22:38 -0700 Subject: [PATCH 5/5] Touch up rls integration * Use the right version when building combined installer * Update dependencies of rls as it depends on rustc and plugins * Fix build-manifest and the versions it uses for the rls --- cargo | 2 +- src/bootstrap/dist.rs | 18 ++++++++++++-- src/bootstrap/lib.rs | 3 +++ src/bootstrap/step.rs | 9 +++++-- src/tools/build-manifest/src/main.rs | 35 ++++++++++++++++------------ 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/cargo b/cargo index 4e95c6b41eca3..4729175045b41 160000 --- a/cargo +++ b/cargo @@ -1 +1 @@ -Subproject commit 4e95c6b41eca3388f54dd5f7787366ad2df637b5 +Subproject commit 4729175045b41b688ab903120860866ce7a22ba9 diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e786d69555a10..4328c4e3f1d4c 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -39,8 +39,10 @@ use util::{cp_r, libdir, is_dylib, cp_filtered, copy, exe}; fn pkgname(build: &Build, component: &str) -> String { if component == "cargo" { format!("{}-{}", component, build.cargo_package_vers()) + } else if component == "rls" { + format!("{}-{}", component, build.package_vers(&build.release_num("rls"))) } else { - assert!(component.starts_with("rust") || component == "rls"); + assert!(component.starts_with("rust")); format!("{}-{}", component, build.rust_package_vers()) } } @@ -598,7 +600,8 @@ pub fn rls(build: &Build, stage: u32, target: &str) { let src = build.src.join("rls"); let release_num = build.release_num("rls"); - let name = format!("rls-{}", build.package_vers(&release_num)); + let name = pkgname(build, "rls"); + let version = build.rls_info.version(build, &release_num); let tmp = tmpdir(build); let image = tmp.join("rls-image"); @@ -614,6 +617,15 @@ pub fn rls(build: &Build, stage: u32, target: &str) { install(&src.join("LICENSE-MIT"), &doc, 0o644); install(&src.join("LICENSE-APACHE"), &doc, 0o644); + // Prepare the overlay + let overlay = tmp.join("rls-overlay"); + drop(fs::remove_dir_all(&overlay)); + t!(fs::create_dir_all(&overlay)); + install(&src.join("README.md"), &overlay, 0o644); + install(&src.join("LICENSE-MIT"), &overlay, 0o644); + install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); + // Generate the installer tarball let mut cmd = Command::new("sh"); cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) @@ -623,6 +635,7 @@ pub fn rls(build: &Build, stage: u32, target: &str) { .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!("--non-installed-overlay={}", sanitize_sh(&overlay))) .arg(format!("--package-name={}-{}", name, target)) .arg("--component-name=rls") .arg("--legacy-manifest-dirs=rustlib,cargo"); @@ -991,6 +1004,7 @@ pub fn hash_and_sign(build: &Build) { cmd.arg(today.trim()); cmd.arg(build.rust_package_vers()); cmd.arg(build.package_vers(&build.release_num("cargo"))); + cmd.arg(build.package_vers(&build.release_num("rls"))); cmd.arg(addr); t!(fs::create_dir_all(distdir(build))); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index e91664ac8aba7..d711b63ea2e26 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -151,6 +151,7 @@ pub struct Build { out: PathBuf, rust_info: channel::GitInfo, cargo_info: channel::GitInfo, + rls_info: channel::GitInfo, local_rebuild: bool, // Probed tools at runtime @@ -234,6 +235,7 @@ impl Build { }; let rust_info = channel::GitInfo::new(&src); let cargo_info = channel::GitInfo::new(&src.join("cargo")); + let rls_info = channel::GitInfo::new(&src.join("rls")); let src_is_git = src.join(".git").exists(); Build { @@ -246,6 +248,7 @@ impl Build { rust_info: rust_info, cargo_info: cargo_info, + rls_info: rls_info, local_rebuild: local_rebuild, cc: HashMap::new(), cxx: HashMap::new(), diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index d1581576957dc..596cbcf01bb80 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -572,7 +572,13 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .run(move |s| compile::tool(build, s.stage, s.target, "cargo")); rules.build("tool-rls", "rls") .host(true) - .dep(|s| s.name("libstd")) + .dep(|s| s.name("librustc")) + .dep(move |s| { + // rls, like cargo, uses procedural macros + s.name("librustc-link") + .target(&build.config.build) + .host(&build.config.build) + }) .run(move |s| compile::tool(build, s.stage, s.target, "rls")); // ======================================================================== @@ -695,7 +701,6 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .run(move |s| dist::docs(build, s.stage, s.target)); rules.dist("dist-analysis", "analysis") .dep(|s| s.name("dist-std")) - .default(true) .only_host_build(true) .run(move |s| dist::analysis(build, &s.compiler(), s.target)); rules.dist("dist-rls", "rls") diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index eab2dc75af8d0..248f3d49f0935 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -135,6 +135,7 @@ macro_rules! t { struct Builder { rust_release: String, cargo_release: String, + rls_release: String, input: PathBuf, output: PathBuf, gpg_passphrase: String, @@ -143,6 +144,7 @@ struct Builder { date: String, rust_version: String, cargo_version: String, + rls_version: String, } fn main() { @@ -152,6 +154,7 @@ fn main() { let date = args.next().unwrap(); let rust_release = args.next().unwrap(); let cargo_release = args.next().unwrap(); + let rls_release = args.next().unwrap(); let s3_address = args.next().unwrap(); let mut passphrase = String::new(); t!(io::stdin().read_to_string(&mut passphrase)); @@ -159,6 +162,7 @@ fn main() { Builder { rust_release: rust_release, cargo_release: cargo_release, + rls_release: rls_release, input: input, output: output, gpg_passphrase: passphrase, @@ -167,6 +171,7 @@ fn main() { date: date, rust_version: String::new(), cargo_version: String::new(), + rls_version: String::new(), }.build(); } @@ -174,6 +179,7 @@ impl Builder { fn build(&mut self) { self.rust_version = self.version("rust", "x86_64-unknown-linux-gnu"); self.cargo_version = self.version("cargo", "x86_64-unknown-linux-gnu"); + self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu"); self.digest_and_sign(); let Manifest { manifest_version, date, pkg } = self.build_manifest(); @@ -223,11 +229,8 @@ impl Builder { self.package("rust-std", &mut manifest.pkg, TARGETS); self.package("rust-docs", &mut manifest.pkg, TARGETS); self.package("rust-src", &mut manifest.pkg, &["*"]); - - if self.rust_release == "nightly" { - self.package("rls", &mut manifest.pkg, HOSTS); - self.package("rust-analysis", &mut manifest.pkg, TARGETS); - } + self.package("rls", &mut manifest.pkg, HOSTS); + self.package("rust-analysis", &mut manifest.pkg, TARGETS); let mut pkg = Package { version: self.cached_version("rust").to_string(), @@ -266,6 +269,14 @@ impl Builder { }); } + extensions.push(Component { + pkg: "rls".to_string(), + target: host.to_string(), + }); + extensions.push(Component { + pkg: "rust-analysis".to_string(), + target: host.to_string(), + }); for target in TARGETS { if target != host { extensions.push(Component { @@ -273,16 +284,6 @@ impl Builder { target: target.to_string(), }); } - if self.rust_release == "nightly" { - extensions.push(Component { - pkg: "rust-analysis".to_string(), - target: target.to_string(), - }); - extensions.push(Component { - pkg: "rls".to_string(), - target: host.to_string(), - }); - } } extensions.push(Component { pkg: "rust-src".to_string(), @@ -348,6 +349,8 @@ impl Builder { format!("rust-src-{}.tar.gz", self.rust_release) } else if component == "cargo" { format!("cargo-{}-{}.tar.gz", self.cargo_release, target) + } else if component == "rls" { + format!("rls-{}-{}.tar.gz", self.rls_release, target) } else { format!("{}-{}-{}.tar.gz", component, self.rust_release, target) } @@ -356,6 +359,8 @@ impl Builder { fn cached_version(&self, component: &str) -> &str { if component == "cargo" { &self.cargo_version + } else if component == "rls" { + &self.rls_version } else { &self.rust_version }