Use PkgType in more places
In particular, this avoids serializing and parsing the pkg to a string, which allows getting rid of `PkgType::Other` altogether
This commit is contained in:
parent
6cbf079596
commit
1e9d2187ed
4 changed files with 27 additions and 47 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
This tool generates the manifests uploaded to static.rust-lang.org and used by rustup.
|
||||
You can see a full list of all manifests at <https://static.rust-lang.org/manifests.txt>.
|
||||
This listing is updated by <https://github.com/rust-lang/generate-manifest-list> every 7 days.
|
||||
|
||||
This gets called by `promote-release` <https://github.com/rust-lang/promote-release> via `x.py dist hash-and-sign`.
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,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", "rust-docs-json-preview"];
|
||||
static NIGHTLY_ONLY_COMPONENTS: &[PkgType] = &[PkgType::Miri, PkgType::JsonDocs];
|
||||
|
||||
macro_rules! t {
|
||||
($e:expr) => {
|
||||
|
|
@ -285,12 +285,7 @@ impl Builder {
|
|||
fn add_packages_to(&mut self, manifest: &mut Manifest) {
|
||||
for pkg in PkgType::all() {
|
||||
let fallback = if pkg.use_docs_fallback() { DOCS_FALLBACK } else { &[] };
|
||||
self.package(
|
||||
&pkg.manifest_component_name(),
|
||||
&mut manifest.pkg,
|
||||
pkg.targets(),
|
||||
fallback,
|
||||
);
|
||||
self.package(pkg, &mut manifest.pkg, fallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -401,26 +396,27 @@ impl Builder {
|
|||
let mut components = Vec::new();
|
||||
let mut extensions = Vec::new();
|
||||
|
||||
let host_component = |pkg: &_| Component::from_str(pkg, host);
|
||||
let host_component = |pkg: &_| Component::from_pkg(pkg, host);
|
||||
|
||||
for pkg in PkgType::all() {
|
||||
match pkg {
|
||||
// rustc/rust-std/cargo/docs are all required
|
||||
PkgType::Rustc | PkgType::Cargo | PkgType::HtmlDocs => {
|
||||
components.push(host_component(&pkg.manifest_component_name()));
|
||||
components.push(host_component(pkg));
|
||||
}
|
||||
PkgType::RustStd => {
|
||||
components.push(host_component(&pkg.manifest_component_name()));
|
||||
components.push(host_component(pkg));
|
||||
extensions.extend(
|
||||
TARGETS.iter().filter(|&&target| target != host).map(|target| {
|
||||
Component::from_str(&pkg.manifest_component_name(), target)
|
||||
}),
|
||||
TARGETS
|
||||
.iter()
|
||||
.filter(|&&target| target != host)
|
||||
.map(|target| Component::from_pkg(pkg, target)),
|
||||
);
|
||||
}
|
||||
// so is rust-mingw if it's available for the target
|
||||
PkgType::RustMingw => {
|
||||
if host.contains("pc-windows-gnu") {
|
||||
components.push(host_component("rust-mingw"));
|
||||
components.push(host_component(pkg));
|
||||
}
|
||||
}
|
||||
// Tools are always present in the manifest,
|
||||
|
|
@ -433,20 +429,16 @@ impl Builder {
|
|||
| PkgType::LlvmTools
|
||||
| PkgType::RustAnalysis
|
||||
| PkgType::JsonDocs => {
|
||||
extensions.push(host_component(&pkg.manifest_component_name()));
|
||||
extensions.push(host_component(pkg));
|
||||
}
|
||||
PkgType::RustcDev | PkgType::RustcDocs => {
|
||||
extensions.extend(
|
||||
HOSTS.iter().map(|target| {
|
||||
Component::from_str(&pkg.manifest_component_name(), target)
|
||||
}),
|
||||
);
|
||||
extensions.extend(HOSTS.iter().map(|target| Component::from_pkg(pkg, target)));
|
||||
}
|
||||
PkgType::RustSrc => {
|
||||
extensions.push(Component::from_str(&pkg.manifest_component_name(), "*"));
|
||||
extensions.push(Component::from_pkg(pkg, "*"));
|
||||
}
|
||||
PkgType::Rust | PkgType::Other(_) => {}
|
||||
// FIXME: is this correct? maybe we should add it so rustup knows about it ...
|
||||
PkgType::Rust => {}
|
||||
// NOTE: this is intentional, these artifacts aren't intended to be used with rustup
|
||||
PkgType::ReproducibleArtifacts => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -494,31 +486,27 @@ impl Builder {
|
|||
|
||||
fn package(
|
||||
&mut self,
|
||||
pkgname: &str,
|
||||
pkg: &PkgType,
|
||||
dst: &mut BTreeMap<String, Package>,
|
||||
targets: &[&str],
|
||||
fallback: &[(&str, &str)],
|
||||
) {
|
||||
if pkgname == "rust" {
|
||||
if *pkg == PkgType::Rust {
|
||||
// This is handled specially by `rust_package` later.
|
||||
// Order is important, so don't call `rust_package` here.
|
||||
return;
|
||||
}
|
||||
|
||||
let version_info = self
|
||||
.versions
|
||||
.version(&PkgType::from_component(pkgname))
|
||||
.expect("failed to load package version");
|
||||
let version_info = self.versions.version(&pkg).expect("failed to load package version");
|
||||
let mut is_present = version_info.present;
|
||||
|
||||
// Never ship nightly-only components for other trains.
|
||||
if self.versions.channel() != "nightly" && NIGHTLY_ONLY_COMPONENTS.contains(&pkgname) {
|
||||
if self.versions.channel() != "nightly" && NIGHTLY_ONLY_COMPONENTS.contains(&pkg) {
|
||||
is_present = false; // Pretend the component is entirely missing.
|
||||
}
|
||||
|
||||
macro_rules! tarball_name {
|
||||
($target_name:expr) => {
|
||||
self.versions.tarball_name(&PkgType::from_component(pkgname), $target_name).unwrap()
|
||||
self.versions.tarball_name(pkg, $target_name).unwrap()
|
||||
};
|
||||
}
|
||||
let mut target_from_compressed_tar = |target_name| {
|
||||
|
|
@ -547,7 +535,8 @@ impl Builder {
|
|||
Target::unavailable()
|
||||
};
|
||||
|
||||
let targets = targets
|
||||
let targets = pkg
|
||||
.targets()
|
||||
.iter()
|
||||
.map(|name| {
|
||||
let target = if is_present {
|
||||
|
|
@ -562,7 +551,7 @@ impl Builder {
|
|||
.collect();
|
||||
|
||||
dst.insert(
|
||||
pkgname.to_string(),
|
||||
pkg.manifest_component_name(),
|
||||
Package {
|
||||
version: version_info.version.unwrap_or_default(),
|
||||
git_commit_hash: version_info.git_commit,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::versions::PkgType;
|
||||
use crate::Builder;
|
||||
use serde::{Serialize, Serializer};
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -116,8 +117,8 @@ pub(crate) struct Component {
|
|||
}
|
||||
|
||||
impl Component {
|
||||
pub(crate) fn from_str(pkg: &str, target: &str) -> Self {
|
||||
Self { pkg: pkg.to_string(), target: target.to_string() }
|
||||
pub(crate) fn from_pkg(pkg: &PkgType, target: &str) -> Self {
|
||||
Self { pkg: pkg.manifest_component_name(), target: target.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ macro_rules! pkg_type {
|
|||
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
|
||||
pub(crate) enum PkgType {
|
||||
$($variant,)+
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl PkgType {
|
||||
|
|
@ -24,18 +23,10 @@ macro_rules! pkg_type {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_component(component: &str) -> Self {
|
||||
match component {
|
||||
$( $component $( | concat!($($is_preview)? $component, "-preview") )? => PkgType::$variant,)+
|
||||
_ => PkgType::Other(component.into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// First part of the tarball name.
|
||||
pub(crate) fn tarball_component_name(&self) -> &str {
|
||||
match self {
|
||||
$( PkgType::$variant => $component,)+
|
||||
PkgType::Other(component) => component,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +91,6 @@ impl PkgType {
|
|||
PkgType::ReproducibleArtifacts => true,
|
||||
PkgType::RustMingw => true,
|
||||
PkgType::RustAnalysis => true,
|
||||
PkgType::Other(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +117,6 @@ impl PkgType {
|
|||
Rustfmt => HOSTS,
|
||||
RustAnalysis => TARGETS,
|
||||
LlvmTools => TARGETS,
|
||||
Other(pkg) => panic!("add {pkg} to the list of known `PkgType`s"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue