File tree Expand file tree Collapse file tree 2 files changed +8
-26
lines changed Expand file tree Collapse file tree 2 files changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -29,3 +29,6 @@ full-syntax = ["syn/full"]
29
29
name = " num_derive"
30
30
proc-macro = true
31
31
test = false
32
+
33
+ [build-dependencies ]
34
+ autocfg = " 0.1.2"
Original file line number Diff line number Diff line change
1
+ extern crate autocfg;
2
+
1
3
use std:: env;
2
- use std:: io:: Write ;
3
- use std:: process:: { Command , Stdio } ;
4
4
5
5
fn main ( ) {
6
- if probe ( "fn main() { 0i128; }" ) {
6
+ let ac = autocfg:: new ( ) ;
7
+ if ac. probe_type ( "i128" ) {
7
8
println ! ( "cargo:rustc-cfg=has_i128" ) ;
8
9
} else if env:: var_os ( "CARGO_FEATURE_I128" ) . is_some ( ) {
9
10
panic ! ( "i128 support was not detected!" ) ;
10
11
}
11
- }
12
-
13
- /// Test if a code snippet can be compiled
14
- fn probe ( code : & str ) -> bool {
15
- let rustc = env:: var_os ( "RUSTC" ) . unwrap_or_else ( || "rustc" . into ( ) ) ;
16
- let out_dir = env:: var_os ( "OUT_DIR" ) . expect ( "environment variable OUT_DIR" ) ;
17
-
18
- let mut child = Command :: new ( rustc)
19
- . arg ( "--out-dir" )
20
- . arg ( out_dir)
21
- . arg ( "--emit=obj" )
22
- . arg ( "-" )
23
- . stdin ( Stdio :: piped ( ) )
24
- . spawn ( )
25
- . expect ( "rustc probe" ) ;
26
-
27
- child
28
- . stdin
29
- . as_mut ( )
30
- . expect ( "rustc stdin" )
31
- . write_all ( code. as_bytes ( ) )
32
- . expect ( "write rustc stdin" ) ;
33
12
34
- child . wait ( ) . expect ( "rustc probe" ) . success ( )
13
+ autocfg :: rerun_path ( file ! ( ) ) ;
35
14
}
You can’t perform that action at this time.
0 commit comments