@@ -1007,102 +1007,150 @@ impl Step for LibcxxVersionTool {
1007
1007
}
1008
1008
1009
1009
macro_rules! tool_extended {
1010
- ( ( $sel: ident, $builder: ident) ,
1011
- $( $name: ident,
1012
- $path: expr,
1013
- $tool_name: expr,
1014
- stable = $stable: expr
1015
- $( , tool_std = $tool_std: literal) ?
1016
- $( , allow_features = $allow_features: expr) ?
1017
- $( , add_bins_to_sysroot = $add_bins_to_sysroot: expr) ?
1018
- ; ) +) => {
1019
- $(
1020
- #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
1010
+ (
1011
+ $name: ident {
1012
+ path: $path: expr,
1013
+ tool_name: $tool_name: expr,
1014
+ stable: $stable: expr
1015
+ $( , add_bins_to_sysroot: $add_bins_to_sysroot: expr ) ?
1016
+ $( , ) ?
1017
+ }
1018
+ ) => {
1019
+ #[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
1021
1020
pub struct $name {
1022
1021
pub compiler: Compiler ,
1023
1022
pub target: TargetSelection ,
1024
- pub extra_features: Vec <String >,
1025
1023
}
1026
1024
1027
1025
impl Step for $name {
1028
1026
type Output = PathBuf ;
1029
- const DEFAULT : bool = true ; // Overwritten below
1027
+ const DEFAULT : bool = true ; // Overridden by `should_run_tool_build_step`
1030
1028
const ONLY_HOSTS : bool = true ;
1031
1029
1032
1030
fn should_run( run: ShouldRun <' _>) -> ShouldRun <' _> {
1033
- let builder = run. builder;
1034
- run. path( $path) . default_condition(
1035
- builder. config. extended
1036
- && builder. config. tools. as_ref( ) . map_or(
1037
- // By default, on nightly/dev enable all tools, else only
1038
- // build stable tools.
1039
- $stable || builder. build. unstable_features( ) ,
1040
- // If `tools` is set, search list for this tool.
1041
- |tools| {
1042
- tools. iter( ) . any( |tool| match tool. as_ref( ) {
1043
- "clippy" => $tool_name == "clippy-driver" ,
1044
- x => $tool_name == x,
1045
- } )
1046
- } ) ,
1031
+ should_run_tool_build_step(
1032
+ run,
1033
+ $tool_name,
1034
+ $path,
1035
+ $stable,
1047
1036
)
1048
1037
}
1049
1038
1050
1039
fn make_run( run: RunConfig <' _>) {
1051
1040
run. builder. ensure( $name {
1052
1041
compiler: run. builder. compiler( run. builder. top_stage, run. builder. config. build) ,
1053
1042
target: run. target,
1054
- extra_features: Vec :: new( ) ,
1055
1043
} ) ;
1056
1044
}
1057
1045
1058
- #[ allow( unused_mut) ]
1059
- fn run( mut $sel, $builder: & Builder <' _>) -> PathBuf {
1060
- let tool = $builder. ensure( ToolBuild {
1061
- compiler: $sel. compiler,
1062
- target: $sel. target,
1063
- tool: $tool_name,
1064
- mode: if false $( || $tool_std) ? { Mode :: ToolStd } else { Mode :: ToolRustc } ,
1065
- path: $path,
1066
- extra_features: $sel. extra_features,
1067
- source_type: SourceType :: InTree ,
1068
- allow_features: concat!( $( $allow_features) * ) ,
1069
- cargo_args: vec![ ]
1070
- } ) ;
1071
-
1072
- if ( false $( || !$add_bins_to_sysroot. is_empty( ) ) ?) && $sel. compiler. stage > 0 {
1073
- let bindir = $builder. sysroot( $sel. compiler) . join( "bin" ) ;
1074
- t!( fs:: create_dir_all( & bindir) ) ;
1075
-
1076
- #[ allow( unused_variables) ]
1077
- let tools_out = $builder
1078
- . cargo_out( $sel. compiler, Mode :: ToolRustc , $sel. target) ;
1046
+ fn run( self , builder: & Builder <' _>) -> PathBuf {
1047
+ let Self { compiler, target } = self ;
1048
+ run_tool_build_step(
1049
+ builder,
1050
+ compiler,
1051
+ target,
1052
+ $tool_name,
1053
+ $path,
1054
+ None $( . or( Some ( & $add_bins_to_sysroot) ) ) ?,
1055
+ )
1056
+ }
1057
+ }
1058
+ }
1059
+ }
1079
1060
1080
- $( for add_bin in $add_bins_to_sysroot {
1081
- let bin_source = tools_out. join( exe( add_bin, $sel. target) ) ;
1082
- let bin_destination = bindir. join( exe( add_bin, $sel. compiler. host) ) ;
1083
- $builder. copy_link( & bin_source, & bin_destination) ;
1084
- } ) ?
1061
+ fn should_run_tool_build_step < ' a > (
1062
+ run : ShouldRun < ' a > ,
1063
+ tool_name : & ' static str ,
1064
+ path : & ' static str ,
1065
+ stable : bool ,
1066
+ ) -> ShouldRun < ' a > {
1067
+ let builder = run. builder ;
1068
+ run. path ( path) . default_condition (
1069
+ builder. config . extended
1070
+ && builder. config . tools . as_ref ( ) . map_or (
1071
+ // By default, on nightly/dev enable all tools, else only
1072
+ // build stable tools.
1073
+ stable || builder. build . unstable_features ( ) ,
1074
+ // If `tools` is set, search list for this tool.
1075
+ |tools| {
1076
+ tools. iter ( ) . any ( |tool| match tool. as_ref ( ) {
1077
+ "clippy" => tool_name == "clippy-driver" ,
1078
+ x => tool_name == x,
1079
+ } )
1080
+ } ,
1081
+ ) ,
1082
+ )
1083
+ }
1085
1084
1086
- let tool = bindir. join( exe( $tool_name, $sel. compiler. host) ) ;
1087
- tool
1088
- } else {
1089
- tool
1090
- }
1091
- }
1085
+ fn run_tool_build_step (
1086
+ builder : & Builder < ' _ > ,
1087
+ compiler : Compiler ,
1088
+ target : TargetSelection ,
1089
+ tool_name : & ' static str ,
1090
+ path : & ' static str ,
1091
+ add_bins_to_sysroot : Option < & [ & str ] > ,
1092
+ ) -> PathBuf {
1093
+ let tool = builder. ensure ( ToolBuild {
1094
+ compiler,
1095
+ target,
1096
+ tool : tool_name,
1097
+ mode : Mode :: ToolRustc ,
1098
+ path,
1099
+ extra_features : vec ! [ ] ,
1100
+ source_type : SourceType :: InTree ,
1101
+ allow_features : "" ,
1102
+ cargo_args : vec ! [ ] ,
1103
+ } ) ;
1104
+
1105
+ // FIXME: This should just be an if-let-chain, but those are unstable.
1106
+ if let Some ( add_bins_to_sysroot) =
1107
+ add_bins_to_sysroot. filter ( |bins| !bins. is_empty ( ) && compiler. stage > 0 )
1108
+ {
1109
+ let bindir = builder. sysroot ( compiler) . join ( "bin" ) ;
1110
+ t ! ( fs:: create_dir_all( & bindir) ) ;
1111
+
1112
+ let tools_out = builder. cargo_out ( compiler, Mode :: ToolRustc , target) ;
1113
+
1114
+ for add_bin in add_bins_to_sysroot {
1115
+ let bin_source = tools_out. join ( exe ( add_bin, target) ) ;
1116
+ let bin_destination = bindir. join ( exe ( add_bin, compiler. host ) ) ;
1117
+ builder. copy_link ( & bin_source, & bin_destination) ;
1092
1118
}
1093
- ) +
1119
+
1120
+ // Return a path into the bin dir.
1121
+ bindir. join ( exe ( tool_name, compiler. host ) )
1122
+ } else {
1123
+ tool
1094
1124
}
1095
1125
}
1096
1126
1097
- tool_extended ! ( ( self , builder) ,
1098
- Cargofmt , "src/tools/rustfmt" , "cargo-fmt" , stable=true ;
1099
- CargoClippy , "src/tools/clippy" , "cargo-clippy" , stable=true ;
1100
- Clippy , "src/tools/clippy" , "clippy-driver" , stable=true , add_bins_to_sysroot = [ "clippy-driver" , "cargo-clippy" ] ;
1101
- Miri , "src/tools/miri" , "miri" , stable=false , add_bins_to_sysroot = [ "miri" ] ;
1102
- CargoMiri , "src/tools/miri/cargo-miri" , "cargo-miri" , stable=false , add_bins_to_sysroot = [ "cargo-miri" ] ;
1103
- Rls , "src/tools/rls" , "rls" , stable=true ;
1104
- Rustfmt , "src/tools/rustfmt" , "rustfmt" , stable=true , add_bins_to_sysroot = [ "rustfmt" , "cargo-fmt" ] ;
1105
- ) ;
1127
+ tool_extended ! ( Cargofmt { path: "src/tools/rustfmt" , tool_name: "cargo-fmt" , stable: true } ) ;
1128
+ tool_extended ! ( CargoClippy { path: "src/tools/clippy" , tool_name: "cargo-clippy" , stable: true } ) ;
1129
+ tool_extended ! ( Clippy {
1130
+ path: "src/tools/clippy" ,
1131
+ tool_name: "clippy-driver" ,
1132
+ stable: true ,
1133
+ add_bins_to_sysroot: [ "clippy-driver" , "cargo-clippy" ]
1134
+ } ) ;
1135
+ tool_extended ! ( Miri {
1136
+ path: "src/tools/miri" ,
1137
+ tool_name: "miri" ,
1138
+ stable: false ,
1139
+ add_bins_to_sysroot: [ "miri" ]
1140
+ } ) ;
1141
+ tool_extended ! ( CargoMiri {
1142
+ path: "src/tools/miri/cargo-miri" ,
1143
+ tool_name: "cargo-miri" ,
1144
+ stable: false ,
1145
+ add_bins_to_sysroot: [ "cargo-miri" ]
1146
+ } ) ;
1147
+ tool_extended ! ( Rls { path: "src/tools/rls" , tool_name: "rls" , stable: true } ) ;
1148
+ tool_extended ! ( Rustfmt {
1149
+ path: "src/tools/rustfmt" ,
1150
+ tool_name: "rustfmt" ,
1151
+ stable: true ,
1152
+ add_bins_to_sysroot: [ "rustfmt" , "cargo-fmt" ]
1153
+ } ) ;
1106
1154
1107
1155
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1108
1156
pub struct TestFloatParse {
0 commit comments