Use PkgType to determine which packages to add to the manifest
Previously, these had to be hard-coded (i.e. specified in both `PkgType` and `fn package`). Now they only have to be specified in `PkgType`.
This commit is contained in:
parent
494cb47852
commit
69a74955fd
2 changed files with 84 additions and 21 deletions
|
|
@ -283,28 +283,15 @@ impl Builder {
|
|||
}
|
||||
|
||||
fn add_packages_to(&mut self, manifest: &mut Manifest) {
|
||||
macro_rules! package {
|
||||
($name:expr, $targets:expr) => {
|
||||
self.package($name, &mut manifest.pkg, $targets, &[])
|
||||
};
|
||||
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,
|
||||
);
|
||||
}
|
||||
package!("rustc", HOSTS);
|
||||
package!("rustc-dev", HOSTS);
|
||||
package!("reproducible-artifacts", HOSTS);
|
||||
package!("rustc-docs", HOSTS);
|
||||
package!("cargo", HOSTS);
|
||||
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);
|
||||
package!("clippy-preview", HOSTS);
|
||||
package!("miri-preview", HOSTS);
|
||||
package!("rustfmt-preview", HOSTS);
|
||||
package!("rust-analysis", TARGETS);
|
||||
package!("llvm-tools-preview", TARGETS);
|
||||
}
|
||||
|
||||
fn add_artifacts_to(&mut self, manifest: &mut Manifest) {
|
||||
|
|
@ -500,6 +487,12 @@ impl Builder {
|
|||
targets: &[&str],
|
||||
fallback: &[(&str, &str)],
|
||||
) {
|
||||
if pkgname == "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))
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ macro_rules! pkg_type {
|
|||
}
|
||||
|
||||
impl PkgType {
|
||||
fn is_preview(&self) -> bool {
|
||||
match self {
|
||||
$( $( $($is_preview)? PkgType::$variant => true, )? )+
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_component(component: &str) -> Self {
|
||||
match component {
|
||||
$( $component $( | concat!($($is_preview)? $component, "-preview") )? => PkgType::$variant,)+
|
||||
|
|
@ -31,6 +38,11 @@ macro_rules! pkg_type {
|
|||
PkgType::Other(component) => component,
|
||||
}
|
||||
}
|
||||
|
||||
/// Component name in the manifest. In particular, this includes the `-preview` suffix where appropriate.
|
||||
pub(crate) fn all() -> &'static [PkgType] {
|
||||
&[ $(PkgType::$variant),+ ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +51,14 @@ pkg_type! {
|
|||
Rust = "rust",
|
||||
RustSrc = "rust-src",
|
||||
Rustc = "rustc",
|
||||
RustcDev = "rustc-dev",
|
||||
RustcDocs = "rustc-docs",
|
||||
ReproducibleArtifacts = "reproducible-artifacts",
|
||||
RustMingw = "rust-mingw",
|
||||
RustStd = "rust-std",
|
||||
Cargo = "cargo",
|
||||
HtmlDocs = "rust-docs",
|
||||
RustAnalysis = "rust-analysis",
|
||||
Rls = "rls"; preview = true,
|
||||
RustAnalyzer = "rust-analyzer"; preview = true,
|
||||
Clippy = "clippy"; preview = true,
|
||||
|
|
@ -50,6 +69,15 @@ pkg_type! {
|
|||
}
|
||||
|
||||
impl PkgType {
|
||||
// / Component name in the manifest. In particular, this includes the `-preview` suffix where appropriate.
|
||||
pub(crate) fn manifest_component_name(&self) -> String {
|
||||
if self.is_preview() {
|
||||
format!("{}-preview", self.tarball_component_name())
|
||||
} else {
|
||||
self.tarball_component_name().to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this package has the same version as Rust itself, or has its own `version` and
|
||||
/// `git-commit-hash` files inside the tarball.
|
||||
fn should_use_rust_version(&self) -> bool {
|
||||
|
|
@ -63,17 +91,59 @@ impl PkgType {
|
|||
PkgType::Miri => false,
|
||||
|
||||
PkgType::Rust => true,
|
||||
PkgType::RustStd => true,
|
||||
PkgType::RustSrc => true,
|
||||
PkgType::Rustc => true,
|
||||
PkgType::JsonDocs => true,
|
||||
PkgType::HtmlDocs => true,
|
||||
PkgType::RustcDev => true,
|
||||
PkgType::RustcDocs => true,
|
||||
PkgType::ReproducibleArtifacts => true,
|
||||
PkgType::RustMingw => true,
|
||||
PkgType::RustAnalysis => true,
|
||||
PkgType::Other(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn targets(&self) -> &[&str] {
|
||||
use crate::{HOSTS, MINGW, TARGETS};
|
||||
use PkgType::*;
|
||||
|
||||
match self {
|
||||
Rust => HOSTS, // doesn't matter in practice, but return something to avoid panicking
|
||||
Rustc => HOSTS,
|
||||
RustcDev => HOSTS,
|
||||
ReproducibleArtifacts => HOSTS,
|
||||
RustcDocs => HOSTS,
|
||||
Cargo => HOSTS,
|
||||
RustMingw => MINGW,
|
||||
RustStd => TARGETS,
|
||||
HtmlDocs => HOSTS,
|
||||
JsonDocs => HOSTS,
|
||||
RustSrc => &["*"],
|
||||
Rls => HOSTS,
|
||||
RustAnalyzer => HOSTS,
|
||||
Clippy => HOSTS,
|
||||
Miri => HOSTS,
|
||||
Rustfmt => HOSTS,
|
||||
RustAnalysis => TARGETS,
|
||||
LlvmTools => TARGETS,
|
||||
Other(pkg) => panic!("add {pkg} to the list of known `PkgType`s"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this package is target-independent or not.
|
||||
fn target_independent(&self) -> bool {
|
||||
*self == PkgType::RustSrc
|
||||
}
|
||||
|
||||
/// Whether to package these target-specific docs for another similar target.
|
||||
pub(crate) fn use_docs_fallback(&self) -> bool {
|
||||
match self {
|
||||
PkgType::JsonDocs | PkgType::HtmlDocs => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue