Skip to content

Commit bed9a85

Browse files
committed
Auto merge of rust-lang#45570 - nrc:manifest-no-rls, r=alexcrichton
Don't fail to build a manifest if a tarball is missing This is guesswork because I can't test build_manifest nor do I know what is actually causing the error to begin with. My hypothesis is that when we try to find the version from the RLS tarball and the tarball is not there, then we panic. I attempt to fix this by making the version string optional, then not adding the RLS package, rename, and extension component if the version is missing. In theory, this should fix the broken nightlies. r? @alexcrichton
2 parents f7b080b + 9c87aca commit bed9a85

File tree

1 file changed

+37
-26
lines changed
  • src/tools/build-manifest/src

1 file changed

+37
-26
lines changed

src/tools/build-manifest/src/main.rs

+37-26
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
extern crate toml;
1212
#[macro_use]
1313
extern crate serde_derive;
14-
extern crate serde;
1514

1615
use std::collections::BTreeMap;
1716
use std::env;
@@ -175,9 +174,9 @@ struct Builder {
175174
digests: BTreeMap<String, String>,
176175
s3_address: String,
177176
date: String,
178-
rust_version: String,
179-
cargo_version: String,
180-
rls_version: String,
177+
rust_version: Option<String>,
178+
cargo_version: Option<String>,
179+
rls_version: Option<String>,
181180
rust_git_commit_hash: Option<String>,
182181
cargo_git_commit_hash: Option<String>,
183182
rls_git_commit_hash: Option<String>,
@@ -205,9 +204,9 @@ fn main() {
205204
digests: BTreeMap::new(),
206205
s3_address,
207206
date,
208-
rust_version: String::new(),
209-
cargo_version: String::new(),
210-
rls_version: String::new(),
207+
rust_version: None,
208+
cargo_version: None,
209+
rls_version: None,
211210
rust_git_commit_hash: None,
212211
cargo_git_commit_hash: None,
213212
rls_git_commit_hash: None,
@@ -258,10 +257,17 @@ impl Builder {
258257
self.package("rls-preview", &mut manifest.pkg, HOSTS);
259258
self.package("rust-analysis", &mut manifest.pkg, TARGETS);
260259

261-
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
260+
let rls_present = manifest.pkg.contains_key("rls-preview");
261+
262+
if rls_present {
263+
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
264+
}
262265

263266
let mut pkg = Package {
264-
version: self.cached_version("rust").to_string(),
267+
version: self.cached_version("rust")
268+
.as_ref()
269+
.expect("Couldn't find Rust version")
270+
.clone(),
265271
git_commit_hash: self.cached_git_commit_hash("rust").clone(),
266272
target: BTreeMap::new(),
267273
};
@@ -294,10 +300,12 @@ impl Builder {
294300
});
295301
}
296302

297-
extensions.push(Component {
298-
pkg: "rls-preview".to_string(),
299-
target: host.to_string(),
300-
});
303+
if rls_present {
304+
extensions.push(Component {
305+
pkg: "rls-preview".to_string(),
306+
target: host.to_string(),
307+
});
308+
}
301309
extensions.push(Component {
302310
pkg: "rust-analysis".to_string(),
303311
target: host.to_string(),
@@ -334,6 +342,14 @@ impl Builder {
334342
pkgname: &str,
335343
dst: &mut BTreeMap<String, Package>,
336344
targets: &[&str]) {
345+
let version = match *self.cached_version(pkgname) {
346+
Some(ref version) => version.clone(),
347+
None => {
348+
println!("Skipping package {}", pkgname);
349+
return;
350+
}
351+
};
352+
337353
let targets = targets.iter().map(|name| {
338354
let filename = self.filename(pkgname, name);
339355
let digest = match self.digests.remove(&filename) {
@@ -355,7 +371,7 @@ impl Builder {
355371
}).collect();
356372

357373
dst.insert(pkgname.to_string(), Package {
358-
version: self.cached_version(pkgname).to_string(),
374+
version,
359375
git_commit_hash: self.cached_git_commit_hash(pkgname).clone(),
360376
target: targets,
361377
});
@@ -380,7 +396,7 @@ impl Builder {
380396
}
381397
}
382398

383-
fn cached_version(&self, component: &str) -> &str {
399+
fn cached_version(&self, component: &str) -> &Option<String> {
384400
if component == "cargo" {
385401
&self.cargo_version
386402
} else if component == "rls" || component == "rls-preview" {
@@ -400,21 +416,20 @@ impl Builder {
400416
}
401417
}
402418

403-
fn version(&self, component: &str, target: &str) -> String {
419+
fn version(&self, component: &str, target: &str) -> Option<String> {
404420
let mut cmd = Command::new("tar");
405421
let filename = self.filename(component, target);
406422
cmd.arg("xf")
407423
.arg(self.input.join(&filename))
408424
.arg(format!("{}/version", filename.replace(".tar.gz", "")))
409425
.arg("-O");
410426
let output = t!(cmd.output());
411-
if !output.status.success() {
412-
panic!("failed to learn version:\n\n{:?}\n\n{}\n\n{}",
413-
cmd,
414-
String::from_utf8_lossy(&output.stdout),
415-
String::from_utf8_lossy(&output.stderr));
427+
if output.status.success() {
428+
Some(String::from_utf8_lossy(&output.stdout).trim().to_string())
429+
} else {
430+
// Perhaps we didn't build this package.
431+
None
416432
}
417-
String::from_utf8_lossy(&output.stdout).trim().to_string()
418433
}
419434

420435
fn git_commit_hash(&self, component: &str, target: &str) -> Option<String> {
@@ -428,10 +443,6 @@ impl Builder {
428443
if output.status.success() {
429444
Some(String::from_utf8_lossy(&output.stdout).trim().to_string())
430445
} else {
431-
// This is always called after `.version()`.
432-
// So if that didn’t fail but this does,
433-
// that’s very probably because the tarball is valid
434-
// but does not contain a `git-commit-hash` file.
435446
None
436447
}
437448
}

0 commit comments

Comments
 (0)