From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/build-manifest/src/main.rs | 55 +++++++++++++++----------------- src/tools/build-manifest/src/versions.rs | 19 +++++------ 2 files changed, 33 insertions(+), 41 deletions(-) (limited to 'src/tools/build-manifest') diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 1a6760d8c..b0006cb90 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -11,9 +11,9 @@ mod versions; use crate::checksum::Checksums; use crate::manifest::{Component, Manifest, Package, Rename, Target}; use crate::versions::{PkgType, Versions}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, HashSet}; use std::env; -use std::fs::{self, File}; +use std::fs; use std::path::{Path, PathBuf}; static HOSTS: &[&str] = &[ @@ -184,7 +184,7 @@ static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin" static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"]; -static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview"]; +static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-docs-json-preview"]; macro_rules! t { ($e:expr) => { @@ -193,6 +193,12 @@ macro_rules! t { Err(e) => panic!("{} failed with {}", stringify!($e), e), } }; + ($e:expr, $extra:expr) => { + match $e { + Ok(e) => e, + Err(e) => panic!("{} failed with {}: {}", stringify!($e), e, $extra), + } + }; } struct Builder { @@ -239,7 +245,6 @@ fn main() { impl Builder { fn build(&mut self) { - self.check_toolstate(); let manifest = self.build_manifest(); let channel = self.versions.channel().to_string(); @@ -261,29 +266,6 @@ impl Builder { t!(self.checksums.store_cache()); } - /// If a tool does not pass its tests on *any* of Linux and Windows, don't ship - /// it on *all* targets, because tools like Miri can "cross-run" programs for - /// different targets, for example, run a program for `x86_64-pc-windows-msvc` - /// on `x86_64-unknown-linux-gnu`. - /// Right now, we do this only for Miri. - fn check_toolstate(&mut self) { - for file in &["toolstates-linux.json", "toolstates-windows.json"] { - let toolstates: Option> = File::open(self.input.join(file)) - .ok() - .and_then(|f| serde_json::from_reader(&f).ok()); - let toolstates = toolstates.unwrap_or_else(|| { - println!("WARNING: `{}` missing/malformed; assuming all tools failed", file); - HashMap::default() // Use empty map if anything went wrong. - }); - // Mark some tools as missing based on toolstate. - if toolstates.get("miri").map(|s| &*s as &str) != Some("test-pass") { - println!("Miri tests are not passing, removing component"); - self.versions.disable_version(&PkgType::Miri); - break; - } - } - } - fn build_manifest(&mut self) -> Manifest { let mut manifest = Manifest { manifest_version: "2".to_string(), @@ -318,6 +300,7 @@ impl Builder { package!("rust-mingw", MINGW); package!("rust-std", TARGETS); self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK); + self.package("rust-docs-json-preview", &mut manifest.pkg, HOSTS, DOCS_FALLBACK); package!("rust-src", &["*"]); package!("rls-preview", HOSTS); package!("rust-analyzer-preview", HOSTS); @@ -403,6 +386,7 @@ impl Builder { rename("rustfmt", "rustfmt-preview"); rename("clippy", "clippy-preview"); rename("miri", "miri-preview"); + rename("rust-docs-json", "rust-docs-json-preview"); rename("rust-analyzer", "rust-analyzer-preview"); } @@ -459,6 +443,7 @@ impl Builder { host_component("rustfmt-preview"), host_component("llvm-tools-preview"), host_component("rust-analysis"), + host_component("rust-docs-json-preview"), ]); extensions.extend( @@ -543,8 +528,18 @@ impl Builder { for (substr, fallback_target) in fallback { if target_name.contains(substr) { let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target)); - // Fallbacks must always be available. - assert!(t.available); + // Fallbacks should typically be available on 'production' builds + // but may not be available for try builds, which only build one target by + // default. Ideally we'd gate this being a hard error on whether we're in a + // production build or not, but it's not information that's readily available + // here. + if !t.available { + eprintln!( + "{:?} not available for fallback", + tarball_name!(fallback_target) + ); + continue; + } return t; } } @@ -595,7 +590,7 @@ impl Builder { self.shipped_files.insert(name.clone()); let dst = self.output.join(name); - t!(fs::write(&dst, contents)); + t!(fs::write(&dst, contents), format!("failed to create manifest {}", dst.display())); } fn write_shipped_files(&self, path: &Path) { diff --git a/src/tools/build-manifest/src/versions.rs b/src/tools/build-manifest/src/versions.rs index 95c2297de..0186194a4 100644 --- a/src/tools/build-manifest/src/versions.rs +++ b/src/tools/build-manifest/src/versions.rs @@ -20,6 +20,7 @@ pub(crate) enum PkgType { Rustfmt, LlvmTools, Miri, + JsonDocs, Other(String), } @@ -36,6 +37,7 @@ impl PkgType { "rustfmt" | "rustfmt-preview" => PkgType::Rustfmt, "llvm-tools" | "llvm-tools-preview" => PkgType::LlvmTools, "miri" | "miri-preview" => PkgType::Miri, + "rust-docs-json" | "rust-docs-json-preview" => PkgType::JsonDocs, other => PkgType::Other(other.into()), } } @@ -53,6 +55,7 @@ impl PkgType { PkgType::Rustfmt => "rustfmt", PkgType::LlvmTools => "llvm-tools", PkgType::Miri => "miri", + PkgType::JsonDocs => "rust-docs-json", PkgType::Other(component) => component, } } @@ -72,6 +75,7 @@ impl PkgType { PkgType::Rust => true, PkgType::RustSrc => true, PkgType::Rustc => true, + PkgType::JsonDocs => true, PkgType::Other(_) => true, } } @@ -113,6 +117,9 @@ impl Versions { Some(version) => Ok(version.clone()), None => { let version_info = self.load_version_from_tarball(package)?; + if *package == PkgType::Rust && version_info.version.is_none() { + panic!("missing version info for toolchain"); + } self.versions.insert(package.clone(), version_info.clone()); Ok(version_info) } @@ -127,6 +134,7 @@ impl Versions { Ok(file) => file, Err(err) if err.kind() == std::io::ErrorKind::NotFound => { // Missing tarballs do not return an error, but return empty data. + println!("warning: missing tarball {}", tarball.display()); return Ok(VersionInfo::default()); } Err(err) => return Err(err.into()), @@ -157,17 +165,6 @@ impl Versions { Ok(VersionInfo { version, git_commit, present: true }) } - pub(crate) fn disable_version(&mut self, package: &PkgType) { - match self.versions.get_mut(package) { - Some(version) => { - *version = VersionInfo::default(); - } - None => { - self.versions.insert(package.clone(), VersionInfo::default()); - } - } - } - pub(crate) fn archive_name( &self, package: &PkgType, -- cgit v1.2.3