1818use std:: env;
1919use std:: path:: PathBuf ;
2020use std:: process:: { exit, Child , Command } ;
21- use std:: str:: FromStr ;
2221use std:: time:: Instant ;
2322
2423use bootstrap:: util:: { dylib_path, dylib_path_var} ;
2524
25+ include ! ( "./_helper.rs" ) ;
26+
2627fn main ( ) {
2728 let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
2829 let arg = |name| args. windows ( 2 ) . find ( |args| args[ 0 ] == name) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
2930
31+ let stage = parse_rustc_stage ( ) ;
32+ let verbose = parse_rustc_verbose ( ) ;
33+
3034 // Detect whether or not we're a build script depending on whether --target
3135 // is passed (a bit janky...)
3236 let target = arg ( "--target" ) ;
3337 let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
3438
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-
4039 // Use a different compiler for build scripts, since there may not yet be a
4140 // libstd for the real compiler to use. However, if Cargo is attempting to
4241 // determine the version of the compiler, the real compiler needs to be
@@ -47,12 +46,7 @@ fn main() {
4746 } else {
4847 ( "RUSTC_REAL" , "RUSTC_LIBDIR" )
4948 } ;
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- } ) ;
49+
5650 let sysroot = env:: var_os ( "RUSTC_SYSROOT" ) . expect ( "RUSTC_SYSROOT was not set" ) ;
5751 let on_fail = env:: var_os ( "RUSTC_ON_FAIL" ) . map ( Command :: new) ;
5852
0 commit comments