@@ -1585,9 +1585,15 @@ impl Step for Extended {
1585
1585
prepare ( "cargo" ) ;
1586
1586
prepare ( "rust-std" ) ;
1587
1587
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
+ ] {
1591
1597
if built_tools. contains ( tool) {
1592
1598
prepare ( tool) ;
1593
1599
}
@@ -1627,6 +1633,8 @@ impl Step for Extended {
1627
1633
"rust-analyzer-preview" . to_string ( )
1628
1634
} else if name == "clippy" {
1629
1635
"clippy-preview" . to_string ( )
1636
+ } else if name == "rustfmt" {
1637
+ "rustfmt-preview" . to_string ( )
1630
1638
} else if name == "miri" {
1631
1639
"miri-preview" . to_string ( )
1632
1640
} else if name == "rustc-codegen-cranelift" {
@@ -1646,7 +1654,7 @@ impl Step for Extended {
1646
1654
prepare ( "cargo" ) ;
1647
1655
prepare ( "rust-analysis" ) ;
1648
1656
prepare ( "rust-std" ) ;
1649
- for tool in & [ "clippy" , "rust-analyzer" , "rust-docs" , "miri" ] {
1657
+ for tool in & [ "clippy" , "rustfmt" , " rust-analyzer", "rust-docs" , "miri" ] {
1650
1658
if built_tools. contains ( tool) {
1651
1659
prepare ( tool) ;
1652
1660
}
@@ -1764,6 +1772,24 @@ impl Step for Extended {
1764
1772
. arg ( etc. join ( "msi/remove-duplicates.xsl" ) )
1765
1773
. run ( builder) ;
1766
1774
}
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
+ }
1767
1793
if built_tools. contains ( "miri" ) {
1768
1794
command ( & heat)
1769
1795
. current_dir ( & exe)
@@ -1830,11 +1856,14 @@ impl Step for Extended {
1830
1856
. arg ( "-out" )
1831
1857
. arg ( & output)
1832
1858
. arg ( input) ;
1833
- add_env ( builder, & mut cmd, target) ;
1859
+ add_env ( builder, & mut cmd, target, & built_tools ) ;
1834
1860
1835
1861
if built_tools. contains ( "clippy" ) {
1836
1862
cmd. arg ( "-dClippyDir=clippy" ) ;
1837
1863
}
1864
+ if built_tools. contains ( "rustfmt" ) {
1865
+ cmd. arg ( "-dRustFmtDir=rustfmt" ) ;
1866
+ }
1838
1867
if built_tools. contains ( "rust-docs" ) {
1839
1868
cmd. arg ( "-dDocsDir=rust-docs" ) ;
1840
1869
}
@@ -1861,6 +1890,9 @@ impl Step for Extended {
1861
1890
if built_tools. contains ( "clippy" ) {
1862
1891
candle ( "ClippyGroup.wxs" . as_ref ( ) ) ;
1863
1892
}
1893
+ if built_tools. contains ( "rustfmt" ) {
1894
+ candle ( "RustFmtGroup.wxs" . as_ref ( ) ) ;
1895
+ }
1864
1896
if built_tools. contains ( "miri" ) {
1865
1897
candle ( "MiriGroup.wxs" . as_ref ( ) ) ;
1866
1898
}
@@ -1899,6 +1931,9 @@ impl Step for Extended {
1899
1931
if built_tools. contains ( "clippy" ) {
1900
1932
cmd. arg ( "ClippyGroup.wixobj" ) ;
1901
1933
}
1934
+ if built_tools. contains ( "rustfmt" ) {
1935
+ cmd. arg ( "RustFmtGroup.wixobj" ) ;
1936
+ }
1902
1937
if built_tools. contains ( "miri" ) {
1903
1938
cmd. arg ( "MiriGroup.wixobj" ) ;
1904
1939
}
@@ -1925,7 +1960,12 @@ impl Step for Extended {
1925
1960
}
1926
1961
}
1927
1962
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
+ ) {
1929
1969
let mut parts = builder. version . split ( '.' ) ;
1930
1970
cmd. env ( "CFG_RELEASE_INFO" , builder. rust_version ( ) )
1931
1971
. env ( "CFG_RELEASE_NUM" , & builder. version )
@@ -1946,6 +1986,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
1946
1986
} else {
1947
1987
cmd. env ( "CFG_MINGW" , "0" ) . env ( "CFG_ABI" , "MSVC" ) ;
1948
1988
}
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" ) ;
1949
1998
}
1950
1999
1951
2000
fn install_llvm_file (
0 commit comments