@@ -22,6 +22,20 @@ use crate::compile;
22
22
use crate :: cache:: { INTERNER , Interned } ;
23
23
use crate :: config:: Config ;
24
24
25
+ fn doc_dir (
26
+ builder : & Builder < ' _ > ,
27
+ compiler : Compiler ,
28
+ target : Interned < String > ,
29
+ mode : Mode ,
30
+ ) -> PathBuf {
31
+ let compiler = if builder. force_use_stage1 ( compiler, target) {
32
+ builder. compiler ( 1 , compiler. host )
33
+ } else {
34
+ compiler
35
+ } ;
36
+ builder. stage_out ( compiler, mode) . join ( target) . join ( "doc" )
37
+ }
38
+
25
39
macro_rules! book {
26
40
( $( $name: ident, $path: expr, $book_name: expr, $book_ver: expr; ) +) => {
27
41
$(
@@ -476,15 +490,9 @@ impl Step for Std {
476
490
let out = builder. doc_out ( target) ;
477
491
t ! ( fs:: create_dir_all( & out) ) ;
478
492
let compiler = builder. compiler ( stage, builder. config . build ) ;
479
- let compiler = if builder. force_use_stage1 ( compiler, target) {
480
- builder. compiler ( 1 , compiler. host )
481
- } else {
482
- compiler
483
- } ;
484
493
485
494
builder. ensure ( compile:: Std { compiler, target } ) ;
486
- let out_dir = builder. stage_out ( compiler, Mode :: Std )
487
- . join ( target) . join ( "doc" ) ;
495
+ let out_dir = doc_dir ( builder, compiler, target, Mode :: Std ) ;
488
496
489
497
// Here what we're doing is creating a *symlink* (directory junction on
490
498
// Windows) to the final output location. This is not done as an
@@ -564,18 +572,12 @@ impl Step for Test {
564
572
let out = builder. doc_out ( target) ;
565
573
t ! ( fs:: create_dir_all( & out) ) ;
566
574
let compiler = builder. compiler ( stage, builder. config . build ) ;
567
- let compiler = if builder. force_use_stage1 ( compiler, target) {
568
- builder. compiler ( 1 , compiler. host )
569
- } else {
570
- compiler
571
- } ;
572
575
573
576
// Build libstd docs so that we generate relative links
574
577
builder. ensure ( Std { stage, target } ) ;
575
578
576
579
builder. ensure ( compile:: Test { compiler, target } ) ;
577
- let out_dir = builder. stage_out ( compiler, Mode :: Test )
578
- . join ( target) . join ( "doc" ) ;
580
+ let out_dir = doc_dir ( builder, compiler, target, Mode :: Test ) ;
579
581
580
582
// See docs in std above for why we symlink
581
583
let my_out = builder. crate_doc_out ( target) ;
@@ -633,18 +635,12 @@ impl Step for WhitelistedRustc {
633
635
let out = builder. doc_out ( target) ;
634
636
t ! ( fs:: create_dir_all( & out) ) ;
635
637
let compiler = builder. compiler ( stage, builder. config . build ) ;
636
- let compiler = if builder. force_use_stage1 ( compiler, target) {
637
- builder. compiler ( 1 , compiler. host )
638
- } else {
639
- compiler
640
- } ;
641
638
642
639
// Build libstd docs so that we generate relative links
643
640
builder. ensure ( Std { stage, target } ) ;
644
641
645
642
builder. ensure ( compile:: Rustc { compiler, target } ) ;
646
- let out_dir = builder. stage_out ( compiler, Mode :: Rustc )
647
- . join ( target) . join ( "doc" ) ;
643
+ let out_dir = doc_dir ( builder, compiler, target, Mode :: Rustc ) ;
648
644
649
645
// See docs in std above for why we symlink
650
646
let my_out = builder. crate_doc_out ( target) ;
@@ -707,11 +703,6 @@ impl Step for Rustc {
707
703
708
704
// Get the correct compiler for this stage.
709
705
let compiler = builder. compiler ( stage, builder. config . build ) ;
710
- let compiler = if builder. force_use_stage1 ( compiler, target) {
711
- builder. compiler ( 1 , compiler. host )
712
- } else {
713
- compiler
714
- } ;
715
706
716
707
if !builder. config . compiler_docs {
717
708
builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
@@ -723,7 +714,7 @@ impl Step for Rustc {
723
714
724
715
// We do not symlink to the same shared folder that already contains std library
725
716
// documentation from previous steps as we do not want to include that.
726
- let out_dir = builder . stage_out ( compiler, Mode :: Rustc ) . join ( target ) . join ( "doc" ) ;
717
+ let out_dir = doc_dir ( builder , compiler, target , Mode :: Rustc ) ;
727
718
t ! ( symlink_dir_force( & builder. config, & out, & out_dir) ) ;
728
719
729
720
// Build cargo command.
@@ -808,11 +799,6 @@ impl Step for Rustdoc {
808
799
809
800
// Get the correct compiler for this stage.
810
801
let compiler = builder. compiler ( stage, builder. config . build ) ;
811
- let compiler = if builder. force_use_stage1 ( compiler, target) {
812
- builder. compiler ( 1 , compiler. host )
813
- } else {
814
- compiler
815
- } ;
816
802
817
803
if !builder. config . compiler_docs {
818
804
builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
@@ -826,9 +812,7 @@ impl Step for Rustdoc {
826
812
builder. ensure ( tool:: Rustdoc { compiler : compiler } ) ;
827
813
828
814
// Symlink compiler docs to the output directory of rustdoc documentation.
829
- let out_dir = builder. stage_out ( compiler, Mode :: ToolRustc )
830
- . join ( target)
831
- . join ( "doc" ) ;
815
+ let out_dir = doc_dir ( builder, compiler, target, Mode :: ToolRustc ) ;
832
816
t ! ( fs:: create_dir_all( & out_dir) ) ;
833
817
t ! ( symlink_dir_force( & builder. config, & out, & out_dir) ) ;
834
818
0 commit comments