@@ -207,6 +207,15 @@ impl Xtasks {
207
207
}
208
208
}
209
209
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
+
210
219
fn cargo_metadata ( ) -> Result < cargo_metadata:: Metadata > {
211
220
let cargo_manifest_path = std:: env:: var ( "CARGO_MANIFEST_PATH" ) . unwrap ( ) ;
212
221
@@ -227,6 +236,14 @@ impl Xtasks {
227
236
Ok ( workspace_dir. join ( dir) )
228
237
}
229
238
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
+
230
247
fn run_system_command < I : IntoIterator < Item = impl AsRef < OsStr > > > (
231
248
command : & str ,
232
249
context : & str ,
@@ -281,6 +298,12 @@ impl Xtasks {
281
298
. to_owned ( )
282
299
} ) ) ;
283
300
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
+
284
307
let working_dir = match dir {
285
308
Some ( d) => Self :: relative_workspace_dir ( d) ?,
286
309
None => Self :: workspace_dir ( ) ?,
@@ -405,7 +428,8 @@ impl Xtasks {
405
428
fn test ( features : Features ) -> Result < ( ) > {
406
429
// run cargo test with instrumentation
407
430
std:: env:: set_var ( "CARGO_INCREMENTAL" , "0" ) ;
408
- std:: env:: set_var ( "RUSTFLAGS" , "-Cinstrument-coverage" ) ;
431
+ Self :: append_rustflags ( "-Cinstrument-coverage" ) ;
432
+
409
433
let target_dir = std:: env:: var ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( |_| "target" . to_owned ( ) ) ;
410
434
let coverage_dir = std:: path:: PathBuf :: from ( target_dir) . join ( "coverage" ) ;
411
435
let coverage_file = coverage_dir. join ( "cargo-test-%p-%m.profraw" ) ;
@@ -473,6 +497,9 @@ impl Xtasks {
473
497
}
474
498
475
499
fn cicd ( ) -> Result < ( ) > {
500
+ // set profile
501
+ Self :: set_cargo_profile ( "ephemeral-build" ) ;
502
+
476
503
// setup the CI environment
477
504
Self :: init ( ) ?;
478
505
@@ -488,7 +515,9 @@ impl Xtasks {
488
515
. clone ( ) ;
489
516
490
517
// 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 ( ) ;
492
521
info ! ( "Powerset: {:?}" , powersets) ;
493
522
let length = powersets. len ( ) ;
494
523
0 commit comments