@@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir};
2222
2323use builder:: { Builder , RunConfig , ShouldRun , Step } ;
2424use cache:: Interned ;
25+ use config:: Config ;
2526
2627pub fn install_docs ( builder : & Builder , stage : u32 , host : Interned < String > ) {
2728 install_sh ( builder, "docs" , "rust-docs" , stage, Some ( host) ) ;
@@ -144,6 +145,19 @@ macro_rules! install {
144145 pub host: Interned <String >,
145146 }
146147
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+
147161 impl Step for $name {
148162 type Output = ( ) ;
149163 const DEFAULT : bool = true ;
@@ -185,39 +199,34 @@ install!((self, builder, _config),
185199 install_std( builder, self . stage, * target) ;
186200 }
187201 } ;
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 , {
190203 builder. ensure( dist:: Cargo { stage: self . stage, target: self . target } ) ;
191204 install_cargo( builder, self . stage, self . target) ;
192205 } ;
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 , {
195207 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 ) {
197209 install_rls( builder, self . stage, self . target) ;
198210 } else {
199211 println!( "skipping Install RLS stage{} ({})" , self . stage, self . target) ;
200212 }
201213 } ;
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 , {
204215 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 ) {
206217 install_rustfmt( builder, self . stage, self . target) ;
207218 } else {
208219 println!( "skipping Install Rustfmt stage{} ({})" , self . stage, self . target) ;
209220 }
210221 } ;
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 , {
213223 builder. ensure( dist:: Analysis {
214224 compiler: builder. compiler( self . stage, self . host) ,
215225 target: self . target
216226 } ) ;
217227 install_analysis( builder, self . stage, self . target) ;
218228 } ;
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 , {
221230 builder. ensure( dist:: Src ) ;
222231 install_src( builder, self . stage) ;
223232 } , ONLY_BUILD ;
0 commit comments