@@ -62,6 +62,7 @@ macro_rules! book {
62
62
target: self . target,
63
63
name: INTERNER . intern_str( $book_name) ,
64
64
src: INTERNER . intern_path( builder. src. join( $path) ) ,
65
+ parent: Some ( self ) ,
65
66
} )
66
67
}
67
68
}
@@ -119,18 +120,20 @@ impl Step for UnstableBook {
119
120
target : self . target ,
120
121
name : INTERNER . intern_str ( "unstable-book" ) ,
121
122
src : INTERNER . intern_path ( builder. md_doc_out ( self . target ) . join ( "unstable-book" ) ) ,
123
+ parent : Some ( self ) ,
122
124
} )
123
125
}
124
126
}
125
127
126
128
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
127
- struct RustbookSrc {
129
+ struct RustbookSrc < P : Step > {
128
130
target : TargetSelection ,
129
131
name : Interned < String > ,
130
132
src : Interned < PathBuf > ,
133
+ parent : Option < P > ,
131
134
}
132
135
133
- impl Step for RustbookSrc {
136
+ impl < P : Step > Step for RustbookSrc < P > {
134
137
type Output = ( ) ;
135
138
136
139
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
@@ -152,13 +155,18 @@ impl Step for RustbookSrc {
152
155
let index = out. join ( "index.html" ) ;
153
156
let rustbook = builder. tool_exe ( Tool :: Rustbook ) ;
154
157
let mut rustbook_cmd = builder. tool_cmd ( Tool :: Rustbook ) ;
155
- if builder. config . dry_run ( ) || up_to_date ( & src, & index) && up_to_date ( & rustbook, & index) {
156
- return ;
158
+
159
+ if !builder. config . dry_run ( ) && !( up_to_date ( & src, & index) || up_to_date ( & rustbook, & index) )
160
+ {
161
+ builder. info ( & format ! ( "Rustbook ({}) - {}" , target, name) ) ;
162
+ let _ = fs:: remove_dir_all ( & out) ;
163
+
164
+ builder. run ( rustbook_cmd. arg ( "build" ) . arg ( & src) . arg ( "-d" ) . arg ( out) ) ;
157
165
}
158
- builder. info ( & format ! ( "Rustbook ({}) - {}" , target, name) ) ;
159
- let _ = fs:: remove_dir_all ( & out) ;
160
166
161
- builder. run ( rustbook_cmd. arg ( "build" ) . arg ( & src) . arg ( "-d" ) . arg ( out) ) ;
167
+ if self . parent . is_some ( ) {
168
+ builder. maybe_open_in_browser :: < P > ( index)
169
+ }
162
170
}
163
171
}
164
172
@@ -205,6 +213,7 @@ impl Step for TheBook {
205
213
target,
206
214
name : INTERNER . intern_str ( "book" ) ,
207
215
src : INTERNER . intern_path ( builder. src . join ( & relative_path) ) ,
216
+ parent : Some ( self ) ,
208
217
} ) ;
209
218
210
219
// building older edition redirects
@@ -213,6 +222,9 @@ impl Step for TheBook {
213
222
target,
214
223
name : INTERNER . intern_string ( format ! ( "book/{}" , edition) ) ,
215
224
src : INTERNER . intern_path ( builder. src . join ( & relative_path) . join ( edition) ) ,
225
+ // There should only be one book that is marked as the parent for each target, so
226
+ // treat the other editions as not having a parent.
227
+ parent : Option :: < Self > :: None ,
216
228
} ) ;
217
229
}
218
230
@@ -228,10 +240,6 @@ impl Step for TheBook {
228
240
229
241
invoke_rustdoc ( builder, compiler, & shared_assets, target, path) ;
230
242
}
231
-
232
- let out = builder. doc_out ( target) ;
233
- let index = out. join ( "book" ) . join ( "index.html" ) ;
234
- builder. maybe_open_in_browser :: < Self > ( index) ;
235
243
}
236
244
}
237
245
@@ -1032,10 +1040,7 @@ impl Step for RustcBook {
1032
1040
target : self . target ,
1033
1041
name : INTERNER . intern_str ( "rustc" ) ,
1034
1042
src : INTERNER . intern_path ( out_base) ,
1043
+ parent : Some ( self ) ,
1035
1044
} ) ;
1036
-
1037
- let out = builder. doc_out ( self . target ) ;
1038
- let index = out. join ( "rustc" ) . join ( "index.html" ) ;
1039
- builder. maybe_open_in_browser :: < Self > ( index) ;
1040
1045
}
1041
1046
}
0 commit comments