1212
1313use compile:: { run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot} ;
1414use builder:: { RunConfig , Builder , ShouldRun , Step } ;
15+ use tool:: prepare_tool_cargo;
1516use { Compiler , Mode } ;
1617use cache:: { INTERNER , Interned } ;
1718use std:: path:: PathBuf ;
@@ -41,6 +42,7 @@ impl Step for Std {
4142
4243 let out_dir = builder. stage_out ( compiler, Mode :: Libstd ) ;
4344 builder. clear_if_dirty ( & out_dir, & builder. rustc ( compiler) ) ;
45+
4446 let mut cargo = builder. cargo ( compiler, Mode :: Libstd , target, "check" ) ;
4547 std_cargo ( builder, & compiler, target, & mut cargo) ;
4648
@@ -170,11 +172,12 @@ impl Step for Test {
170172 }
171173
172174 fn run ( self , builder : & Builder ) {
173- let target = self . target ;
174175 let compiler = builder. compiler ( 0 , builder. config . build ) ;
176+ let target = self . target ;
175177
176178 let out_dir = builder. stage_out ( compiler, Mode :: Libtest ) ;
177179 builder. clear_if_dirty ( & out_dir, & libstd_stamp ( builder, compiler, target) ) ;
180+
178181 let mut cargo = builder. cargo ( compiler, Mode :: Libtest , target, "check" ) ;
179182 test_cargo ( builder, & compiler, target, & mut cargo) ;
180183
@@ -190,6 +193,48 @@ impl Step for Test {
190193 }
191194}
192195
196+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
197+ pub struct Rustdoc {
198+ pub target : Interned < String > ,
199+ }
200+
201+ impl Step for Rustdoc {
202+ type Output = ( ) ;
203+ const ONLY_HOSTS : bool = true ;
204+ const DEFAULT : bool = true ;
205+
206+ fn should_run ( run : ShouldRun ) -> ShouldRun {
207+ run. path ( "src/tools/rustdoc" )
208+ }
209+
210+ fn make_run ( run : RunConfig ) {
211+ run. builder . ensure ( Rustdoc {
212+ target : run. target ,
213+ } ) ;
214+ }
215+
216+ fn run ( self , builder : & Builder ) {
217+ let compiler = builder. compiler ( 0 , builder. config . build ) ;
218+ let target = self . target ;
219+
220+ let mut cargo = prepare_tool_cargo ( builder,
221+ compiler,
222+ target,
223+ "check" ,
224+ "src/tools/rustdoc" ) ;
225+
226+ let _folder = builder. fold_output ( || format ! ( "stage{}-rustdoc" , compiler. stage) ) ;
227+ println ! ( "Checking rustdoc artifacts ({} -> {})" , & compiler. host, target) ;
228+ run_cargo ( builder,
229+ & mut cargo,
230+ & rustdoc_stamp ( builder, compiler, target) ,
231+ true ) ;
232+
233+ let libdir = builder. sysroot_libdir ( compiler, target) ;
234+ add_to_sysroot ( & builder, & libdir, & rustdoc_stamp ( builder, compiler, target) ) ;
235+ }
236+ }
237+
193238/// Cargo's output path for the standard library in a given stage, compiled
194239/// by a particular compiler for the specified target.
195240pub fn libstd_stamp ( builder : & Builder , compiler : Compiler , target : Interned < String > ) -> PathBuf {
@@ -217,3 +262,9 @@ fn codegen_backend_stamp(builder: &Builder,
217262 builder. cargo_out ( compiler, Mode :: Librustc , target)
218263 . join ( format ! ( ".librustc_trans-{}-check.stamp" , backend) )
219264}
265+
266+ /// Cargo's output path for rustdoc in a given stage, compiled by a particular
267+ /// compiler for the specified target.
268+ pub fn rustdoc_stamp ( builder : & Builder , compiler : Compiler , target : Interned < String > ) -> PathBuf {
269+ builder. cargo_out ( compiler, Mode :: Tool , target) . join ( ".rustdoc-check.stamp" )
270+ }
0 commit comments