@@ -593,84 +593,97 @@ impl Step for Rustc {
593
593
}
594
594
}
595
595
596
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
597
- pub struct Rustdoc {
598
- stage : u32 ,
599
- target : TargetSelection ,
600
- }
601
-
602
- impl Step for Rustdoc {
603
- type Output = ( ) ;
604
- const DEFAULT : bool = true ;
605
- const ONLY_HOSTS : bool = true ;
606
-
607
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
608
- run. krate ( "rustdoc-tool" )
609
- }
610
-
611
- fn make_run ( run : RunConfig < ' _ > ) {
612
- run. builder . ensure ( Rustdoc { stage : run. builder . top_stage , target : run. target } ) ;
613
- }
614
-
615
- /// Generates compiler documentation.
616
- ///
617
- /// This will generate all documentation for compiler and dependencies.
618
- /// Compiler documentation is distributed separately, so we make sure
619
- /// we do not merge it with the other documentation from std, test and
620
- /// proc_macros. This is largely just a wrapper around `cargo doc`.
621
- fn run ( self , builder : & Builder < ' _ > ) {
622
- let stage = self . stage ;
623
- let target = self . target ;
624
- builder. info ( & format ! ( "Documenting stage{} rustdoc ({})" , stage, target) ) ;
625
-
626
- // This is the intended out directory for compiler documentation.
627
- let out = builder. compiler_doc_out ( target) ;
628
- t ! ( fs:: create_dir_all( & out) ) ;
596
+ macro_rules! tool_doc {
597
+ ( $tool: ident, $should_run: literal, $path: literal, [ $( $krate: literal) ,+ $( , ) ?] $( , binary=$bin: expr) ?) => {
598
+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
599
+ pub struct $tool {
600
+ stage: u32 ,
601
+ target: TargetSelection ,
602
+ }
629
603
630
- let compiler = builder. compiler ( stage, builder. config . build ) ;
604
+ impl Step for $tool {
605
+ type Output = ( ) ;
606
+ const DEFAULT : bool = true ;
607
+ const ONLY_HOSTS : bool = true ;
631
608
632
- if !builder. config . compiler_docs {
633
- builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
634
- return ;
635
- }
609
+ fn should_run( run: ShouldRun <' _>) -> ShouldRun <' _> {
610
+ run. krate( $should_run)
611
+ }
636
612
637
- // Build rustc docs so that we generate relative links.
638
- builder. ensure ( Rustc { stage, target } ) ;
613
+ fn make_run( run: RunConfig <' _>) {
614
+ run. builder. ensure( $tool { stage: run. builder. top_stage, target: run. target } ) ;
615
+ }
639
616
640
- // Build rustdoc.
641
- builder. ensure ( tool:: Rustdoc { compiler } ) ;
617
+ /// Generates compiler documentation.
618
+ ///
619
+ /// This will generate all documentation for compiler and dependencies.
620
+ /// Compiler documentation is distributed separately, so we make sure
621
+ /// we do not merge it with the other documentation from std, test and
622
+ /// proc_macros. This is largely just a wrapper around `cargo doc`.
623
+ fn run( self , builder: & Builder <' _>) {
624
+ let stage = self . stage;
625
+ let target = self . target;
626
+ builder. info( & format!( "Documenting stage{} {} ({})" , stage, stringify!( $tool) . to_lowercase( ) , target) ) ;
642
627
643
- // Symlink compiler docs to the output directory of rustdoc documentation.
644
- let out_dir = builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( target. triple ) . join ( "doc" ) ;
645
- t ! ( fs:: create_dir_all( & out_dir) ) ;
646
- t ! ( symlink_dir_force( & builder. config, & out, & out_dir) ) ;
628
+ // This is the intended out directory for compiler documentation.
629
+ let out = builder. compiler_doc_out( target) ;
630
+ t!( fs:: create_dir_all( & out) ) ;
647
631
648
- // Build cargo command.
649
- let mut cargo = prepare_tool_cargo (
650
- builder,
651
- compiler,
652
- Mode :: ToolRustc ,
653
- target,
654
- "doc" ,
655
- "src/tools/rustdoc" ,
656
- SourceType :: InTree ,
657
- & [ ] ,
658
- ) ;
632
+ let compiler = builder. compiler( stage, builder. config. build) ;
659
633
660
- cargo. arg ( "-Zskip-rustdoc-fingerprint" ) ;
661
- // Only include compiler crates, no dependencies of those, such as `libc`.
662
- cargo. arg ( "--no-deps" ) ;
663
- cargo. arg ( "-p" ) . arg ( "rustdoc" ) ;
664
- cargo. arg ( "-p" ) . arg ( "rustdoc-json-types" ) ;
634
+ if !builder. config. compiler_docs {
635
+ builder. info( "\t skipping - compiler/tool docs disabled" ) ;
636
+ return ;
637
+ }
665
638
666
- cargo. rustdocflag ( "--document-private-items" ) ;
667
- cargo. rustdocflag ( "--enable-index-page" ) ;
668
- cargo. rustdocflag ( "--show-type-layout" ) ;
669
- cargo. rustdocflag ( "-Zunstable-options" ) ;
670
- builder. run ( & mut cargo. into ( ) ) ;
639
+ // Build rustc docs so that we generate relative links.
640
+ builder. ensure( Rustc { stage, target } ) ;
641
+
642
+ // Symlink compiler docs to the output directory of rustdoc documentation.
643
+ let out_dir = builder. stage_out( compiler, Mode :: ToolRustc ) . join( target. triple) . join( "doc" ) ;
644
+ t!( fs:: create_dir_all( & out_dir) ) ;
645
+ t!( symlink_dir_force( & builder. config, & out, & out_dir) ) ;
646
+
647
+ // Build cargo command.
648
+ let mut cargo = prepare_tool_cargo(
649
+ builder,
650
+ compiler,
651
+ Mode :: ToolRustc ,
652
+ target,
653
+ "doc" ,
654
+ $path,
655
+ SourceType :: InTree ,
656
+ & [ ] ,
657
+ ) ;
658
+
659
+ cargo. arg( "-Zskip-rustdoc-fingerprint" ) ;
660
+ // Only include compiler crates, no dependencies of those, such as `libc`.
661
+ cargo. arg( "--no-deps" ) ;
662
+ $(
663
+ cargo. arg( "-p" ) . arg( $krate) ;
664
+ ) +
665
+
666
+ $( if !$bin {
667
+ cargo. rustdocflag( "--document-private-items" ) ;
668
+ } ) ?
669
+ cargo. rustdocflag( "--enable-index-page" ) ;
670
+ cargo. rustdocflag( "--show-type-layout" ) ;
671
+ cargo. rustdocflag( "-Zunstable-options" ) ;
672
+ builder. run( & mut cargo. into( ) ) ;
673
+ }
674
+ }
671
675
}
672
676
}
673
677
678
+ tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , [ "rustdoc" , "rustdoc-json-types" ] ) ;
679
+ tool_doc ! (
680
+ Rustfmt ,
681
+ "rustfmt-nightly" ,
682
+ "src/tools/rustfmt" ,
683
+ [ "rustfmt-nightly" , "rustfmt-config_proc_macro" ] ,
684
+ binary = true
685
+ ) ;
686
+
674
687
#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
675
688
pub struct ErrorIndex {
676
689
pub target : TargetSelection ,
0 commit comments