@@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir};
22
22
23
23
use builder:: { Builder , RunConfig , ShouldRun , Step } ;
24
24
use cache:: Interned ;
25
+ use config:: Config ;
25
26
26
27
pub fn install_docs ( builder : & Builder , stage : u32 , host : Interned < String > ) {
27
28
install_sh ( builder, "docs" , "rust-docs" , stage, Some ( host) ) ;
@@ -144,6 +145,19 @@ macro_rules! install {
144
145
pub host: Interned <String >,
145
146
}
146
147
148
+ impl $name {
149
+ #[ allow( dead_code) ]
150
+ fn should_build( config: & Config ) -> bool {
151
+ config. extended && config. tools. as_ref( )
152
+ . map_or( true , |t| t. contains( $path) )
153
+ }
154
+
155
+ #[ allow( dead_code) ]
156
+ fn should_install( builder: & Builder ) -> bool {
157
+ builder. config. tools. as_ref( ) . map_or( false , |t| t. contains( $path) )
158
+ }
159
+ }
160
+
147
161
impl Step for $name {
148
162
type Output = ( ) ;
149
163
const DEFAULT : bool = true ;
@@ -185,39 +199,34 @@ install!((self, builder, _config),
185
199
install_std( builder, self . stage, * target) ;
186
200
}
187
201
} ;
188
- Cargo , "cargo" , _config. extended &&
189
- _config. tools. as_ref( ) . map_or( true , |t| t. contains( "cargo" ) ) , only_hosts: true , {
202
+ Cargo , "cargo" , Self :: should_build( _config) , only_hosts: true , {
190
203
builder. ensure( dist:: Cargo { stage: self . stage, target: self . target } ) ;
191
204
install_cargo( builder, self . stage, self . target) ;
192
205
} ;
193
- Rls , "rls" , _config. extended &&
194
- _config. tools. as_ref( ) . map_or( true , |t| t. contains( "rls" ) ) , only_hosts: true , {
206
+ Rls , "rls" , Self :: should_build( _config) , only_hosts: true , {
195
207
if builder. ensure( dist:: Rls { stage: self . stage, target: self . target } ) . is_some( ) ||
196
- builder . config . tools . as_ref ( ) . map_or ( false , |t| t . contains ( "rls" ) ) {
208
+ Self :: should_install ( builder ) {
197
209
install_rls( builder, self . stage, self . target) ;
198
210
} else {
199
211
println!( "skipping Install RLS stage{} ({})" , self . stage, self . target) ;
200
212
}
201
213
} ;
202
- Rustfmt , "rustfmt" , _config. extended &&
203
- _config. tools. as_ref( ) . map_or( true , |t| t. contains( "rustfmt" ) ) , only_hosts: true , {
214
+ Rustfmt , "rustfmt" , Self :: should_build( _config) , only_hosts: true , {
204
215
if builder. ensure( dist:: Rustfmt { stage: self . stage, target: self . target } ) . is_some( ) ||
205
- builder . config . tools . as_ref ( ) . map_or ( false , |t| t . contains ( "rustfmt" ) ) {
216
+ Self :: should_install ( builder ) {
206
217
install_rustfmt( builder, self . stage, self . target) ;
207
218
} else {
208
219
println!( "skipping Install Rustfmt stage{} ({})" , self . stage, self . target) ;
209
220
}
210
221
} ;
211
- Analysis , "analysis" , _config. extended &&
212
- _config. tools. as_ref( ) . map_or( true , |t| t. contains( "analysis" ) ) , only_hosts: false , {
222
+ Analysis , "analysis" , Self :: should_build( _config) , only_hosts: false , {
213
223
builder. ensure( dist:: Analysis {
214
224
compiler: builder. compiler( self . stage, self . host) ,
215
225
target: self . target
216
226
} ) ;
217
227
install_analysis( builder, self . stage, self . target) ;
218
228
} ;
219
- Src , "src" , _config. extended &&
220
- _config. tools. as_ref( ) . map_or( true , |t| t. contains( "src" ) ) , only_hosts: true , {
229
+ Src , "src" , Self :: should_build( _config) , only_hosts: true , {
221
230
builder. ensure( dist:: Src ) ;
222
231
install_src( builder, self . stage) ;
223
232
} , ONLY_BUILD ;
0 commit comments