Skip to content

Commit b36dfb0

Browse files
committed
Auto merge of #40584 - nrc:rls-submod, r=alexcrichton
Add the RLS as a submodule and build a package out of it r? @brson (and cc @alexcrichton) Please review closely, I am not at all convinced I've done the right things here. I did run `x.py dist` and it makes an rls package which looks right to my eyes, but I haven't tested on non-linux platforms nor am I really sure what it should look like. This does not attempt to run tests for the RLS yet.
2 parents 3b5754e + 99656e9 commit b36dfb0

File tree

11 files changed

+118
-38
lines changed

11 files changed

+118
-38
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
[submodule "book"]
2727
path = src/doc/book
2828
url = https://github.com/rust-lang/book.git
29+
[submodule "rls"]
30+
path = rls
31+
url = https://github.com/rust-lang-nursery/rls.git
32+

configure

-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ opt dist-host-only 0 "only install bins for the host architecture"
445445
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
446446
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
447447
opt codegen-tests 1 "run the src/test/codegen tests"
448-
opt save-analysis 0 "save API analysis data"
449448
opt option-checking 1 "complain about unrecognized options in this configure script"
450449
opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
451450
opt locked-deps 0 "force Cargo.lock to be up to date"

rls

Submodule rls added at 016cbc5

src/bootstrap/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub struct Config {
7474
pub rustc_default_ar: Option<String>,
7575
pub rust_optimize_tests: bool,
7676
pub rust_debuginfo_tests: bool,
77-
pub rust_save_analysis: bool,
7877
pub rust_dist_src: bool,
7978

8079
pub build: String,
@@ -226,7 +225,6 @@ struct Rust {
226225
optimize_tests: Option<bool>,
227226
debuginfo_tests: Option<bool>,
228227
codegen_tests: Option<bool>,
229-
save_analysis: Option<bool>,
230228
}
231229

232230
/// TOML representation of how each build target is configured.
@@ -352,7 +350,6 @@ impl Config {
352350
set(&mut config.rust_optimize_tests, rust.optimize_tests);
353351
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
354352
set(&mut config.codegen_tests, rust.codegen_tests);
355-
set(&mut config.rust_save_analysis, rust.save_analysis);
356353
set(&mut config.rust_rpath, rust.rpath);
357354
set(&mut config.debug_jemalloc, rust.debug_jemalloc);
358355
set(&mut config.use_jemalloc, rust.use_jemalloc);
@@ -460,7 +457,6 @@ impl Config {
460457
("LOCAL_REBUILD", self.local_rebuild),
461458
("NINJA", self.ninja),
462459
("CODEGEN_TESTS", self.codegen_tests),
463-
("SAVE_ANALYSIS", self.rust_save_analysis),
464460
("LOCKED_DEPS", self.locked_deps),
465461
("VENDOR", self.vendor),
466462
("FULL_BOOTSTRAP", self.full_bootstrap),

src/bootstrap/config.toml.example

-3
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@
234234
# saying that the FileCheck executable is missing, you may want to disable this.
235235
#codegen-tests = true
236236

237-
# Flag indicating whether the API analysis data should be saved.
238-
#save-analysis = false
239-
240237
# =============================================================================
241238
# Options for specific targets
242239
#

src/bootstrap/dist.rs

+66-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ use util::{cp_r, libdir, is_dylib, cp_filtered, copy, exe};
3939
fn pkgname(build: &Build, component: &str) -> String {
4040
if component == "cargo" {
4141
format!("{}-{}", component, build.cargo_package_vers())
42+
} else if component == "rls" {
43+
format!("{}-{}", component, build.package_vers(&build.release_num("rls")))
4244
} else {
4345
assert!(component.starts_with("rust"));
4446
format!("{}-{}", component, build.rust_package_vers())
@@ -315,15 +317,12 @@ pub fn rust_src_location(build: &Build) -> PathBuf {
315317

316318
/// Creates a tarball of save-analysis metadata, if available.
317319
pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
318-
if !build.config.rust_save_analysis {
319-
return
320-
}
321-
320+
assert!(build.config.extended);
322321
println!("Dist analysis");
323322

324323
if compiler.host != build.config.build {
325324
println!("\tskipping, not a build host");
326-
return
325+
return;
327326
}
328327

329328
// Package save-analysis from stage1 if not doing a full bootstrap, as the
@@ -393,6 +392,7 @@ pub fn rust_src(build: &Build) {
393392
"man",
394393
"src",
395394
"cargo",
395+
"rls",
396396
];
397397

398398
let filter_fn = move |path: &Path| {
@@ -539,7 +539,7 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {
539539

540540
let src = build.src.join("cargo");
541541
let etc = src.join("src/etc");
542-
let release_num = build.cargo_release_num();
542+
let release_num = build.release_num("cargo");
543543
let name = pkgname(build, "cargo");
544544
let version = build.cargo_info.version(build, &release_num);
545545

@@ -593,6 +593,55 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {
593593
build.run(&mut cmd);
594594
}
595595

596+
pub fn rls(build: &Build, stage: u32, target: &str) {
597+
assert!(build.config.extended);
598+
println!("Dist RLS stage{} ({})", stage, target);
599+
let compiler = Compiler::new(stage, &build.config.build);
600+
601+
let src = build.src.join("rls");
602+
let release_num = build.release_num("rls");
603+
let name = pkgname(build, "rls");
604+
let version = build.rls_info.version(build, &release_num);
605+
606+
let tmp = tmpdir(build);
607+
let image = tmp.join("rls-image");
608+
drop(fs::remove_dir_all(&image));
609+
t!(fs::create_dir_all(&image));
610+
611+
// Prepare the image directory
612+
let rls = build.cargo_out(&compiler, Mode::Tool, target)
613+
.join(exe("rls", target));
614+
install(&rls, &image.join("bin"), 0o755);
615+
let doc = image.join("share/doc/rls");
616+
install(&src.join("README.md"), &doc, 0o644);
617+
install(&src.join("LICENSE-MIT"), &doc, 0o644);
618+
install(&src.join("LICENSE-APACHE"), &doc, 0o644);
619+
620+
// Prepare the overlay
621+
let overlay = tmp.join("rls-overlay");
622+
drop(fs::remove_dir_all(&overlay));
623+
t!(fs::create_dir_all(&overlay));
624+
install(&src.join("README.md"), &overlay, 0o644);
625+
install(&src.join("LICENSE-MIT"), &overlay, 0o644);
626+
install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
627+
t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));
628+
629+
// Generate the installer tarball
630+
let mut cmd = Command::new("sh");
631+
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
632+
.arg("--product-name=Rust")
633+
.arg("--rel-manifest-dir=rustlib")
634+
.arg("--success-message=RLS-ready-to-serve.")
635+
.arg(format!("--image-dir={}", sanitize_sh(&image)))
636+
.arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
637+
.arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
638+
.arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay)))
639+
.arg(format!("--package-name={}-{}", name, target))
640+
.arg("--component-name=rls")
641+
.arg("--legacy-manifest-dirs=rustlib,cargo");
642+
build.run(&mut cmd);
643+
}
644+
596645
/// Creates a combined installer for the specified target in the provided stage.
597646
pub fn extended(build: &Build, stage: u32, target: &str) {
598647
println!("Dist extended stage{} ({})", stage, target);
@@ -604,6 +653,12 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
604653
let cargo_installer = dist.join(format!("{}-{}.tar.gz",
605654
pkgname(build, "cargo"),
606655
target));
656+
let rls_installer = dist.join(format!("{}-{}.tar.gz",
657+
pkgname(build, "rls"),
658+
target));
659+
let analysis_installer = dist.join(format!("{}-{}.tar.gz",
660+
pkgname(build, "rust-analysis"),
661+
target));
607662
let docs_installer = dist.join(format!("{}-{}.tar.gz",
608663
pkgname(build, "rust-docs"),
609664
target));
@@ -631,9 +686,11 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
631686
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
632687
// the std files during uninstall. To do this ensure that rustc comes
633688
// before rust-std in the list below.
634-
let mut input_tarballs = format!("{},{},{},{}",
689+
let mut input_tarballs = format!("{},{},{},{},{},{}",
635690
sanitize_sh(&rustc_installer),
636691
sanitize_sh(&cargo_installer),
692+
sanitize_sh(&rls_installer),
693+
sanitize_sh(&analysis_installer),
637694
sanitize_sh(&docs_installer),
638695
sanitize_sh(&std_installer));
639696
if target.contains("pc-windows-gnu") {
@@ -946,7 +1003,8 @@ pub fn hash_and_sign(build: &Build) {
9461003
cmd.arg(distdir(build));
9471004
cmd.arg(today.trim());
9481005
cmd.arg(build.rust_package_vers());
949-
cmd.arg(build.package_vers(&build.cargo_release_num()));
1006+
cmd.arg(build.package_vers(&build.release_num("cargo")));
1007+
cmd.arg(build.package_vers(&build.release_num("rls")));
9501008
cmd.arg(addr);
9511009

9521010
t!(fs::create_dir_all(distdir(build)));

src/bootstrap/install.rs

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ pub fn install(build: &Build, stage: u32, host: &str) {
5555
&docdir, &libdir, &mandir, &empty_dir);
5656
}
5757

58-
if build.config.rust_save_analysis {
59-
install_sh(&build, "analysis", "rust-analysis", stage, host, &prefix,
60-
&docdir, &libdir, &mandir, &empty_dir);
61-
}
62-
6358
install_sh(&build, "rustc", "rustc", stage, host, &prefix,
6459
&docdir, &libdir, &mandir, &empty_dir);
6560
t!(fs::remove_dir_all(&empty_dir));

src/bootstrap/lib.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub struct Build {
151151
out: PathBuf,
152152
rust_info: channel::GitInfo,
153153
cargo_info: channel::GitInfo,
154+
rls_info: channel::GitInfo,
154155
local_rebuild: bool,
155156

156157
// Probed tools at runtime
@@ -234,6 +235,7 @@ impl Build {
234235
};
235236
let rust_info = channel::GitInfo::new(&src);
236237
let cargo_info = channel::GitInfo::new(&src.join("cargo"));
238+
let rls_info = channel::GitInfo::new(&src.join("rls"));
237239
let src_is_git = src.join(".git").exists();
238240

239241
Build {
@@ -246,6 +248,7 @@ impl Build {
246248

247249
rust_info: rust_info,
248250
cargo_info: cargo_info,
251+
rls_info: rls_info,
249252
local_rebuild: local_rebuild,
250253
cc: HashMap::new(),
251254
cxx: HashMap::new(),
@@ -545,7 +548,7 @@ impl Build {
545548
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
546549
}
547550

548-
if self.config.rust_save_analysis && compiler.is_final_stage(self) {
551+
if self.config.extended && compiler.is_final_stage(self) {
549552
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
550553
}
551554

@@ -1017,7 +1020,7 @@ impl Build {
10171020

10181021
/// Returns the value of `package_vers` above for Cargo
10191022
fn cargo_package_vers(&self) -> String {
1020-
self.package_vers(&self.cargo_release_num())
1023+
self.package_vers(&self.release_num("cargo"))
10211024
}
10221025

10231026
/// Returns the `version` string associated with this compiler for Rust
@@ -1029,10 +1032,11 @@ impl Build {
10291032
self.rust_info.version(self, channel::CFG_RELEASE_NUM)
10301033
}
10311034

1032-
/// Returns the `a.b.c` version that Cargo is at.
1033-
fn cargo_release_num(&self) -> String {
1035+
/// Returns the `a.b.c` version that the given package is at.
1036+
fn release_num(&self, package: &str) -> String {
10341037
let mut toml = String::new();
1035-
t!(t!(File::open(self.src.join("cargo/Cargo.toml"))).read_to_string(&mut toml));
1038+
let toml_file_name = self.src.join(&format!("{}/Cargo.toml", package));
1039+
t!(t!(File::open(toml_file_name)).read_to_string(&mut toml));
10361040
for line in toml.lines() {
10371041
let prefix = "version = \"";
10381042
let suffix = "\"";
@@ -1041,7 +1045,7 @@ impl Build {
10411045
}
10421046
}
10431047

1044-
panic!("failed to find version in cargo's Cargo.toml")
1048+
panic!("failed to find version in {}'s Cargo.toml", package)
10451049
}
10461050

10471051
/// Returns whether unstable features should be enabled for the compiler

src/bootstrap/step.rs

+17
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,16 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
570570
.host(&build.config.build)
571571
})
572572
.run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
573+
rules.build("tool-rls", "rls")
574+
.host(true)
575+
.dep(|s| s.name("librustc"))
576+
.dep(move |s| {
577+
// rls, like cargo, uses procedural macros
578+
s.name("librustc-link")
579+
.target(&build.config.build)
580+
.host(&build.config.build)
581+
})
582+
.run(move |s| compile::tool(build, s.stage, s.target, "rls"));
573583

574584
// ========================================================================
575585
// Documentation targets
@@ -694,6 +704,11 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
694704
.default(true)
695705
.only_host_build(true)
696706
.run(move |s| dist::analysis(build, &s.compiler(), s.target));
707+
rules.dist("dist-rls", "rls")
708+
.host(true)
709+
.only_host_build(true)
710+
.dep(|s| s.name("tool-rls"))
711+
.run(move |s| dist::rls(build, s.stage, s.target));
697712
rules.dist("install", "path/to/nowhere")
698713
.dep(|s| s.name("default:dist"))
699714
.run(move |s| install::install(build, s.stage, s.target));
@@ -711,6 +726,8 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
711726
.dep(|d| d.name("dist-mingw"))
712727
.dep(|d| d.name("dist-docs"))
713728
.dep(|d| d.name("dist-cargo"))
729+
.dep(|d| d.name("dist-rls"))
730+
.dep(|d| d.name("dist-analysis"))
714731
.run(move |s| dist::extended(build, s.stage, s.target));
715732

716733
rules.dist("dist-sign", "hash-and-sign")

src/ci/run.sh

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ fi
4242
if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
4343
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=nightly"
4444
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
45-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-save-analysis"
4645

4746
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
4847
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

0 commit comments

Comments
 (0)