1
1
use std:: process;
2
2
3
- use crate :: RustcTargetSpecs ;
3
+ use crate :: { RustcTargetSpecs , TargetSpec } ;
4
+
5
+ pub fn get_targets_msrv ( ) -> Vec < u8 > {
6
+ let mut cmd = process:: Command :: new ( "rustc" ) ;
7
+ cmd. args ( [ "+1.63" , "--print" , "target-list" ] ) ;
8
+ cmd. stdout ( process:: Stdio :: piped ( ) ) ;
9
+ cmd. stderr ( process:: Stdio :: inherit ( ) ) ;
10
+
11
+ let process:: Output { status, stdout, .. } = cmd. output ( ) . unwrap ( ) ;
12
+
13
+ if !status. success ( ) {
14
+ panic ! ( "{:?} failed with non-zero exit status: {}" , cmd, status)
15
+ }
16
+
17
+ stdout
18
+ }
19
+
20
+ pub fn get_target_spec_from_msrv ( target : & str ) -> TargetSpec {
21
+ let mut cmd = process:: Command :: new ( "rustc" ) ;
22
+ cmd. args ( [
23
+ "+1.63" ,
24
+ "-Zunstable-options" ,
25
+ "--print" ,
26
+ "target-spec-json" ,
27
+ "--target" ,
28
+ target,
29
+ ] ) ;
30
+ cmd. env ( "RUSTC_BOOTSTRAP" , "1" ) ;
31
+ cmd. stdout ( process:: Stdio :: piped ( ) ) ;
32
+ cmd. stderr ( process:: Stdio :: inherit ( ) ) ;
33
+
34
+ let process:: Output { status, stdout, .. } = cmd. output ( ) . unwrap ( ) ;
35
+
36
+ if !status. success ( ) {
37
+ panic ! ( "{:?} failed with non-zero exit status: {}" , cmd, status)
38
+ }
39
+
40
+ serde_json:: from_slice ( & stdout) . unwrap ( )
41
+ }
4
42
5
43
pub fn get_target_specs_from_json ( ) -> RustcTargetSpecs {
6
44
let mut cmd = process:: Command :: new ( "rustc" ) ;
@@ -9,8 +47,9 @@ pub fn get_target_specs_from_json() -> RustcTargetSpecs {
9
47
"-Zunstable-options" ,
10
48
"--print" ,
11
49
"all-target-specs-json" ,
12
- ] )
13
- . stdout ( process:: Stdio :: piped ( ) ) ;
50
+ ] ) ;
51
+ cmd. stdout ( process:: Stdio :: piped ( ) ) ;
52
+ cmd. stderr ( process:: Stdio :: inherit ( ) ) ;
14
53
15
54
let process:: Output { status, stdout, .. } = cmd. output ( ) . unwrap ( ) ;
16
55
0 commit comments