@@ -17,7 +17,7 @@ fn get_compile_options(
1717 config : & Config ,
1818 features : & Option < Vec < String > > ,
1919 package : & Package ,
20- bench : & str ,
20+ benches : Vec < & str > ,
2121) -> Result < CompileOptions > {
2222 let mut compile_opts = CompileOptions :: new ( config, CompileMode :: Build ) ?;
2323 compile_opts. spec = Packages :: Packages ( vec ! [ package. name( ) . to_string( ) ] ) ;
@@ -38,7 +38,7 @@ fn get_compile_options(
3838 false ,
3939 vec ! [ ] ,
4040 false ,
41- vec ! [ bench . into ( ) ] ,
41+ benches . iter ( ) . map ( |s| s . to_string ( ) ) . collect ( ) ,
4242 false ,
4343 false ,
4444 ) ;
@@ -92,27 +92,20 @@ pub fn build_benches(
9292 ) ?;
9393
9494 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 ( ) ;
116109
117110 if built_benches. is_empty ( ) {
118111 bail ! (
@@ -121,6 +114,10 @@ pub fn build_benches(
121114 ) ;
122115 }
123116
117+ ws. config ( )
118+ . shell ( )
119+ . status_with_color ( "Built" , benches_names_str, Color :: Green ) ?;
120+
124121 let mut codspeed_target_dir = get_codspeed_dir ( ws) ;
125122 create_dir_all ( & codspeed_target_dir) ?;
126123 if let Some ( name) = package_name. as_ref ( ) {
@@ -129,14 +126,16 @@ pub fn build_benches(
129126 }
130127 clear_dir ( & codspeed_target_dir) ?;
131128
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) ?;
135134 }
136135
137136 ws. config ( ) . shell ( ) . status_with_color (
138137 "Finished" ,
139- format ! ( "built {} benchmark suite(s)" , built_benches . len( ) ) ,
138+ format ! ( "built {} benchmark suite(s)" , benches . len( ) ) ,
140139 Color :: Green ,
141140 ) ?;
142141
0 commit comments