Skip to content

Commit

Permalink
Reviewer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Apr 9, 2017
1 parent c55325e commit 223b280
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 73 deletions.
2 changes: 1 addition & 1 deletion rls
Submodule rls updated from e24fc8 to 88fc39
59 changes: 7 additions & 52 deletions src/bootstrap/dist.rs
Expand Up @@ -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())
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -720,28 +721,20 @@ 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")));

cp_r(&work.join(&format!("{}-{}", pkgname(build, "rustc"), target)),
&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)),
&pkg.join("rust-std"));

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);

Expand All @@ -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");

Expand All @@ -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))
Expand All @@ -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"));
Expand All @@ -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")));

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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());

Expand All @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
26 changes: 6 additions & 20 deletions src/bootstrap/lib.rs
Expand Up @@ -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
Expand All @@ -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 = "\"";
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/tools/build-manifest/src/main.rs
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 223b280

Please sign in to comment.