@@ -1585,9 +1585,15 @@ impl Step for Extended {
15851585 prepare ( "cargo" ) ;
15861586 prepare ( "rust-std" ) ;
15871587 prepare ( "rust-analysis" ) ;
1588- prepare ( "clippy" ) ;
1589- prepare ( "rust-analyzer" ) ;
1590- for tool in & [ "rust-docs" , "miri" , "rustc-codegen-cranelift" ] {
1588+
1589+ for tool in & [
1590+ "clippy" ,
1591+ "rustfmt" ,
1592+ "rust-analyzer" ,
1593+ "rust-docs" ,
1594+ "miri" ,
1595+ "rustc-codegen-cranelift" ,
1596+ ] {
15911597 if built_tools. contains ( tool) {
15921598 prepare ( tool) ;
15931599 }
@@ -1627,6 +1633,8 @@ impl Step for Extended {
16271633 "rust-analyzer-preview" . to_string ( )
16281634 } else if name == "clippy" {
16291635 "clippy-preview" . to_string ( )
1636+ } else if name == "rustfmt" {
1637+ "rustfmt-preview" . to_string ( )
16301638 } else if name == "miri" {
16311639 "miri-preview" . to_string ( )
16321640 } else if name == "rustc-codegen-cranelift" {
@@ -1646,7 +1654,7 @@ impl Step for Extended {
16461654 prepare ( "cargo" ) ;
16471655 prepare ( "rust-analysis" ) ;
16481656 prepare ( "rust-std" ) ;
1649- for tool in & [ "clippy" , "rust-analyzer" , "rust-docs" , "miri" ] {
1657+ for tool in & [ "clippy" , "rustfmt" , " rust-analyzer", "rust-docs" , "miri" ] {
16501658 if built_tools. contains ( tool) {
16511659 prepare ( tool) ;
16521660 }
@@ -1764,6 +1772,24 @@ impl Step for Extended {
17641772 . arg ( etc. join ( "msi/remove-duplicates.xsl" ) )
17651773 . run ( builder) ;
17661774 }
1775+ if built_tools. contains ( "rustfmt" ) {
1776+ command ( & heat)
1777+ . current_dir ( & exe)
1778+ . arg ( "dir" )
1779+ . arg ( "rustfmt" )
1780+ . args ( heat_flags)
1781+ . arg ( "-cg" )
1782+ . arg ( "RustFmtGroup" )
1783+ . arg ( "-dr" )
1784+ . arg ( "RustFmt" )
1785+ . arg ( "-var" )
1786+ . arg ( "var.RustFmtDir" )
1787+ . arg ( "-out" )
1788+ . arg ( exe. join ( "RustFmtGroup.wxs" ) )
1789+ . arg ( "-t" )
1790+ . arg ( etc. join ( "msi/remove-duplicates.xsl" ) )
1791+ . run ( builder) ;
1792+ }
17671793 if built_tools. contains ( "miri" ) {
17681794 command ( & heat)
17691795 . current_dir ( & exe)
@@ -1830,11 +1856,14 @@ impl Step for Extended {
18301856 . arg ( "-out" )
18311857 . arg ( & output)
18321858 . arg ( input) ;
1833- add_env ( builder, & mut cmd, target) ;
1859+ add_env ( builder, & mut cmd, target, & built_tools ) ;
18341860
18351861 if built_tools. contains ( "clippy" ) {
18361862 cmd. arg ( "-dClippyDir=clippy" ) ;
18371863 }
1864+ if built_tools. contains ( "rustfmt" ) {
1865+ cmd. arg ( "-dRustFmtDir=rustfmt" ) ;
1866+ }
18381867 if built_tools. contains ( "rust-docs" ) {
18391868 cmd. arg ( "-dDocsDir=rust-docs" ) ;
18401869 }
@@ -1861,6 +1890,9 @@ impl Step for Extended {
18611890 if built_tools. contains ( "clippy" ) {
18621891 candle ( "ClippyGroup.wxs" . as_ref ( ) ) ;
18631892 }
1893+ if built_tools. contains ( "rustfmt" ) {
1894+ candle ( "RustFmtGroup.wxs" . as_ref ( ) ) ;
1895+ }
18641896 if built_tools. contains ( "miri" ) {
18651897 candle ( "MiriGroup.wxs" . as_ref ( ) ) ;
18661898 }
@@ -1899,6 +1931,9 @@ impl Step for Extended {
18991931 if built_tools. contains ( "clippy" ) {
19001932 cmd. arg ( "ClippyGroup.wixobj" ) ;
19011933 }
1934+ if built_tools. contains ( "rustfmt" ) {
1935+ cmd. arg ( "RustFmtGroup.wixobj" ) ;
1936+ }
19021937 if built_tools. contains ( "miri" ) {
19031938 cmd. arg ( "MiriGroup.wixobj" ) ;
19041939 }
@@ -1925,7 +1960,12 @@ impl Step for Extended {
19251960 }
19261961}
19271962
1928- fn add_env ( builder : & Builder < ' _ > , cmd : & mut BootstrapCommand , target : TargetSelection ) {
1963+ fn add_env (
1964+ builder : & Builder < ' _ > ,
1965+ cmd : & mut BootstrapCommand ,
1966+ target : TargetSelection ,
1967+ built_tools : & HashSet < & ' static str > ,
1968+ ) {
19291969 let mut parts = builder. version . split ( '.' ) ;
19301970 cmd. env ( "CFG_RELEASE_INFO" , builder. rust_version ( ) )
19311971 . env ( "CFG_RELEASE_NUM" , & builder. version )
@@ -1946,6 +1986,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
19461986 } else {
19471987 cmd. env ( "CFG_MINGW" , "0" ) . env ( "CFG_ABI" , "MSVC" ) ;
19481988 }
1989+
1990+ // ensure these variables are defined
1991+ let mut define_optional_tool = |tool_name : & str , env_name : & str | {
1992+ cmd. env ( env_name, if built_tools. contains ( tool_name) { "1" } else { "0" } ) ;
1993+ } ;
1994+ define_optional_tool ( "rustfmt" , "CFG_RUSTFMT" ) ;
1995+ define_optional_tool ( "clippy" , "CFG_CLIPPY" ) ;
1996+ define_optional_tool ( "miri" , "CFG_MIRI" ) ;
1997+ define_optional_tool ( "rust-analyzer" , "CFG_RA" ) ;
19491998}
19501999
19512000fn install_llvm_file (
0 commit comments