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"]
2929name = " num_derive"
3030proc-macro = true
3131test = 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+
13use std:: env;
2- use std:: io:: Write ;
3- use std:: process:: { Command , Stdio } ;
44
55fn main ( ) {
6- if probe ( "fn main() { 0i128; }" ) {
6+ let ac = autocfg:: new ( ) ;
7+ if ac. probe_type ( "i128" ) {
78 println ! ( "cargo:rustc-cfg=has_i128" ) ;
89 } else if env:: var_os ( "CARGO_FEATURE_I128" ) . is_some ( ) {
910 panic ! ( "i128 support was not detected!" ) ;
1011 }
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" ) ;
3312
34- child . wait ( ) . expect ( "rustc probe" ) . success ( )
13+ autocfg :: rerun_path ( file ! ( ) ) ;
3514}
You can’t perform that action at this time.
0 commit comments