@@ -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,32 +199,34 @@ install!((self, builder, _config),
185199 install_std( builder, self . stage, * target) ;
186200 }
187201 } ;
188- Cargo , "cargo" , _config. extended , only_hosts: true , {
202+ Cargo , "cargo" , Self :: should_build ( _config) , only_hosts: true , {
189203 builder. ensure( dist:: Cargo { stage: self . stage, target: self . target } ) ;
190204 install_cargo( builder, self . stage, self . target) ;
191205 } ;
192- Rls , "rls" , _config. extended, only_hosts: true , {
193- if builder. ensure( dist:: Rls { stage: self . stage, target: self . target } ) . is_some( ) {
206+ Rls , "rls" , Self :: should_build( _config) , only_hosts: true , {
207+ if builder. ensure( dist:: Rls { stage: self . stage, target: self . target } ) . is_some( ) ||
208+ Self :: should_install( builder) {
194209 install_rls( builder, self . stage, self . target) ;
195210 } else {
196211 println!( "skipping Install RLS stage{} ({})" , self . stage, self . target) ;
197212 }
198213 } ;
199- Rustfmt , "rustfmt" , _config. extended, only_hosts: true , {
200- if builder. ensure( dist:: Rustfmt { stage: self . stage, target: self . target } ) . is_some( ) {
214+ Rustfmt , "rustfmt" , Self :: should_build( _config) , only_hosts: true , {
215+ if builder. ensure( dist:: Rustfmt { stage: self . stage, target: self . target } ) . is_some( ) ||
216+ Self :: should_install( builder) {
201217 install_rustfmt( builder, self . stage, self . target) ;
202218 } else {
203219 println!( "skipping Install Rustfmt stage{} ({})" , self . stage, self . target) ;
204220 }
205221 } ;
206- Analysis , "analysis" , _config. extended , only_hosts: false , {
222+ Analysis , "analysis" , Self :: should_build ( _config) , only_hosts: false , {
207223 builder. ensure( dist:: Analysis {
208224 compiler: builder. compiler( self . stage, self . host) ,
209225 target: self . target
210226 } ) ;
211227 install_analysis( builder, self . stage, self . target) ;
212228 } ;
213- Src , "src" , _config. extended , only_hosts: true , {
229+ Src , "src" , Self :: should_build ( _config) , only_hosts: true , {
214230 builder. ensure( dist:: Src ) ;
215231 install_src( builder, self . stage) ;
216232 } , ONLY_BUILD ;
0 commit comments