18
18
use std:: env;
19
19
use std:: path:: PathBuf ;
20
20
use std:: process:: { exit, Child , Command } ;
21
- use std:: str:: FromStr ;
22
21
use std:: time:: Instant ;
23
22
24
23
use bootstrap:: util:: { dylib_path, dylib_path_var} ;
25
24
25
+ include ! ( "./_helper.rs" ) ;
26
+
26
27
fn main ( ) {
27
28
let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
28
29
let arg = |name| args. windows ( 2 ) . find ( |args| args[ 0 ] == name) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
29
30
31
+ let stage = parse_rustc_stage ( ) ;
32
+ let verbose = parse_rustc_verbose ( ) ;
33
+
30
34
// Detect whether or not we're a build script depending on whether --target
31
35
// is passed (a bit janky...)
32
36
let target = arg ( "--target" ) ;
33
37
let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
34
38
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
-
40
39
// Use a different compiler for build scripts, since there may not yet be a
41
40
// libstd for the real compiler to use. However, if Cargo is attempting to
42
41
// determine the version of the compiler, the real compiler needs to be
@@ -47,12 +46,7 @@ fn main() {
47
46
} else {
48
47
( "RUSTC_REAL" , "RUSTC_LIBDIR" )
49
48
} ;
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
+
56
50
let sysroot = env:: var_os ( "RUSTC_SYSROOT" ) . expect ( "RUSTC_SYSROOT was not set" ) ;
57
51
let on_fail = env:: var_os ( "RUSTC_ON_FAIL" ) . map ( Command :: new) ;
58
52
0 commit comments