@@ -247,7 +247,9 @@ fn xargo_version() -> Option<(u32, u32, u32)> {
247
247
Some ( ( major, minor, patch) )
248
248
}
249
249
250
- fn ask_to_run ( mut cmd : Command , ask : bool , text : & str ) {
250
+ fn ask_to_run ( mut cmd : Command , subcommand : MiriCommand , text : & str ) {
251
+ // Disable interactive prompts in CI (GitHub Actions, Travis, AppVeyor, etc).
252
+ let ask = subcommand != MiriCommand :: Setup && env:: var_os ( "CI" ) . is_none ( ) ;
251
253
if ask {
252
254
let mut buf = String :: new ( ) ;
253
255
print ! ( "I will run `{:?}` to {}. Proceed? [Y/n] " , cmd, text) ;
@@ -271,9 +273,9 @@ fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
271
273
/// Performs the setup required to make `cargo miri` work: Getting a custom-built libstd. Then sets
272
274
/// `MIRI_SYSROOT`. Skipped if `MIRI_SYSROOT` is already set, in which case we expect the user has
273
275
/// done all this already.
274
- fn setup ( ask_user : bool ) {
276
+ fn setup ( subcommand : MiriCommand ) {
275
277
if std:: env:: var ( "MIRI_SYSROOT" ) . is_ok ( ) {
276
- if !ask_user {
278
+ if subcommand == MiriCommand :: Setup {
277
279
println ! ( "WARNING: MIRI_SYSROOT already set, not doing anything." )
278
280
}
279
281
return ;
@@ -287,7 +289,7 @@ fn setup(ask_user: bool) {
287
289
}
288
290
let mut cmd = cargo ( ) ;
289
291
cmd. args ( & [ "install" , "xargo" , "-f" ] ) ;
290
- ask_to_run ( cmd, ask_user , "install a recent enough xargo" ) ;
292
+ ask_to_run ( cmd, subcommand , "install a recent enough xargo" ) ;
291
293
}
292
294
293
295
// Determine where the rust sources are located. `XARGO_RUST_SRC` env var trumps everything.
@@ -310,7 +312,7 @@ fn setup(ask_user: bool) {
310
312
cmd. args ( & [ "component" , "add" , "rust-src" ] ) ;
311
313
ask_to_run (
312
314
cmd,
313
- ask_user ,
315
+ subcommand ,
314
316
"install the rustc-src component for the selected toolchain" ,
315
317
) ;
316
318
}
@@ -361,7 +363,8 @@ path = "lib.rs"
361
363
File :: create ( dir. join ( "lib.rs" ) ) . unwrap ( ) ;
362
364
// Prepare xargo invocation.
363
365
let target = get_arg_flag_value ( "--target" ) ;
364
- let print_sysroot = !ask_user && has_arg_flag ( "--print-sysroot" ) ; // whether we just print the sysroot path
366
+ let print_sysroot = subcommand == MiriCommand :: Setup
367
+ && has_arg_flag ( "--print-sysroot" ) ; // whether we just print the sysroot path
365
368
let mut command = xargo_check ( ) ;
366
369
command. arg ( "build" ) . arg ( "-q" ) ;
367
370
command. current_dir ( & dir) ;
@@ -389,7 +392,7 @@ path = "lib.rs"
389
392
if print_sysroot {
390
393
// Print just the sysroot and nothing else; this way we do not need any escaping.
391
394
println ! ( "{}" , sysroot. display( ) ) ;
392
- } else if !ask_user {
395
+ } else if subcommand == MiriCommand :: Setup {
393
396
println ! ( "A libstd for Miri is now available in `{}`." , sysroot. display( ) ) ;
394
397
}
395
398
}
@@ -436,9 +439,7 @@ fn in_cargo_miri() {
436
439
test_sysroot_consistency ( ) ;
437
440
438
441
// We always setup.
439
- // Disable interactive prompts in CI (GitHub Actions, Travis, AppVeyor, etc).
440
- let ask = subcommand != MiriCommand :: Setup && env:: var_os ( "CI" ) . is_none ( ) ;
441
- setup ( ask) ;
442
+ setup ( subcommand) ;
442
443
if subcommand == MiriCommand :: Setup {
443
444
// Stop here.
444
445
return ;
0 commit comments