@@ -543,43 +543,50 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
543
543
rules. build ( "tool-rustbook" , "src/tools/rustbook" )
544
544
. default ( build. config . build_all_tools )
545
545
. host ( true )
546
+ . only_stage ( 0 )
546
547
. dep ( |s| s. name ( "maybe-clean-tools" ) )
547
548
. dep ( |s| s. name ( "librustc-tool" ) )
548
549
. run ( move |s| compile:: tool ( build, s. stage , s. target , "rustbook" ) ) ;
549
550
rules. build ( "tool-error-index" , "src/tools/error_index_generator" )
550
551
. default ( build. config . build_all_tools )
551
552
. host ( true )
553
+ . only_stage ( 0 )
552
554
. dep ( |s| s. name ( "maybe-clean-tools" ) )
553
555
. dep ( |s| s. name ( "librustc-tool" ) )
554
556
. run ( move |s| compile:: tool ( build, s. stage , s. target , "error_index_generator" ) ) ;
555
557
rules. build ( "tool-unstable-book-gen" , "src/tools/unstable-book-gen" )
556
558
. default ( build. config . build_all_tools )
557
559
. host ( true )
560
+ . only_stage ( 0 )
558
561
. dep ( |s| s. name ( "maybe-clean-tools" ) )
559
562
. dep ( |s| s. name ( "libstd-tool" ) )
560
563
. run ( move |s| compile:: tool ( build, s. stage , s. target , "unstable-book-gen" ) ) ;
561
564
rules. build ( "tool-tidy" , "src/tools/tidy" )
562
565
. default ( build. config . build_all_tools )
563
566
. host ( true )
564
567
. only_build ( true )
568
+ . only_stage ( 0 )
565
569
. dep ( |s| s. name ( "maybe-clean-tools" ) )
566
570
. dep ( |s| s. name ( "libstd-tool" ) )
567
571
. run ( move |s| compile:: tool ( build, s. stage , s. target , "tidy" ) ) ;
568
572
rules. build ( "tool-linkchecker" , "src/tools/linkchecker" )
569
573
. default ( build. config . build_all_tools )
570
574
. host ( true )
575
+ . only_stage ( 0 )
571
576
. dep ( |s| s. name ( "maybe-clean-tools" ) )
572
577
. dep ( |s| s. name ( "libstd-tool" ) )
573
578
. run ( move |s| compile:: tool ( build, s. stage , s. target , "linkchecker" ) ) ;
574
579
rules. build ( "tool-cargotest" , "src/tools/cargotest" )
575
580
. default ( build. config . build_all_tools )
576
581
. host ( true )
582
+ . only_stage ( 0 )
577
583
. dep ( |s| s. name ( "maybe-clean-tools" ) )
578
584
. dep ( |s| s. name ( "libstd-tool" ) )
579
585
. run ( move |s| compile:: tool ( build, s. stage , s. target , "cargotest" ) ) ;
580
586
rules. build ( "tool-compiletest" , "src/tools/compiletest" )
581
587
. default ( build. config . build_all_tools )
582
588
. host ( true )
589
+ . only_stage ( 0 )
583
590
. dep ( |s| s. name ( "maybe-clean-tools" ) )
584
591
. dep ( |s| s. name ( "libtest-tool" ) )
585
592
. run ( move |s| compile:: tool ( build, s. stage , s. target , "compiletest" ) ) ;
@@ -588,6 +595,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
588
595
. host ( true )
589
596
. only_build ( true )
590
597
. only_host_build ( true )
598
+ . only_stage ( 0 )
591
599
. dep ( |s| s. name ( "maybe-clean-tools" ) )
592
600
. dep ( |s| s. name ( "libstd-tool" ) )
593
601
. 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 {
600
608
rules. build ( "tool-remote-test-client" , "src/tools/remote-test-client" )
601
609
. default ( build. config . build_all_tools )
602
610
. host ( true )
611
+ . only_stage ( 0 )
603
612
. dep ( |s| s. name ( "maybe-clean-tools" ) )
604
613
. dep ( |s| s. name ( "libstd-tool" ) )
605
614
. run ( move |s| compile:: tool ( build, s. stage , s. target , "remote-test-client" ) ) ;
606
615
rules. build ( "tool-rust-installer" , "src/tools/rust-installer" )
607
616
. default ( build. config . build_all_tools )
608
617
. host ( true )
618
+ . only_stage ( 0 )
609
619
. dep ( |s| s. name ( "maybe-clean-tools" ) )
610
620
. dep ( |s| s. name ( "libstd-tool" ) )
611
621
. run ( move |s| compile:: tool ( build, s. stage , s. target , "rust-installer" ) ) ;
@@ -980,6 +990,9 @@ struct Rule<'a> {
980
990
/// targets.
981
991
only_build : bool ,
982
992
993
+ /// Whether this rule is only built for one stage (usually stage 0).
994
+ only_stage : Option < u32 > ,
995
+
983
996
/// A list of "order only" dependencies. This rules does not actually
984
997
/// depend on these rules, but if they show up in the dependency graph then
985
998
/// this rule must be executed after all these rules.
@@ -1008,6 +1021,7 @@ impl<'a> Rule<'a> {
1008
1021
host : false ,
1009
1022
only_host_build : false ,
1010
1023
only_build : false ,
1024
+ only_stage : None ,
1011
1025
after : Vec :: new ( ) ,
1012
1026
}
1013
1027
}
@@ -1059,6 +1073,11 @@ impl<'a, 'b> RuleBuilder<'a, 'b> {
1059
1073
self . rule . only_host_build = only_host_build;
1060
1074
self
1061
1075
}
1076
+
1077
+ fn only_stage ( & mut self , stage : u32 ) -> & mut Self {
1078
+ self . rule . only_stage = Some ( stage) ;
1079
+ self
1080
+ }
1062
1081
}
1063
1082
1064
1083
impl < ' a , ' b > Drop for RuleBuilder < ' a , ' b > {
@@ -1225,6 +1244,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
1225
1244
Subcommand :: Install { ref paths } => ( Kind :: Install , & paths[ ..] ) ,
1226
1245
Subcommand :: Clean => panic ! ( ) ,
1227
1246
} ;
1247
+ let current_stage = self . sbuild . stage ;
1228
1248
1229
1249
let mut rules: Vec < _ > = self . rules . values ( ) . filter_map ( |rule| {
1230
1250
if rule. kind != kind {
@@ -1278,7 +1298,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
1278
1298
1279
1299
hosts. iter ( ) . flat_map ( move |host| {
1280
1300
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) )
1282
1305
} )
1283
1306
} )
1284
1307
} ) . collect ( )
0 commit comments