@@ -543,43 +543,50 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
543543 rules. build ( "tool-rustbook" , "src/tools/rustbook" )
544544 . default ( build. config . build_all_tools )
545545 . host ( true )
546+ . only_stage ( 0 )
546547 . dep ( |s| s. name ( "maybe-clean-tools" ) )
547548 . dep ( |s| s. name ( "librustc-tool" ) )
548549 . run ( move |s| compile:: tool ( build, s. stage , s. target , "rustbook" ) ) ;
549550 rules. build ( "tool-error-index" , "src/tools/error_index_generator" )
550551 . default ( build. config . build_all_tools )
551552 . host ( true )
553+ . only_stage ( 0 )
552554 . dep ( |s| s. name ( "maybe-clean-tools" ) )
553555 . dep ( |s| s. name ( "librustc-tool" ) )
554556 . run ( move |s| compile:: tool ( build, s. stage , s. target , "error_index_generator" ) ) ;
555557 rules. build ( "tool-unstable-book-gen" , "src/tools/unstable-book-gen" )
556558 . default ( build. config . build_all_tools )
557559 . host ( true )
560+ . only_stage ( 0 )
558561 . dep ( |s| s. name ( "maybe-clean-tools" ) )
559562 . dep ( |s| s. name ( "libstd-tool" ) )
560563 . run ( move |s| compile:: tool ( build, s. stage , s. target , "unstable-book-gen" ) ) ;
561564 rules. build ( "tool-tidy" , "src/tools/tidy" )
562565 . default ( build. config . build_all_tools )
563566 . host ( true )
564567 . only_build ( true )
568+ . only_stage ( 0 )
565569 . dep ( |s| s. name ( "maybe-clean-tools" ) )
566570 . dep ( |s| s. name ( "libstd-tool" ) )
567571 . run ( move |s| compile:: tool ( build, s. stage , s. target , "tidy" ) ) ;
568572 rules. build ( "tool-linkchecker" , "src/tools/linkchecker" )
569573 . default ( build. config . build_all_tools )
570574 . host ( true )
575+ . only_stage ( 0 )
571576 . dep ( |s| s. name ( "maybe-clean-tools" ) )
572577 . dep ( |s| s. name ( "libstd-tool" ) )
573578 . run ( move |s| compile:: tool ( build, s. stage , s. target , "linkchecker" ) ) ;
574579 rules. build ( "tool-cargotest" , "src/tools/cargotest" )
575580 . default ( build. config . build_all_tools )
576581 . host ( true )
582+ . only_stage ( 0 )
577583 . dep ( |s| s. name ( "maybe-clean-tools" ) )
578584 . dep ( |s| s. name ( "libstd-tool" ) )
579585 . run ( move |s| compile:: tool ( build, s. stage , s. target , "cargotest" ) ) ;
580586 rules. build ( "tool-compiletest" , "src/tools/compiletest" )
581587 . default ( build. config . build_all_tools )
582588 . host ( true )
589+ . only_stage ( 0 )
583590 . dep ( |s| s. name ( "maybe-clean-tools" ) )
584591 . dep ( |s| s. name ( "libtest-tool" ) )
585592 . run ( move |s| compile:: tool ( build, s. stage , s. target , "compiletest" ) ) ;
@@ -588,6 +595,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
588595 . host ( true )
589596 . only_build ( true )
590597 . only_host_build ( true )
598+ . only_stage ( 0 )
591599 . dep ( |s| s. name ( "maybe-clean-tools" ) )
592600 . dep ( |s| s. name ( "libstd-tool" ) )
593601 . run ( move |s| compile:: tool ( build, s. stage , s. target , "build-manifest" ) ) ;
@@ -600,12 +608,14 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
600608 rules. build ( "tool-remote-test-client" , "src/tools/remote-test-client" )
601609 . default ( build. config . build_all_tools )
602610 . host ( true )
611+ . only_stage ( 0 )
603612 . dep ( |s| s. name ( "maybe-clean-tools" ) )
604613 . dep ( |s| s. name ( "libstd-tool" ) )
605614 . run ( move |s| compile:: tool ( build, s. stage , s. target , "remote-test-client" ) ) ;
606615 rules. build ( "tool-rust-installer" , "src/tools/rust-installer" )
607616 . default ( build. config . build_all_tools )
608617 . host ( true )
618+ . only_stage ( 0 )
609619 . dep ( |s| s. name ( "maybe-clean-tools" ) )
610620 . dep ( |s| s. name ( "libstd-tool" ) )
611621 . run ( move |s| compile:: tool ( build, s. stage , s. target , "rust-installer" ) ) ;
@@ -980,6 +990,9 @@ struct Rule<'a> {
980990 /// targets.
981991 only_build : bool ,
982992
993+ /// Whether this rule is only built for one stage (usually stage 0).
994+ only_stage : Option < u32 > ,
995+
983996 /// A list of "order only" dependencies. This rules does not actually
984997 /// depend on these rules, but if they show up in the dependency graph then
985998 /// this rule must be executed after all these rules.
@@ -1008,6 +1021,7 @@ impl<'a> Rule<'a> {
10081021 host : false ,
10091022 only_host_build : false ,
10101023 only_build : false ,
1024+ only_stage : None ,
10111025 after : Vec :: new ( ) ,
10121026 }
10131027 }
@@ -1059,6 +1073,11 @@ impl<'a, 'b> RuleBuilder<'a, 'b> {
10591073 self . rule . only_host_build = only_host_build;
10601074 self
10611075 }
1076+
1077+ fn only_stage ( & mut self , stage : u32 ) -> & mut Self {
1078+ self . rule . only_stage = Some ( stage) ;
1079+ self
1080+ }
10621081}
10631082
10641083impl < ' a , ' b > Drop for RuleBuilder < ' a , ' b > {
@@ -1225,6 +1244,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
12251244 Subcommand :: Install { ref paths } => ( Kind :: Install , & paths[ ..] ) ,
12261245 Subcommand :: Clean => panic ! ( ) ,
12271246 } ;
1247+ let current_stage = self . sbuild . stage ;
12281248
12291249 let mut rules: Vec < _ > = self . rules . values ( ) . filter_map ( |rule| {
12301250 if rule. kind != kind {
@@ -1278,7 +1298,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
12781298
12791299 hosts. iter ( ) . flat_map ( move |host| {
12801300 arr. iter ( ) . map ( move |target| {
1281- self . sbuild . name ( rule. name ) . target ( target) . host ( host)
1301+ self . sbuild . name ( rule. name )
1302+ . target ( target)
1303+ . host ( host)
1304+ . stage ( rule. only_stage . unwrap_or ( current_stage) )
12821305 } )
12831306 } )
12841307 } ) . collect ( )
0 commit comments