@@ -20,26 +20,24 @@ use std::path::{Path, PathBuf};
20
20
use std:: process:: { Child , Command } ;
21
21
use std:: time:: Instant ;
22
22
23
- use dylib_util:: { dylib_path, dylib_path_var, exe} ;
23
+ use shared_helpers:: {
24
+ dylib_path, dylib_path_var, exe, maybe_dump, parse_rustc_stage, parse_rustc_verbose,
25
+ parse_value_from_args,
26
+ } ;
24
27
25
- #[ path = "../utils/bin_helpers.rs" ]
26
- mod bin_helpers;
27
-
28
- #[ path = "../utils/dylib.rs" ]
29
- mod dylib_util;
28
+ #[ path = "../utils/shared_helpers.rs" ]
29
+ mod shared_helpers;
30
30
31
31
fn main ( ) {
32
32
let orig_args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
33
33
let mut args = orig_args. clone ( ) ;
34
- let arg =
35
- |name| orig_args. windows ( 2 ) . find ( |args| args[ 0 ] == name) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
36
34
37
- let stage = bin_helpers :: parse_rustc_stage ( ) ;
38
- let verbose = bin_helpers :: parse_rustc_verbose ( ) ;
35
+ let stage = parse_rustc_stage ( ) ;
36
+ let verbose = parse_rustc_verbose ( ) ;
39
37
40
38
// Detect whether or not we're a build script depending on whether --target
41
39
// is passed (a bit janky...)
42
- let target = arg ( "--target" ) ;
40
+ let target = parse_value_from_args ( & orig_args , "--target" ) ;
43
41
let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
44
42
45
43
// Use a different compiler for build scripts, since there may not yet be a
@@ -102,7 +100,7 @@ fn main() {
102
100
cmd. args ( & args) . env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
103
101
104
102
// Get the name of the crate we're compiling, if any.
105
- let crate_name = arg ( "--crate-name" ) ;
103
+ let crate_name = parse_value_from_args ( & orig_args , "--crate-name" ) ;
106
104
107
105
if let Some ( crate_name) = crate_name {
108
106
if let Some ( target) = env:: var_os ( "RUSTC_TIME" ) {
@@ -143,10 +141,11 @@ fn main() {
143
141
cmd. arg ( "-C" ) . arg ( "panic=abort" ) ;
144
142
}
145
143
144
+ let crate_type = parse_value_from_args ( & orig_args, "--crate-type" ) ;
146
145
// `-Ztls-model=initial-exec` must not be applied to proc-macros, see
147
146
// issue https://github.com/rust-lang/rust/issues/100530
148
147
if env:: var ( "RUSTC_TLS_MODEL_INITIAL_EXEC" ) . is_ok ( )
149
- && arg ( "--crate-type" ) != Some ( "proc-macro" )
148
+ && crate_type != Some ( "proc-macro" )
150
149
&& !matches ! ( crate_name, Some ( "proc_macro2" | "quote" | "syn" | "synstructure" ) )
151
150
{
152
151
cmd. arg ( "-Ztls-model=initial-exec" ) ;
@@ -251,7 +250,7 @@ fn main() {
251
250
eprintln ! ( "{prefix} libdir: {libdir:?}" ) ;
252
251
}
253
252
254
- bin_helpers :: maybe_dump ( format ! ( "stage{stage}-rustc" ) , & cmd) ;
253
+ maybe_dump ( format ! ( "stage{stage}-rustc" ) , & cmd) ;
255
254
256
255
let start = Instant :: now ( ) ;
257
256
let ( child, status) = {
0 commit comments