1616//! never get replaced.
1717
1818include ! ( "../dylib_util.rs" ) ;
19+ include ! ( "./_helper.rs" ) ;
1920
2021use std:: env;
2122use std:: path:: PathBuf ;
2223use std:: process:: { exit, Child , Command } ;
23- use std:: str:: FromStr ;
2424use std:: time:: Instant ;
2525
2626fn main ( ) {
2727 let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
2828 let arg = |name| args. windows ( 2 ) . find ( |args| args[ 0 ] == name) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
2929
30+ let stage = parse_rustc_stage ( ) ;
31+ let verbose = parse_rustc_verbose ( ) ;
32+
3033 // Detect whether or not we're a build script depending on whether --target
3134 // is passed (a bit janky...)
3235 let target = arg ( "--target" ) ;
3336 let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
3437
35- let verbose = match env:: var ( "RUSTC_VERBOSE" ) {
36- Ok ( s) => usize:: from_str ( & s) . expect ( "RUSTC_VERBOSE should be an integer" ) ,
37- Err ( _) => 0 ,
38- } ;
39-
4038 // Use a different compiler for build scripts, since there may not yet be a
4139 // libstd for the real compiler to use. However, if Cargo is attempting to
4240 // determine the version of the compiler, the real compiler needs to be
@@ -47,12 +45,7 @@ fn main() {
4745 } else {
4846 ( "RUSTC_REAL" , "RUSTC_LIBDIR" )
4947 } ;
50- let stage = env:: var ( "RUSTC_STAGE" ) . unwrap_or_else ( |_| {
51- // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
52- eprintln ! ( "rustc shim: fatal: RUSTC_STAGE was not set" ) ;
53- eprintln ! ( "rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap" ) ;
54- exit ( 101 ) ;
55- } ) ;
48+
5649 let sysroot = env:: var_os ( "RUSTC_SYSROOT" ) . expect ( "RUSTC_SYSROOT was not set" ) ;
5750 let on_fail = env:: var_os ( "RUSTC_ON_FAIL" ) . map ( Command :: new) ;
5851
0 commit comments