11use crate :: {
22 app:: { BenchTargetFilters , PackageFilters } ,
33 helpers:: { clear_dir, get_codspeed_target_dir} ,
4- measurement_mode:: MeasurementMode ,
4+ measurement_mode:: { BuildMode , MeasurementMode } ,
55 prelude:: * ,
66} ;
77use anyhow:: Context ;
@@ -84,11 +84,11 @@ impl BuildOptions<'_> {
8484 & self ,
8585 metadata : & Metadata ,
8686 quiet : bool ,
87- measurement_mode : MeasurementMode ,
87+ build_mode : BuildMode ,
8888 ) -> Result < Vec < BuiltBench > > {
8989 let workspace_packages = metadata. workspace_packages ( ) ;
9090
91- let mut cargo = self . build_command ( measurement_mode ) ;
91+ let mut cargo = self . build_command ( build_mode ) ;
9292 if quiet {
9393 cargo. arg ( "--quiet" ) ;
9494 }
@@ -211,7 +211,7 @@ See `cargo codspeed build --help` for more information.");
211211 /// completely overrides rustflags from cargo config
212212 /// We use the cargo built-in config mechanism to set the flags if the user has not set
213213 /// `RUSTFLAGS`.
214- fn add_rust_flags ( & self , cargo : & mut Command , measurement_mode : MeasurementMode ) {
214+ fn add_rust_flags ( & self , cargo : & mut Command , build_mode : BuildMode ) {
215215 let mut flags = vec ! [
216216 // Add debug info (equivalent to -g)
217217 "-Cdebuginfo=2" . to_owned( ) ,
@@ -226,9 +226,7 @@ See `cargo codspeed build --help` for more information.");
226226 ] ;
227227
228228 // Add the codspeed cfg flag if the benchmark should only run once
229- if measurement_mode == MeasurementMode :: Simulation
230- || measurement_mode == MeasurementMode :: Analysis
231- {
229+ if build_mode == BuildMode :: Analysis {
232230 flags. push ( "--cfg=codspeed" . to_owned ( ) ) ;
233231 }
234232
@@ -254,7 +252,7 @@ See `cargo codspeed build --help` for more information.");
254252
255253 /// Generates a subcommand to build the benchmarks by invoking cargo and forwarding the filters
256254 /// This command explicitly ignores the `self.benches`: all benches are built
257- fn build_command ( & self , measurement_mode : MeasurementMode ) -> Command {
255+ fn build_command ( & self , build_mode : BuildMode ) -> Command {
258256 let mut cargo = Command :: new ( "cargo" ) ;
259257 cargo. arg ( "build" ) ;
260258
@@ -266,7 +264,7 @@ See `cargo codspeed build --help` for more information.");
266264 cargo. args ( [ "--benches" ] ) ;
267265 }
268266
269- self . add_rust_flags ( & mut cargo, measurement_mode ) ;
267+ self . add_rust_flags ( & mut cargo, build_mode ) ;
270268
271269 if let Some ( features) = self . features {
272270 cargo. arg ( "--features" ) . arg ( features. join ( "," ) ) ;
@@ -303,14 +301,15 @@ impl PackageFilters {
303301}
304302
305303pub fn build_benches ( metadata : & Metadata , config : BuildConfig ) -> Result < ( ) > {
304+ let build_mode = config. measurement_mode . into ( ) ;
306305 let built_benches = BuildOptions {
307306 bench_target_filters : config. bench_target_filters ,
308307 package_filters : config. package_filters ,
309308 features : & config. features ,
310309 profile : & config. profile ,
311310 passthrough_flags : & config. passthrough_flags ,
312311 }
313- . build ( metadata, config. quiet , config . measurement_mode ) ?;
312+ . build ( metadata, config. quiet , build_mode ) ?;
314313
315314 if built_benches. is_empty ( ) {
316315 bail ! (
@@ -319,7 +318,7 @@ pub fn build_benches(metadata: &Metadata, config: BuildConfig) -> Result<()> {
319318 ) ;
320319 }
321320
322- let codspeed_target_dir = get_codspeed_target_dir ( metadata, config . measurement_mode ) ;
321+ let codspeed_target_dir = get_codspeed_target_dir ( metadata, build_mode ) ;
323322 let built_bench_count = built_benches. len ( ) ;
324323
325324 // Create and clear packages codspeed target directories
0 commit comments