@@ -17,6 +17,13 @@ macro_rules! pkg_type {
1717 }
1818
1919 impl PkgType {
20+ fn is_preview( & self ) -> bool {
21+ match self {
22+ $( $( $( $is_preview) ? PkgType :: $variant => true , ) ? ) +
23+ _ => false ,
24+ }
25+ }
26+
2027 pub ( crate ) fn from_component( component: & str ) -> Self {
2128 match component {
2229 $( $component $( | concat!( $( $is_preview) ? $component, "-preview" ) ) ? => PkgType :: $variant, ) +
@@ -31,6 +38,11 @@ macro_rules! pkg_type {
3138 PkgType :: Other ( component) => component,
3239 }
3340 }
41+
42+ /// Component name in the manifest. In particular, this includes the `-preview` suffix where appropriate.
43+ pub ( crate ) fn all( ) -> & ' static [ PkgType ] {
44+ & [ $( PkgType :: $variant) ,+ ]
45+ }
3446 }
3547 }
3648}
@@ -39,7 +51,14 @@ pkg_type! {
3951 Rust = "rust" ,
4052 RustSrc = "rust-src" ,
4153 Rustc = "rustc" ,
54+ RustcDev = "rustc-dev" ,
55+ RustcDocs = "rustc-docs" ,
56+ ReproducibleArtifacts = "reproducible-artifacts" ,
57+ RustMingw = "rust-mingw" ,
58+ RustStd = "rust-std" ,
4259 Cargo = "cargo" ,
60+ HtmlDocs = "rust-docs" ,
61+ RustAnalysis = "rust-analysis" ,
4362 Rls = "rls" ; preview = true ,
4463 RustAnalyzer = "rust-analyzer" ; preview = true ,
4564 Clippy = "clippy" ; preview = true ,
@@ -50,6 +69,15 @@ pkg_type! {
5069}
5170
5271impl PkgType {
72+ // / Component name in the manifest. In particular, this includes the `-preview` suffix where appropriate.
73+ pub ( crate ) fn manifest_component_name ( & self ) -> String {
74+ if self . is_preview ( ) {
75+ format ! ( "{}-preview" , self . tarball_component_name( ) )
76+ } else {
77+ self . tarball_component_name ( ) . to_string ( )
78+ }
79+ }
80+
5381 /// Whether this package has the same version as Rust itself, or has its own `version` and
5482 /// `git-commit-hash` files inside the tarball.
5583 fn should_use_rust_version ( & self ) -> bool {
@@ -63,17 +91,59 @@ impl PkgType {
6391 PkgType :: Miri => false ,
6492
6593 PkgType :: Rust => true ,
94+ PkgType :: RustStd => true ,
6695 PkgType :: RustSrc => true ,
6796 PkgType :: Rustc => true ,
6897 PkgType :: JsonDocs => true ,
98+ PkgType :: HtmlDocs => true ,
99+ PkgType :: RustcDev => true ,
100+ PkgType :: RustcDocs => true ,
101+ PkgType :: ReproducibleArtifacts => true ,
102+ PkgType :: RustMingw => true ,
103+ PkgType :: RustAnalysis => true ,
69104 PkgType :: Other ( _) => true ,
70105 }
71106 }
72107
108+ pub ( crate ) fn targets ( & self ) -> & [ & str ] {
109+ use crate :: { HOSTS , MINGW , TARGETS } ;
110+ use PkgType :: * ;
111+
112+ match self {
113+ Rust => HOSTS , // doesn't matter in practice, but return something to avoid panicking
114+ Rustc => HOSTS ,
115+ RustcDev => HOSTS ,
116+ ReproducibleArtifacts => HOSTS ,
117+ RustcDocs => HOSTS ,
118+ Cargo => HOSTS ,
119+ RustMingw => MINGW ,
120+ RustStd => TARGETS ,
121+ HtmlDocs => HOSTS ,
122+ JsonDocs => HOSTS ,
123+ RustSrc => & [ "*" ] ,
124+ Rls => HOSTS ,
125+ RustAnalyzer => HOSTS ,
126+ Clippy => HOSTS ,
127+ Miri => HOSTS ,
128+ Rustfmt => HOSTS ,
129+ RustAnalysis => TARGETS ,
130+ LlvmTools => TARGETS ,
131+ Other ( pkg) => panic ! ( "add {pkg} to the list of known `PkgType`s" ) ,
132+ }
133+ }
134+
73135 /// Whether this package is target-independent or not.
74136 fn target_independent ( & self ) -> bool {
75137 * self == PkgType :: RustSrc
76138 }
139+
140+ /// Whether to package these target-specific docs for another similar target.
141+ pub ( crate ) fn use_docs_fallback ( & self ) -> bool {
142+ match self {
143+ PkgType :: JsonDocs | PkgType :: HtmlDocs => true ,
144+ _ => false ,
145+ }
146+ }
77147}
78148
79149#[ derive( Debug , Default , Clone ) ]
0 commit comments