@@ -7,10 +7,10 @@ use std::path::PathBuf;
77use super :: test_helpers:: run_cargo_test;
88use crate :: Mode ;
99use crate :: core:: build_steps:: compile;
10- use crate :: core:: build_steps:: tool:: { self , SourceType } ;
11- use crate :: core:: builder:: { Builder , RunConfig , ShouldRun , Step } ;
10+ use crate :: core:: build_steps:: tool:: { self , SourceType , Tool } ;
11+ use crate :: core:: builder:: { Builder , Compiler , RunConfig , ShouldRun , Step } ;
1212use crate :: core:: config:: TargetSelection ;
13- use crate :: utils:: helpers:: { dylib_path, dylib_path_var} ;
13+ use crate :: utils:: helpers:: { LldThreads , dylib_path, dylib_path_var, linker_args } ;
1414
1515/// Rustdoc is special in various ways, which is why this step is different from `Crate`.
1616#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -168,3 +168,40 @@ impl Step for CrateRustdocJsonTypes {
168168 ) ;
169169 }
170170}
171+
172+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
173+ pub struct RustdocTheme {
174+ pub compiler : Compiler ,
175+ }
176+
177+ impl Step for RustdocTheme {
178+ type Output = ( ) ;
179+ const DEFAULT : bool = true ;
180+ const ONLY_HOSTS : bool = true ;
181+
182+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
183+ run. path ( "src/tools/rustdoc-themes" )
184+ }
185+
186+ fn make_run ( run : RunConfig < ' _ > ) {
187+ let compiler = run. builder . compiler ( run. builder . top_stage , run. target ) ;
188+
189+ run. builder . ensure ( RustdocTheme { compiler } ) ;
190+ }
191+
192+ fn run ( self , builder : & Builder < ' _ > ) {
193+ let rustdoc = builder. bootstrap_out . join ( "rustdoc" ) ;
194+ let mut cmd = builder. tool_cmd ( Tool :: RustdocTheme ) ;
195+ cmd. arg ( rustdoc. to_str ( ) . unwrap ( ) )
196+ . arg ( builder. src . join ( "src/librustdoc/html/static/css/rustdoc.css" ) . to_str ( ) . unwrap ( ) )
197+ . env ( "RUSTC_STAGE" , self . compiler . stage . to_string ( ) )
198+ . env ( "RUSTC_SYSROOT" , builder. sysroot ( self . compiler ) )
199+ . env ( "RUSTDOC_LIBDIR" , builder. sysroot_target_libdir ( self . compiler , self . compiler . host ) )
200+ . env ( "CFG_RELEASE_CHANNEL" , & builder. config . channel )
201+ . env ( "RUSTDOC_REAL" , builder. rustdoc ( self . compiler ) )
202+ . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
203+ cmd. args ( linker_args ( builder, self . compiler . host , LldThreads :: No ) ) ;
204+
205+ cmd. delay_failure ( ) . run ( builder) ;
206+ }
207+ }
0 commit comments