@@ -207,6 +207,15 @@ impl Xtasks {
207207 }
208208 }
209209
210+ // TODO: have a global args struct instead of this
211+ fn set_cargo_profile ( profile : & str ) {
212+ std:: env:: set_var ( "BMS_CARGO_PROFILE" , profile) ;
213+ }
214+
215+ fn get_cargo_profile ( ) -> Option < String > {
216+ Some ( std:: env:: var ( "BMS_CARGO_PROFILE" ) . unwrap_or_default ( ) )
217+ }
218+
210219 fn cargo_metadata ( ) -> Result < cargo_metadata:: Metadata > {
211220 let cargo_manifest_path = std:: env:: var ( "CARGO_MANIFEST_PATH" ) . unwrap ( ) ;
212221
@@ -227,6 +236,14 @@ impl Xtasks {
227236 Ok ( workspace_dir. join ( dir) )
228237 }
229238
239+ fn append_rustflags ( flag : & str ) {
240+ let rustflags = std:: env:: var ( "RUSTFLAGS" ) . unwrap_or_default ( ) ;
241+ let mut flags = rustflags. split ( ' ' ) . collect :: < Vec < _ > > ( ) ;
242+ flags. push ( flag) ;
243+ let flags = flags. join ( " " ) ;
244+ std:: env:: set_var ( "RUSTFLAGS" , flags) ;
245+ }
246+
230247 fn run_system_command < I : IntoIterator < Item = impl AsRef < OsStr > > > (
231248 command : & str ,
232249 context : & str ,
@@ -281,6 +298,12 @@ impl Xtasks {
281298 . to_owned ( )
282299 } ) ) ;
283300
301+ let profile = Self :: get_cargo_profile ( ) ;
302+ if let Some ( profile) = profile {
303+ args. push ( "--profile" . to_owned ( ) ) ;
304+ args. push ( profile) ;
305+ }
306+
284307 let working_dir = match dir {
285308 Some ( d) => Self :: relative_workspace_dir ( d) ?,
286309 None => Self :: workspace_dir ( ) ?,
@@ -405,7 +428,8 @@ impl Xtasks {
405428 fn test ( features : Features ) -> Result < ( ) > {
406429 // run cargo test with instrumentation
407430 std:: env:: set_var ( "CARGO_INCREMENTAL" , "0" ) ;
408- std:: env:: set_var ( "RUSTFLAGS" , "-Cinstrument-coverage" ) ;
431+ Self :: append_rustflags ( "-Cinstrument-coverage" ) ;
432+
409433 let target_dir = std:: env:: var ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( |_| "target" . to_owned ( ) ) ;
410434 let coverage_dir = std:: path:: PathBuf :: from ( target_dir) . join ( "coverage" ) ;
411435 let coverage_file = coverage_dir. join ( "cargo-test-%p-%m.profraw" ) ;
@@ -473,6 +497,9 @@ impl Xtasks {
473497 }
474498
475499 fn cicd ( ) -> Result < ( ) > {
500+ // set profile
501+ Self :: set_cargo_profile ( "ephemeral-build" ) ;
502+
476503 // setup the CI environment
477504 Self :: init ( ) ?;
478505
@@ -488,7 +515,9 @@ impl Xtasks {
488515 . clone ( ) ;
489516
490517 // run powerset with all language features enabled without mutually exclusive
491- let powersets = non_exclusive. iter ( ) . cloned ( ) . powerset ( ) . collect :: < Vec < _ > > ( ) ;
518+ let mut powersets = non_exclusive. iter ( ) . cloned ( ) . powerset ( ) . collect :: < Vec < _ > > ( ) ;
519+ // start with longest to compile all first
520+ powersets. reverse ( ) ;
492521 info ! ( "Powerset: {:?}" , powersets) ;
493522 let length = powersets. len ( ) ;
494523
0 commit comments