@@ -162,8 +162,26 @@ fn test_sysroot_consistency() {
162162 }
163163}
164164
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+
165183fn xargo_version ( ) -> Option < ( u32 , u32 , u32 ) > {
166- let out = Command :: new ( " xargo" ) . arg ( "--version" ) . output ( ) . ok ( ) ?;
184+ let out = xargo ( ) . arg ( "--version" ) . output ( ) . ok ( ) ?;
167185 if !out. status . success ( ) {
168186 return None ;
169187 }
@@ -224,21 +242,14 @@ fn setup(ask_user: bool) {
224242 }
225243
226244 // 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 ) ) {
229246 if ask_user {
230247 ask ( "It seems you do not have a recent enough xargo installed. I will run `cargo install xargo -f`. Proceed?" ) ;
231248 } else {
232249 println ! ( "Installing xargo: `cargo install xargo -f`" ) ;
233250 }
234251
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 ( ) {
242253 show_error ( format ! ( "Failed to install xargo" ) ) ;
243254 }
244255 }
@@ -294,7 +305,7 @@ path = "lib.rs"
294305 // Run xargo.
295306 let target = get_arg_flag_value ( "--target" ) ;
296307 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 ( ) ;
298309 command. arg ( "build" ) . arg ( "-q" )
299310 . current_dir ( & dir)
300311 . env ( "RUSTFLAGS" , miri:: miri_default_args ( ) . join ( " " ) )
@@ -383,7 +394,7 @@ fn in_cargo_miri() {
383394 // Now we run `cargo rustc $FLAGS $ARGS`, giving the user the
384395 // change to add additional arguments. `FLAGS` is set to identify
385396 // 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 ( ) ;
387398 cmd. arg ( "rustc" ) ;
388399 match ( subcommand, kind. as_str ( ) ) {
389400 ( MiriCommand :: Run , "bin" ) => {
0 commit comments