File tree Expand file tree Collapse file tree 2 files changed +23
-16
lines changed
dev-tools/gen-target-info/src Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -84,15 +84,22 @@ fn generate_target_mapping(f: &mut File, target_specs: &RustcTargetSpecs) -> std
8484
8585fn main ( ) {
8686 // Primarily use information from nightly.
87- let mut target_specs = get_target_specs_from_json ( ) ;
87+ let mut target_specs = get_target_specs_from_json ( std :: env :: var ( "RUSTC" ) . ok ( ) ) ;
8888 // Next, read from MSRV to support old, removed targets.
89- for target_triple in get_targets_msrv ( ) . lines ( ) {
90- let target_triple = target_triple. unwrap ( ) ;
91- let target_triple = target_triple. trim ( ) ;
92- target_specs
93- . 0
94- . entry ( target_triple. to_string ( ) )
95- . or_insert_with ( || get_target_spec_from_msrv ( target_triple) ) ;
89+ if std:: env:: var ( "CC_RS_MSRV" )
90+ . unwrap_or ( "1" . to_string ( ) )
91+ . parse :: < u32 > ( )
92+ . unwrap ( )
93+ != 0
94+ {
95+ for target_triple in get_targets_msrv ( ) . lines ( ) {
96+ let target_triple = target_triple. unwrap ( ) ;
97+ let target_triple = target_triple. trim ( ) ;
98+ target_specs
99+ . 0
100+ . entry ( target_triple. to_string ( ) )
101+ . or_insert_with ( || get_target_spec_from_msrv ( target_triple) ) ;
102+ }
96103 }
97104
98105 // Open file to write to
Original file line number Diff line number Diff line change @@ -40,14 +40,14 @@ pub fn get_target_spec_from_msrv(target: &str) -> TargetSpec {
4040 serde_json:: from_slice ( & stdout) . unwrap ( )
4141}
4242
43- pub fn get_target_specs_from_json ( ) -> RustcTargetSpecs {
44- let mut cmd = process:: Command :: new ( "rustc" ) ;
45- cmd . args ( [
46- "+nightly" ,
47- "-Zunstable-options" ,
48- "--print" ,
49- "all-target-specs-json" ,
50- ] ) ;
43+ pub fn get_target_specs_from_json ( rustc : Option < String > ) -> RustcTargetSpecs {
44+ let mut cmd = process:: Command :: new ( rustc . clone ( ) . unwrap_or ( "rustc" . into ( ) ) ) ;
45+
46+ if rustc . is_none ( ) {
47+ cmd . arg ( "+nightly" ) ;
48+ }
49+
50+ cmd . args ( [ "-Zunstable-options" , "--print" , "all-target-specs-json" ] ) ;
5151 cmd. stdout ( process:: Stdio :: piped ( ) ) ;
5252 cmd. stderr ( process:: Stdio :: inherit ( ) ) ;
5353
You can’t perform that action at this time.
0 commit comments