@@ -1632,9 +1632,15 @@ impl Step for Extended {
16321632 prepare ( "cargo" ) ;
16331633 prepare ( "rust-std" ) ;
16341634 prepare ( "rust-analysis" ) ;
1635- prepare ( "clippy" ) ;
1636- prepare ( "rust-analyzer" ) ;
1637- for tool in & [ "rust-docs" , "miri" , "rustc-codegen-cranelift" ] {
1635+
1636+ for tool in & [
1637+ "clippy" ,
1638+ "rustfmt" ,
1639+ "rust-analyzer" ,
1640+ "rust-docs" ,
1641+ "miri" ,
1642+ "rustc-codegen-cranelift" ,
1643+ ] {
16381644 if built_tools. contains ( tool) {
16391645 prepare ( tool) ;
16401646 }
@@ -1674,6 +1680,8 @@ impl Step for Extended {
16741680 "rust-analyzer-preview" . to_string ( )
16751681 } else if name == "clippy" {
16761682 "clippy-preview" . to_string ( )
1683+ } else if name == "rustfmt" {
1684+ "rustfmt-preview" . to_string ( )
16771685 } else if name == "miri" {
16781686 "miri-preview" . to_string ( )
16791687 } else if name == "rustc-codegen-cranelift" {
@@ -1693,7 +1701,7 @@ impl Step for Extended {
16931701 prepare ( "cargo" ) ;
16941702 prepare ( "rust-analysis" ) ;
16951703 prepare ( "rust-std" ) ;
1696- for tool in & [ "clippy" , "rust-analyzer" , "rust-docs" , "miri" ] {
1704+ for tool in & [ "clippy" , "rustfmt" , " rust-analyzer", "rust-docs" , "miri" ] {
16971705 if built_tools. contains ( tool) {
16981706 prepare ( tool) ;
16991707 }
@@ -1811,6 +1819,24 @@ impl Step for Extended {
18111819 . arg ( etc. join ( "msi/remove-duplicates.xsl" ) )
18121820 . run ( builder) ;
18131821 }
1822+ if built_tools. contains ( "rustfmt" ) {
1823+ command ( & heat)
1824+ . current_dir ( & exe)
1825+ . arg ( "dir" )
1826+ . arg ( "rustfmt" )
1827+ . args ( heat_flags)
1828+ . arg ( "-cg" )
1829+ . arg ( "RustFmtGroup" )
1830+ . arg ( "-dr" )
1831+ . arg ( "RustFmt" )
1832+ . arg ( "-var" )
1833+ . arg ( "var.RustFmtDir" )
1834+ . arg ( "-out" )
1835+ . arg ( exe. join ( "RustFmtGroup.wxs" ) )
1836+ . arg ( "-t" )
1837+ . arg ( etc. join ( "msi/remove-duplicates.xsl" ) )
1838+ . run ( builder) ;
1839+ }
18141840 if built_tools. contains ( "miri" ) {
18151841 command ( & heat)
18161842 . current_dir ( & exe)
@@ -1877,11 +1903,14 @@ impl Step for Extended {
18771903 . arg ( "-out" )
18781904 . arg ( & output)
18791905 . arg ( input) ;
1880- add_env ( builder, & mut cmd, target) ;
1906+ add_env ( builder, & mut cmd, target, & built_tools ) ;
18811907
18821908 if built_tools. contains ( "clippy" ) {
18831909 cmd. arg ( "-dClippyDir=clippy" ) ;
18841910 }
1911+ if built_tools. contains ( "rustfmt" ) {
1912+ cmd. arg ( "-dRustFmtDir=rustfmt" ) ;
1913+ }
18851914 if built_tools. contains ( "rust-docs" ) {
18861915 cmd. arg ( "-dDocsDir=rust-docs" ) ;
18871916 }
@@ -1908,6 +1937,9 @@ impl Step for Extended {
19081937 if built_tools. contains ( "clippy" ) {
19091938 candle ( "ClippyGroup.wxs" . as_ref ( ) ) ;
19101939 }
1940+ if built_tools. contains ( "rustfmt" ) {
1941+ candle ( "RustFmtGroup.wxs" . as_ref ( ) ) ;
1942+ }
19111943 if built_tools. contains ( "miri" ) {
19121944 candle ( "MiriGroup.wxs" . as_ref ( ) ) ;
19131945 }
@@ -1946,6 +1978,9 @@ impl Step for Extended {
19461978 if built_tools. contains ( "clippy" ) {
19471979 cmd. arg ( "ClippyGroup.wixobj" ) ;
19481980 }
1981+ if built_tools. contains ( "rustfmt" ) {
1982+ cmd. arg ( "RustFmtGroup.wixobj" ) ;
1983+ }
19491984 if built_tools. contains ( "miri" ) {
19501985 cmd. arg ( "MiriGroup.wixobj" ) ;
19511986 }
@@ -1972,7 +2007,12 @@ impl Step for Extended {
19722007 }
19732008}
19742009
1975- fn add_env ( builder : & Builder < ' _ > , cmd : & mut BootstrapCommand , target : TargetSelection ) {
2010+ fn add_env (
2011+ builder : & Builder < ' _ > ,
2012+ cmd : & mut BootstrapCommand ,
2013+ target : TargetSelection ,
2014+ built_tools : & HashSet < & ' static str > ,
2015+ ) {
19762016 let mut parts = builder. version . split ( '.' ) ;
19772017 cmd. env ( "CFG_RELEASE_INFO" , builder. rust_version ( ) )
19782018 . env ( "CFG_RELEASE_NUM" , & builder. version )
@@ -1993,6 +2033,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
19932033 } else {
19942034 cmd. env ( "CFG_MINGW" , "0" ) . env ( "CFG_ABI" , "MSVC" ) ;
19952035 }
2036+
2037+ // ensure these variables are defined
2038+ let mut define_optional_tool = |tool_name : & str , env_name : & str | {
2039+ cmd. env ( env_name, if built_tools. contains ( tool_name) { "1" } else { "0" } ) ;
2040+ } ;
2041+ define_optional_tool ( "rustfmt" , "CFG_RUSTFMT" ) ;
2042+ define_optional_tool ( "clippy" , "CFG_CLIPPY" ) ;
2043+ define_optional_tool ( "miri" , "CFG_MIRI" ) ;
2044+ define_optional_tool ( "rust-analyzer" , "CFG_RA" ) ;
19962045}
19972046
19982047fn install_llvm_file (
0 commit comments