@@ -17,7 +17,7 @@ fn get_compile_options(
17
17
config : & Config ,
18
18
features : & Option < Vec < String > > ,
19
19
package : & Package ,
20
- bench : & str ,
20
+ benches : Vec < & str > ,
21
21
) -> Result < CompileOptions > {
22
22
let mut compile_opts = CompileOptions :: new ( config, CompileMode :: Build ) ?;
23
23
compile_opts. spec = Packages :: Packages ( vec ! [ package. name( ) . to_string( ) ] ) ;
@@ -38,7 +38,7 @@ fn get_compile_options(
38
38
false ,
39
39
vec ! [ ] ,
40
40
false ,
41
- vec ! [ bench . into ( ) ] ,
41
+ benches . iter ( ) . map ( |s| s . to_string ( ) ) . collect ( ) ,
42
42
false ,
43
43
false ,
44
44
) ;
@@ -92,27 +92,20 @@ pub fn build_benches(
92
92
) ?;
93
93
94
94
let config = ws. config ( ) ;
95
- let mut built_benches = vec ! [ ] ;
96
- for bench in benches {
97
- ws. config ( )
98
- . shell ( )
99
- . status_with_color ( "Building" , bench. name ( ) , Color :: Yellow ) ?;
100
- let compile_opts = get_compile_options ( config, & features, package, bench. name ( ) ) ?;
101
- let result = cargo:: ops:: compile ( ws, & compile_opts) ?;
102
- let built_targets = result
103
- . tests
104
- . into_iter ( )
105
- . filter ( |u| u. unit . target . is_bench ( ) )
106
- . collect_vec ( ) ;
107
- if let Some ( built_bench) = built_targets. into_iter ( ) . next ( ) {
108
- built_benches. push ( built_bench) ;
109
- } else {
110
- bail ! ( "No benchmark target found." )
111
- }
112
- ws. config ( )
113
- . shell ( )
114
- . status_with_color ( "Built" , bench. name ( ) , Color :: Green ) ?;
115
- }
95
+
96
+ let benches_names = benches. iter ( ) . map ( |t| t. name ( ) ) . collect_vec ( ) ;
97
+ let benches_names_str = benches_names. join ( ", " ) ;
98
+
99
+ ws. config ( )
100
+ . shell ( )
101
+ . status_with_color ( "Building" , benches_names_str. clone ( ) , Color :: Yellow ) ?;
102
+ let compile_opts = get_compile_options ( config, & features, package, benches_names) ?;
103
+ let result = cargo:: ops:: compile ( ws, & compile_opts) ?;
104
+ let built_benches = result
105
+ . tests
106
+ . into_iter ( )
107
+ . filter ( |u| u. unit . target . is_bench ( ) )
108
+ . collect_vec ( ) ;
116
109
117
110
if built_benches. is_empty ( ) {
118
111
bail ! (
@@ -121,6 +114,10 @@ pub fn build_benches(
121
114
) ;
122
115
}
123
116
117
+ ws. config ( )
118
+ . shell ( )
119
+ . status_with_color ( "Built" , benches_names_str, Color :: Green ) ?;
120
+
124
121
let mut codspeed_target_dir = get_codspeed_dir ( ws) ;
125
122
create_dir_all ( & codspeed_target_dir) ?;
126
123
if let Some ( name) = package_name. as_ref ( ) {
@@ -129,14 +126,16 @@ pub fn build_benches(
129
126
}
130
127
clear_dir ( & codspeed_target_dir) ?;
131
128
132
- for bench in built_benches. iter ( ) {
133
- let bench_dest = codspeed_target_dir. clone ( ) . join ( bench. unit . target . name ( ) ) ;
134
- std:: fs:: copy ( bench. path . clone ( ) , bench_dest) ?;
129
+ for built_bench in built_benches. iter ( ) {
130
+ let bench_dest = codspeed_target_dir
131
+ . clone ( )
132
+ . join ( built_bench. unit . target . name ( ) ) ;
133
+ std:: fs:: copy ( built_bench. path . clone ( ) , bench_dest) ?;
135
134
}
136
135
137
136
ws. config ( ) . shell ( ) . status_with_color (
138
137
"Finished" ,
139
- format ! ( "built {} benchmark suite(s)" , built_benches . len( ) ) ,
138
+ format ! ( "built {} benchmark suite(s)" , benches . len( ) ) ,
140
139
Color :: Green ,
141
140
) ?;
142
141
0 commit comments