@@ -685,18 +685,7 @@ impl Step for Rustc {
685
685
target,
686
686
) ;
687
687
688
- // This uses a shared directory so that librustdoc documentation gets
689
- // correctly built and merged with the rustc documentation. This is
690
- // needed because rustdoc is built in a different directory from
691
- // rustc. rustdoc needs to be able to see everything, for example when
692
- // merging the search index, or generating local (relative) links.
693
688
let out_dir = builder. stage_out ( compiler, Mode :: Rustc ) . join ( target. triple ) . join ( "doc" ) ;
694
- t ! ( fs:: create_dir_all( out_dir. parent( ) . unwrap( ) ) ) ;
695
- symlink_dir_force ( & builder. config , & out, & out_dir) ;
696
- // Cargo puts proc macros in `target/doc` even if you pass `--target`
697
- // explicitly (https://github.com/rust-lang/cargo/issues/7677).
698
- let proc_macro_out_dir = builder. stage_out ( compiler, Mode :: Rustc ) . join ( "doc" ) ;
699
- symlink_dir_force ( & builder. config , & out, & proc_macro_out_dir) ;
700
689
701
690
// Build cargo command.
702
691
let mut cargo = builder. cargo ( compiler, Mode :: Rustc , SourceType :: InTree , target, "doc" ) ;
@@ -736,8 +725,29 @@ impl Step for Rustc {
736
725
}
737
726
}
738
727
728
+ // This uses a shared directory so that librustdoc documentation gets
729
+ // correctly built and merged with the rustc documentation.
730
+ //
731
+ // This is needed because rustdoc is built in a different directory from
732
+ // rustc. rustdoc needs to be able to see everything, for example when
733
+ // merging the search index, or generating local (relative) links.
734
+ symlink_dir_force ( & builder. config , & out, & out_dir) ;
735
+ // Cargo puts proc macros in `target/doc` even if you pass `--target`
736
+ // explicitly (https://github.com/rust-lang/cargo/issues/7677).
737
+ let proc_macro_out_dir = builder. stage_out ( compiler, Mode :: Rustc ) . join ( "doc" ) ;
738
+ symlink_dir_force ( & builder. config , & out, & proc_macro_out_dir) ;
739
+
739
740
builder. run ( & mut cargo. into ( ) ) ;
740
741
742
+ if !builder. config . dry_run ( ) {
743
+ // Sanity check on linked compiler crates
744
+ for krate in & * self . crates {
745
+ let dir_name = krate. replace ( "-" , "_" ) ;
746
+ // Making sure the directory exists and is not empty.
747
+ assert ! ( out. join( & * dir_name) . read_dir( ) . unwrap( ) . next( ) . is_some( ) ) ;
748
+ }
749
+ }
750
+
741
751
if builder. paths . iter ( ) . any ( |path| path. ends_with ( "compiler" ) ) {
742
752
// For `x.py doc compiler --open`, open `rustc_middle` by default.
743
753
let index = out. join ( "rustc_middle" ) . join ( "index.html" ) ;
@@ -756,10 +766,10 @@ macro_rules! tool_doc {
756
766
$should_run: literal,
757
767
$path: literal,
758
768
$( rustc_tool = $rustc_tool: literal, ) ?
759
- $( in_tree = $in_tree: literal, ) ?
760
- [ $ ( $extra_arg : literal ) ,+ $ ( , ) ?]
761
- $( , ) ?
762
- ) => {
769
+ $( in_tree = $in_tree: literal , ) ?
770
+ $ ( is_library = $is_library : expr , ) ?
771
+ $( crates = $crates : expr ) ?
772
+ ) => {
763
773
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
764
774
pub struct $tool {
765
775
target: TargetSelection ,
@@ -818,9 +828,16 @@ macro_rules! tool_doc {
818
828
// Cargo uses a different directory for proc macros.
819
829
builder. stage_out( compiler, Mode :: ToolRustc ) . join( "doc" ) ,
820
830
] ;
821
- for out_dir in out_dirs {
822
- t!( fs:: create_dir_all( & out_dir) ) ;
823
- symlink_dir_force( & builder. config, & out, & out_dir) ;
831
+
832
+ if !builder. config. dry_run( ) {
833
+ $( for krate in $crates {
834
+ let dir_name = krate. replace( "-" , "_" ) ;
835
+ t!( fs:: create_dir_all( out_dirs[ 0 ] . join( & * dir_name) ) ) ;
836
+ } ) ?
837
+
838
+ for out_dir in & out_dirs {
839
+ symlink_dir_force( & builder. config, & out, & out_dir) ;
840
+ }
824
841
}
825
842
826
843
// Build cargo command.
@@ -839,9 +856,13 @@ macro_rules! tool_doc {
839
856
// Only include compiler crates, no dependencies of those, such as `libc`.
840
857
cargo. arg( "--no-deps" ) ;
841
858
842
- $(
843
- cargo. arg( $extra_arg) ;
844
- ) +
859
+ if false $( || $is_library) ? {
860
+ cargo. arg( "--lib" ) ;
861
+ }
862
+
863
+ $( for krate in $crates {
864
+ cargo. arg( "-p" ) . arg( krate) ;
865
+ } ) ?
845
866
846
867
cargo. rustdocflag( "--document-private-items" ) ;
847
868
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
@@ -853,60 +874,56 @@ macro_rules! tool_doc {
853
874
854
875
let _guard = builder. msg_doc( compiler, stringify!( $tool) . to_lowercase( ) , target) ;
855
876
builder. run( & mut cargo. into( ) ) ;
877
+
878
+ // if !builder.config.dry_run() {
879
+ // // Sanity check on linked doc directories
880
+ // $(for krate in $crates {
881
+ // let dir_name = krate.replace("-", "_");
882
+ // // Making sure the directory exists and is not empty.
883
+ // assert!(out.join(&*dir_name).read_dir().unwrap().next().is_some());
884
+ // })?
885
+ // }
856
886
}
857
887
}
858
888
}
859
889
}
860
890
861
- tool_doc ! (
862
- Rustdoc ,
863
- "rustdoc-tool" ,
864
- "src/tools/rustdoc" ,
865
- [ "-p" , "rustdoc" , "-p" , "rustdoc-json-types" ]
866
- ) ;
891
+ tool_doc ! ( Rustdoc , "rustdoc-tool" , "src/tools/rustdoc" , crates = [ "rustdoc" , "rustdoc-json-types" ] ) ;
867
892
tool_doc ! (
868
893
Rustfmt ,
869
894
"rustfmt-nightly" ,
870
895
"src/tools/rustfmt" ,
871
- [ "-p" , " rustfmt-nightly", "-p" , " rustfmt-config_proc_macro"] ,
896
+ crates = [ " rustfmt-nightly", "rustfmt-config_proc_macro" ]
872
897
) ;
873
- tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , [ "-p" , "clippy_utils" ] ) ;
874
- tool_doc ! ( Miri , "miri" , "src/tools/miri" , [ "-p" , "miri" ] ) ;
898
+ tool_doc ! ( Clippy , "clippy" , "src/tools/clippy" , crates = [ "clippy_utils" ] ) ;
899
+ tool_doc ! ( Miri , "miri" , "src/tools/miri" , crates = [ "miri" ] ) ;
875
900
tool_doc ! (
876
901
Cargo ,
877
902
"cargo" ,
878
903
"src/tools/cargo" ,
879
904
rustc_tool = false ,
880
905
in_tree = false ,
881
- [
882
- "-p" ,
906
+ crates = [
883
907
"cargo" ,
884
- "-p" ,
885
908
"cargo-platform" ,
886
- "-p" ,
887
909
"cargo-util" ,
888
- "-p" ,
889
910
"crates-io" ,
890
- "-p" ,
891
911
"cargo-test-macro" ,
892
- "-p" ,
893
912
"cargo-test-support" ,
894
- "-p" ,
895
913
"cargo-credential" ,
896
- "-p" ,
897
914
"mdman" ,
898
915
// FIXME: this trips a license check in tidy.
899
- // "-p",
900
916
// "resolver-tests",
901
917
]
902
918
) ;
903
- tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , [ "-p" , "tidy" ] ) ;
919
+ tool_doc ! ( Tidy , "tidy" , "src/tools/tidy" , rustc_tool = false , crates = [ "tidy" ] ) ;
904
920
tool_doc ! (
905
921
Bootstrap ,
906
922
"bootstrap" ,
907
923
"src/bootstrap" ,
908
924
rustc_tool = false ,
909
- [ "--lib" , "-p" , "bootstrap" ]
925
+ is_library = true ,
926
+ crates = [ "bootstrap" ]
910
927
) ;
911
928
912
929
#[ derive( Ord , PartialOrd , Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
0 commit comments