@@ -16,7 +16,7 @@ use crate::cache::{Interned, INTERNER};
1616use crate :: compile;
1717use crate :: config:: { Config , TargetSelection } ;
1818use 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} ;
2020use crate :: Mode ;
2121
2222macro_rules! submodule_helper {
@@ -197,11 +197,21 @@ impl Step for TheBook {
197197 let compiler = self . compiler ;
198198 let target = self . target ;
199199
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+ }
200210 // build book
201211 builder. ensure ( RustbookSrc {
202212 target,
203213 name : INTERNER . intern_str ( "book" ) ,
204- src : INTERNER . intern_path ( builder . src . join ( & relative_path ) ) ,
214+ src : INTERNER . intern_path ( absolute_path . clone ( ) ) ,
205215 parent : Some ( self ) ,
206216 } ) ;
207217
@@ -210,7 +220,7 @@ impl Step for TheBook {
210220 builder. ensure ( RustbookSrc {
211221 target,
212222 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) ) ,
214224 // There should only be one book that is marked as the parent for each target, so
215225 // treat the other editions as not having a parent.
216226 parent : Option :: < Self > :: None ,
@@ -225,7 +235,7 @@ impl Step for TheBook {
225235
226236 // build the redirect pages
227237 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 ) ) {
229239 let file = t ! ( file) ;
230240 let path = file. path ( ) ;
231241 let path = path. to_str ( ) . unwrap ( ) ;
0 commit comments