@@ -685,8 +685,6 @@ impl Step for Rustc {
685
685
target,
686
686
) ;
687
687
688
- let out_dir = builder. stage_out ( compiler, Mode :: Rustc ) . join ( target. triple ) . join ( "doc" ) ;
689
-
690
688
// Build cargo command.
691
689
let mut cargo = builder. cargo ( compiler, Mode :: Rustc , SourceType :: InTree , target, "doc" ) ;
692
690
cargo. rustdocflag ( "--document-private-items" ) ;
@@ -713,6 +711,7 @@ impl Step for Rustc {
713
711
714
712
let mut to_open = None ;
715
713
714
+ let out_dir = builder. stage_out ( compiler, Mode :: Rustc ) . join ( target. triple ) . join ( "doc" ) ;
716
715
for krate in & * self . crates {
717
716
// Create all crate output directories first to make sure rustdoc uses
718
717
// relative links.
@@ -766,10 +765,10 @@ macro_rules! tool_doc {
766
765
$should_run: literal,
767
766
$path: literal,
768
767
$( rustc_tool = $rustc_tool: literal, ) ?
769
- $( in_tree = $in_tree: literal, ) ?
770
- [ $ ( $extra_arg : literal ) ,+ $ ( , ) ?]
771
- $( , ) ?
772
- ) => {
768
+ $( in_tree = $in_tree: literal , ) ?
769
+ $ ( is_library = $is_library : expr , ) ?
770
+ $( crates = $crates : expr ) ?
771
+ ) => {
773
772
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
774
773
pub struct $tool {
775
774
target: TargetSelection ,
@@ -822,17 +821,6 @@ macro_rules! tool_doc {
822
821
SourceType :: Submodule
823
822
} ;
824
823
825
- // Symlink compiler docs to the output directory of rustdoc documentation.
826
- let out_dirs = [
827
- builder. stage_out( compiler, Mode :: ToolRustc ) . join( target. triple) . join( "doc" ) ,
828
- // Cargo uses a different directory for proc macros.
829
- builder. stage_out( compiler, Mode :: ToolRustc ) . join( "doc" ) ,
830
- ] ;
831
- for out_dir in out_dirs {
832
- t!( fs:: create_dir_all( & out_dir) ) ;
833
- symlink_dir_force( & builder. config, & out, & out_dir) ;
834
- }
835
-
836
824
// Build cargo command.
837
825
let mut cargo = prepare_tool_cargo(
838
826
builder,
@@ -849,9 +837,13 @@ macro_rules! tool_doc {
849
837
// Only include compiler crates, no dependencies of those, such as `libc`.
850
838
cargo. arg( "--no-deps" ) ;
851
839
852
- $(
853
- cargo. arg( $extra_arg) ;
854
- ) +
840
+ if false $( || $is_library) ? {
841
+ cargo. arg( "--lib" ) ;
842
+ }
843
+
844
+ $( for krate in $crates {
845
+ cargo. arg( "-p" ) . arg( krate) ;
846
+ } ) ?
855
847
856
848
cargo. rustdocflag( "--document-private-items" ) ;
857
849
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
@@ -861,62 +853,69 @@ macro_rules! tool_doc {
861
853
cargo. rustdocflag( "--generate-link-to-definition" ) ;
862
854
cargo. rustdocflag( "-Zunstable-options" ) ;
863
855
856
+ let out_dir = builder. stage_out( compiler, Mode :: ToolRustc ) . join( target. triple) . join( "doc" ) ;
857
+ $( for krate in $crates {
858
+ let dir_name = krate. replace( "-" , "_" ) ;
859
+ t!( fs:: create_dir_all( out_dir. join( & * dir_name) ) ) ;
860
+ } ) ?
861
+
862
+ // Symlink compiler docs to the output directory of rustdoc documentation.
863
+ symlink_dir_force( & builder. config, & out, & out_dir) ;
864
+ let proc_macro_out_dir = builder. stage_out( compiler, Mode :: ToolRustc ) . join( "doc" ) ;
865
+ symlink_dir_force( & builder. config, & out, & proc_macro_out_dir) ;
866
+
864
867
let _guard = builder. msg_doc( compiler, stringify!( $tool) . to_lowercase( ) , target) ;
865
868
builder. run( & mut cargo. into( ) ) ;
869
+
870
+ if !builder. config. dry_run( ) {
871
+ // Sanity check on linked doc directories
872
+ $( for krate in $crates {
873
+ let dir_name = krate. replace( "-" , "_" ) ;
874
+ // Making sure the directory exists and is not empty.
875
+ assert!( out. join( & * dir_name) . read_dir( ) . unwrap( ) . next( ) . is_some( ) ) ;
876
+ } ) ?
877
+ }
866
878
}
867
879
}
868
880
}
869
881
}
870
882
871
- tool_doc ! (
872
- Rustdoc ,
873
- "rustdoc-tool" ,
874
- "src/tools/rustdoc" ,
875
- [ "-p" , "rustdoc" , "-p" , "rustdoc-json-types" ]
876
- ) ;
883
+ tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , crates = [ "rustdoc" , "rustdoc-json-types" ] ) ;
877
884
tool_doc ! (
878
885
Rustfmt ,
879
886
"rustfmt-nightly" ,
880
887
"src/tools/rustfmt" ,
881
- [ "-p" , " rustfmt-nightly", "-p" , " rustfmt-config_proc_macro"] ,
888
+ crates = [ " rustfmt-nightly", "rustfmt-config_proc_macro" ]
882
889
) ;
883
- tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "-p" , "clippy_utils" ] ) ;
884
- tool_doc ! ( Miri , "miri" , "src/tools/miri" , [ "-p" , "miri" ] ) ;
890
+ tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , crates = [ "clippy_utils" ] ) ;
891
+ tool_doc ! ( Miri , "miri" , "src/tools/miri" , crates = [ "miri" ] ) ;
885
892
tool_doc ! (
886
893
Cargo ,
887
894
"cargo" ,
888
895
"src/tools/cargo" ,
889
896
rustc_tool = false ,
890
897
in_tree = false ,
891
- [
892
- "-p" ,
898
+ crates = [
893
899
"cargo" ,
894
- "-p" ,
895
900
"cargo-platform" ,
896
- "-p" ,
897
901
"cargo-util" ,
898
- "-p" ,
899
902
"crates-io" ,
900
- "-p" ,
901
903
"cargo-test-macro" ,
902
- "-p" ,
903
904
"cargo-test-support" ,
904
- "-p" ,
905
905
"cargo-credential" ,
906
- "-p" ,
907
906
"mdman" ,
908
907
// FIXME: this trips a license check in tidy.
909
- // "-p",
910
908
// "resolver-tests",
911
909
]
912
910
) ;
913
- tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , [ "-p" , "tidy" ] ) ;
911
+ tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
914
912
tool_doc ! (
915
913
Bootstrap ,
916
914
"bootstrap" ,
917
915
"src/bootstrap" ,
918
916
rustc_tool = false ,
919
- [ "--lib" , "-p" , "bootstrap" ]
917
+ is_library = true ,
918
+ crates = [ "bootstrap" ]
920
919
) ;
921
920
922
921
#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
0 commit comments