@@ -162,8 +162,26 @@ fn test_sysroot_consistency() {
162
162
}
163
163
}
164
164
165
+ fn cargo ( ) -> Command {
166
+ if let Ok ( val) = std:: env:: var ( "CARGO" ) {
167
+ // Bootstrap tells us where to find cargo
168
+ Command :: new ( val)
169
+ } else {
170
+ Command :: new ( "cargo" )
171
+ }
172
+ }
173
+
174
+ fn xargo ( ) -> Command {
175
+ if let Ok ( val) = std:: env:: var ( "XARGO" ) {
176
+ // Bootstrap tells us where to find xargo
177
+ Command :: new ( val)
178
+ } else {
179
+ Command :: new ( "xargo" )
180
+ }
181
+ }
182
+
165
183
fn xargo_version ( ) -> Option < ( u32 , u32 , u32 ) > {
166
- let out = Command :: new ( " xargo" ) . arg ( "--version" ) . output ( ) . ok ( ) ?;
184
+ let out = xargo ( ) . arg ( "--version" ) . output ( ) . ok ( ) ?;
167
185
if !out. status . success ( ) {
168
186
return None ;
169
187
}
@@ -224,21 +242,14 @@ fn setup(ask_user: bool) {
224
242
}
225
243
226
244
// First, we need xargo.
227
- let xargo = xargo_version ( ) ;
228
- if xargo. map_or ( true , |v| v < ( 0 , 3 , 14 ) ) {
245
+ if xargo_version ( ) . map_or ( true , |v| v < ( 0 , 3 , 14 ) ) {
229
246
if ask_user {
230
247
ask ( "It seems you do not have a recent enough xargo installed. I will run `cargo install xargo -f`. Proceed?" ) ;
231
248
} else {
232
249
println ! ( "Installing xargo: `cargo install xargo -f`" ) ;
233
250
}
234
251
235
- let mut cargo = if let Ok ( val) = std:: env:: var ( "CARGO" ) {
236
- // In rustc bootstrap, an env var tells us where to find cargo.
237
- Command :: new ( val)
238
- } else {
239
- Command :: new ( "cargo" )
240
- } ;
241
- if !cargo. args ( & [ "install" , "xargo" , "-f" ] ) . status ( ) . unwrap ( ) . success ( ) {
252
+ if !cargo ( ) . args ( & [ "install" , "xargo" , "-f" ] ) . status ( ) . unwrap ( ) . success ( ) {
242
253
show_error ( format ! ( "Failed to install xargo" ) ) ;
243
254
}
244
255
}
@@ -294,7 +305,7 @@ path = "lib.rs"
294
305
// Run xargo.
295
306
let target = get_arg_flag_value ( "--target" ) ;
296
307
let print_env = !ask_user && has_arg_flag ( "--env" ) ; // whether we just print the necessary environment variable
297
- let mut command = Command :: new ( " xargo" ) ;
308
+ let mut command = xargo ( ) ;
298
309
command. arg ( "build" ) . arg ( "-q" )
299
310
. current_dir ( & dir)
300
311
. env ( "RUSTFLAGS" , miri:: miri_default_args ( ) . join ( " " ) )
@@ -383,7 +394,7 @@ fn in_cargo_miri() {
383
394
// Now we run `cargo rustc $FLAGS $ARGS`, giving the user the
384
395
// change to add additional arguments. `FLAGS` is set to identify
385
396
// this target. The user gets to control what gets actually passed to Miri.
386
- let mut cmd = Command :: new ( " cargo" ) ;
397
+ let mut cmd = cargo ( ) ;
387
398
cmd. arg ( "rustc" ) ;
388
399
match ( subcommand, kind. as_str ( ) ) {
389
400
( MiriCommand :: Run , "bin" ) => {
0 commit comments