@@ -253,6 +253,47 @@ impl Step for Rls {
253253 }
254254}
255255
256+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
257+ pub struct Rustfmt {
258+ stage : u32 ,
259+ host : Interned < String > ,
260+ }
261+
262+ impl Step for Rustfmt {
263+ type Output = ( ) ;
264+ const ONLY_HOSTS : bool = true ;
265+
266+ fn should_run ( run : ShouldRun ) -> ShouldRun {
267+ run. path ( "src/tools/rustfmt" )
268+ }
269+
270+ fn make_run ( run : RunConfig ) {
271+ run. builder . ensure ( Rustfmt {
272+ stage : run. builder . top_stage ,
273+ host : run. target ,
274+ } ) ;
275+ }
276+
277+ /// Runs `cargo test` for rustfmt.
278+ fn run ( self , builder : & Builder ) {
279+ let build = builder. build ;
280+ let stage = self . stage ;
281+ let host = self . host ;
282+ let compiler = builder. compiler ( stage, host) ;
283+
284+ builder. ensure ( tool:: Rustfmt { compiler, target : self . host } ) ;
285+ let mut cargo = builder. cargo ( compiler, Mode :: Tool , host, "test" ) ;
286+ cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/rustfmt/Cargo.toml" ) ) ;
287+
288+ // Don't build tests dynamically, just a pain to work with
289+ cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
290+
291+ builder. add_rustc_lib_path ( compiler, & mut cargo) ;
292+
293+ try_run ( build, & mut cargo) ;
294+ }
295+ }
296+
256297fn path_for_cargo ( builder : & Builder , compiler : Compiler ) -> OsString {
257298 // Configure PATH to find the right rustc. NB. we have to use PATH
258299 // and not RUSTC because the Cargo test suite has tests that will
0 commit comments