@@ -17,6 +17,13 @@ macro_rules! pkg_type {
17
17
}
18
18
19
19
impl PkgType {
20
+ fn is_preview( & self ) -> bool {
21
+ match self {
22
+ $( $( $( $is_preview) ? PkgType :: $variant => true , ) ? ) +
23
+ _ => false ,
24
+ }
25
+ }
26
+
20
27
pub ( crate ) fn from_component( component: & str ) -> Self {
21
28
match component {
22
29
$( $component $( | concat!( $( $is_preview) ? $component, "-preview" ) ) ? => PkgType :: $variant, ) +
@@ -31,6 +38,11 @@ macro_rules! pkg_type {
31
38
PkgType :: Other ( component) => component,
32
39
}
33
40
}
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
+ }
34
46
}
35
47
}
36
48
}
@@ -39,7 +51,14 @@ pkg_type! {
39
51
Rust = "rust" ,
40
52
RustSrc = "rust-src" ,
41
53
Rustc = "rustc" ,
54
+ RustcDev = "rustc-dev" ,
55
+ RustcDocs = "rustc-docs" ,
56
+ ReproducibleArtifacts = "reproducible-artifacts" ,
57
+ RustMingw = "rust-mingw" ,
58
+ RustStd = "rust-std" ,
42
59
Cargo = "cargo" ,
60
+ HtmlDocs = "rust-docs" ,
61
+ RustAnalysis = "rust-analysis" ,
43
62
Rls = "rls" ; preview = true ,
44
63
RustAnalyzer = "rust-analyzer" ; preview = true ,
45
64
Clippy = "clippy" ; preview = true ,
@@ -50,6 +69,15 @@ pkg_type! {
50
69
}
51
70
52
71
impl 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
+
53
81
/// Whether this package has the same version as Rust itself, or has its own `version` and
54
82
/// `git-commit-hash` files inside the tarball.
55
83
fn should_use_rust_version ( & self ) -> bool {
@@ -63,17 +91,59 @@ impl PkgType {
63
91
PkgType :: Miri => false ,
64
92
65
93
PkgType :: Rust => true ,
94
+ PkgType :: RustStd => true ,
66
95
PkgType :: RustSrc => true ,
67
96
PkgType :: Rustc => true ,
68
97
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 ,
69
104
PkgType :: Other ( _) => true ,
70
105
}
71
106
}
72
107
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
+
73
135
/// Whether this package is target-independent or not.
74
136
fn target_independent ( & self ) -> bool {
75
137
* self == PkgType :: RustSrc
76
138
}
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
+ }
77
147
}
78
148
79
149
#[ derive( Debug , Default , Clone ) ]
0 commit comments