@@ -1966,8 +1966,6 @@ fn add_env(
19661966 target : TargetSelection ,
19671967 built_tools : & HashSet < & ' static str > ,
19681968) {
1969- // envs for wix should be always defined, even if not used
1970- // FIXME: is they affect ccache?
19711969 let mut parts = builder. version . split ( '.' ) ;
19721970 cmd. env ( "CFG_RELEASE_INFO" , builder. rust_version ( ) )
19731971 . env ( "CFG_RELEASE_NUM" , & builder. version )
@@ -1989,26 +1987,14 @@ fn add_env(
19891987 cmd. env ( "CFG_MINGW" , "0" ) . env ( "CFG_ABI" , "MSVC" ) ;
19901988 }
19911989
1992- if built_tools. contains ( "rustfmt" ) {
1993- cmd. env ( "CFG_RUSTFMT" , "1" ) ;
1994- } else {
1995- cmd. env ( "CFG_RUSTFMT" , "0" ) ;
1996- }
1997- if built_tools. contains ( "clippy" ) {
1998- cmd. env ( "CFG_CLIPPY" , "1" ) ;
1999- } else {
2000- cmd. env ( "CFG_CLIPPY" , "0" ) ;
2001- }
2002- if built_tools. contains ( "miri" ) {
2003- cmd. env ( "CFG_MIRI" , "1" ) ;
2004- } else {
2005- cmd. env ( "CFG_MIRI" , "0" ) ;
2006- }
2007- if built_tools. contains ( "rust-analyzer" ) {
2008- cmd. env ( "CFG_RA" , "1" ) ;
2009- } else {
2010- cmd. env ( "CFG_RA" , "0" ) ;
2011- }
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" ) ;
20121998}
20131999
20142000fn install_llvm_file (
0 commit comments