@@ -16,7 +16,7 @@ use crate::cache::{Interned, INTERNER};
16
16
use crate :: compile;
17
17
use crate :: config:: { Config , TargetSelection } ;
18
18
use crate :: tool:: { self , prepare_tool_cargo, SourceType , Tool } ;
19
- use crate :: util:: { symlink_dir, t, up_to_date} ;
19
+ use crate :: util:: { dir_is_empty , symlink_dir, t, up_to_date} ;
20
20
use crate :: Mode ;
21
21
22
22
macro_rules! submodule_helper {
@@ -197,11 +197,21 @@ impl Step for TheBook {
197
197
let compiler = self . compiler ;
198
198
let target = self . target ;
199
199
200
+ let absolute_path = builder. src . join ( & relative_path) ;
201
+ let redirect_path = absolute_path. join ( "redirects" ) ;
202
+ if !absolute_path. exists ( )
203
+ || !redirect_path. exists ( )
204
+ || dir_is_empty ( & absolute_path)
205
+ || dir_is_empty ( & redirect_path)
206
+ {
207
+ eprintln ! ( "Please checkout submodule: {}" , relative_path. display( ) ) ;
208
+ crate :: exit!( 1 ) ;
209
+ }
200
210
// build book
201
211
builder. ensure ( RustbookSrc {
202
212
target,
203
213
name : INTERNER . intern_str ( "book" ) ,
204
- src : INTERNER . intern_path ( builder . src . join ( & relative_path ) ) ,
214
+ src : INTERNER . intern_path ( absolute_path . clone ( ) ) ,
205
215
parent : Some ( self ) ,
206
216
} ) ;
207
217
@@ -210,7 +220,7 @@ impl Step for TheBook {
210
220
builder. ensure ( RustbookSrc {
211
221
target,
212
222
name : INTERNER . intern_string ( format ! ( "book/{}" , edition) ) ,
213
- src : INTERNER . intern_path ( builder . src . join ( & relative_path ) . join ( edition) ) ,
223
+ src : INTERNER . intern_path ( absolute_path . join ( edition) ) ,
214
224
// There should only be one book that is marked as the parent for each target, so
215
225
// treat the other editions as not having a parent.
216
226
parent : Option :: < Self > :: None ,
@@ -225,7 +235,7 @@ impl Step for TheBook {
225
235
226
236
// build the redirect pages
227
237
let _guard = builder. msg_doc ( compiler, "book redirect pages" , target) ;
228
- for file in t ! ( fs:: read_dir( builder . src . join ( & relative_path ) . join ( "redirects" ) ) ) {
238
+ for file in t ! ( fs:: read_dir( redirect_path ) ) {
229
239
let file = t ! ( file) ;
230
240
let path = file. path ( ) ;
231
241
let path = path. to_str ( ) . unwrap ( ) ;
0 commit comments