@@ -766,10 +766,10 @@ macro_rules! tool_doc {
766
766
$should_run: literal,
767
767
$path: literal,
768
768
$( rustc_tool = $rustc_tool: literal, ) ?
769
- $( in_tree = $in_tree: literal, ) ?
770
- [ $ ( $extra_arg : literal ) ,+ $ ( , ) ?]
771
- $( , ) ?
772
- ) => {
769
+ $( in_tree = $in_tree: literal , ) ?
770
+ $ ( is_library = $is_library : expr , ) ?
771
+ $( crates = $crates : expr ) ?
772
+ ) => {
773
773
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
774
774
pub struct $tool {
775
775
target: TargetSelection ,
@@ -828,8 +828,13 @@ macro_rules! tool_doc {
828
828
// Cargo uses a different directory for proc macros.
829
829
builder. stage_out( compiler, Mode :: ToolRustc ) . join( "doc" ) ,
830
830
] ;
831
+
832
+ $( for krate in $crates {
833
+ let dir_name = krate. replace( "-" , "_" ) ;
834
+ t!( fs:: create_dir_all( & out. join( dir_name) ) ) ;
835
+ } ) ?
836
+
831
837
for out_dir in out_dirs {
832
- t!( fs:: create_dir_all( & out_dir) ) ;
833
838
symlink_dir_force( & builder. config, & out, & out_dir) ;
834
839
}
835
840
@@ -849,9 +854,13 @@ macro_rules! tool_doc {
849
854
// Only include compiler crates, no dependencies of those, such as `libc`.
850
855
cargo. arg( "--no-deps" ) ;
851
856
852
- $(
853
- cargo. arg( $extra_arg) ;
854
- ) +
857
+ if false $( || $is_library) ? {
858
+ cargo. arg( "--lib" ) ;
859
+ }
860
+
861
+ $( for krate in $crates {
862
+ cargo. arg( "-p" ) . arg( krate) ;
863
+ } ) ?
855
864
856
865
cargo. rustdocflag( "--document-private-items" ) ;
857
866
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
@@ -863,60 +872,56 @@ macro_rules! tool_doc {
863
872
864
873
let _guard = builder. msg_doc( compiler, stringify!( $tool) . to_lowercase( ) , target) ;
865
874
builder. run( & mut cargo. into( ) ) ;
875
+
876
+ if !builder. config. dry_run( ) {
877
+ // Sanity check on linked doc directories
878
+ $( for krate in $crates {
879
+ let dir_name = krate. replace( "-" , "_" ) ;
880
+ // Making sure the directory exists and is not empty.
881
+ assert!( out. join( & * dir_name) . read_dir( ) . unwrap( ) . next( ) . is_some( ) ) ;
882
+ } ) ?
883
+ }
866
884
}
867
885
}
868
886
}
869
887
}
870
888
871
- tool_doc ! (
872
- Rustdoc ,
873
- "rustdoc-tool" ,
874
- "src/tools/rustdoc" ,
875
- [ "-p" , "rustdoc" , "-p" , "rustdoc-json-types" ]
876
- ) ;
889
+ tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , crates = [ "rustdoc" , "rustdoc-json-types" ] ) ;
877
890
tool_doc ! (
878
891
Rustfmt ,
879
892
"rustfmt-nightly" ,
880
893
"src/tools/rustfmt" ,
881
- [ "-p" , " rustfmt-nightly", "-p" , " rustfmt-config_proc_macro"] ,
894
+ crates = [ " rustfmt-nightly", "rustfmt-config_proc_macro" ]
882
895
) ;
883
- tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "-p" , "clippy_utils" ] ) ;
884
- tool_doc ! ( Miri , "miri" , "src/tools/miri" , [ "-p" , "miri" ] ) ;
896
+ tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , crates = [ "clippy_utils" ] ) ;
897
+ tool_doc ! ( Miri , "miri" , "src/tools/miri" , crates = [ "miri" ] ) ;
885
898
tool_doc ! (
886
899
Cargo ,
887
900
"cargo" ,
888
901
"src/tools/cargo" ,
889
902
rustc_tool = false ,
890
903
in_tree = false ,
891
- [
892
- "-p" ,
904
+ crates = [
893
905
"cargo" ,
894
- "-p" ,
895
906
"cargo-platform" ,
896
- "-p" ,
897
907
"cargo-util" ,
898
- "-p" ,
899
908
"crates-io" ,
900
- "-p" ,
901
909
"cargo-test-macro" ,
902
- "-p" ,
903
910
"cargo-test-support" ,
904
- "-p" ,
905
911
"cargo-credential" ,
906
- "-p" ,
907
912
"mdman" ,
908
913
// FIXME: this trips a license check in tidy.
909
- // "-p",
910
914
// "resolver-tests",
911
915
]
912
916
) ;
913
- tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , [ "-p" , "tidy" ] ) ;
917
+ tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
914
918
tool_doc ! (
915
919
Bootstrap ,
916
920
"bootstrap" ,
917
921
"src/bootstrap" ,
918
922
rustc_tool = false ,
919
- [ "--lib" , "-p" , "bootstrap" ]
923
+ is_library = true ,
924
+ crates = [ "bootstrap" ]
920
925
) ;
921
926
922
927
#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
0 commit comments