@@ -25,94 +25,92 @@ fn main() {
25
25
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
26
26
// running tests to ensure that the ABI is correct.
27
27
match which_freebsd ( ) {
28
- Some ( 10 ) if libc_ci || rustc_dep_of_std => {
29
- println ! ( "cargo:rustc-cfg=freebsd10" )
30
- }
31
- Some ( 11 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd11" ) ,
32
- Some ( 12 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd12" ) ,
33
- Some ( 13 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd13" ) ,
34
- Some ( 14 ) if libc_ci => println ! ( "cargo:rustc-cfg=freebsd14" ) ,
35
- Some ( _) | None => println ! ( "cargo:rustc-cfg=freebsd11" ) ,
28
+ Some ( 10 ) if libc_ci || rustc_dep_of_std => set_cfg ( "freebsd10" ) ,
29
+ Some ( 11 ) if libc_ci => set_cfg ( "freebsd11" ) ,
30
+ Some ( 12 ) if libc_ci => set_cfg ( "freebsd12" ) ,
31
+ Some ( 13 ) if libc_ci => set_cfg ( "freebsd13" ) ,
32
+ Some ( 14 ) if libc_ci => set_cfg ( "freebsd14" ) ,
33
+ Some ( _) | None => set_cfg ( "freebsd11" ) ,
36
34
}
37
35
38
36
// On CI: deny all warnings
39
37
if libc_ci {
40
- println ! ( "cargo:rustc-cfg= libc_deny_warnings") ;
38
+ set_cfg ( " libc_deny_warnings") ;
41
39
}
42
40
43
41
// Rust >= 1.15 supports private module use:
44
42
if rustc_minor_ver >= 15 || rustc_dep_of_std {
45
- println ! ( "cargo:rustc-cfg= libc_priv_mod_use") ;
43
+ set_cfg ( " libc_priv_mod_use") ;
46
44
}
47
45
48
46
// Rust >= 1.19 supports unions:
49
47
if rustc_minor_ver >= 19 || rustc_dep_of_std {
50
- println ! ( "cargo:rustc-cfg= libc_union") ;
48
+ set_cfg ( " libc_union") ;
51
49
}
52
50
53
51
// Rust >= 1.24 supports const mem::size_of:
54
52
if rustc_minor_ver >= 24 || rustc_dep_of_std {
55
- println ! ( "cargo:rustc-cfg= libc_const_size_of") ;
53
+ set_cfg ( " libc_const_size_of") ;
56
54
}
57
55
58
56
// Rust >= 1.25 supports repr(align):
59
57
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
60
- println ! ( "cargo:rustc-cfg= libc_align") ;
58
+ set_cfg ( " libc_align") ;
61
59
}
62
60
63
61
// Rust >= 1.26 supports i128 and u128:
64
62
if rustc_minor_ver >= 26 || rustc_dep_of_std {
65
- println ! ( "cargo:rustc-cfg= libc_int128") ;
63
+ set_cfg ( " libc_int128") ;
66
64
}
67
65
68
66
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
69
67
// Otherwise, it defines an incompatible type to retaining
70
68
// backwards-compatibility.
71
69
if rustc_minor_ver >= 30 || rustc_dep_of_std {
72
- println ! ( "cargo:rustc-cfg= libc_core_cvoid") ;
70
+ set_cfg ( " libc_core_cvoid") ;
73
71
}
74
72
75
73
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
76
74
if rustc_minor_ver >= 33 || rustc_dep_of_std {
77
- println ! ( "cargo:rustc-cfg= libc_packedN") ;
78
- println ! ( "cargo:rustc-cfg= libc_cfg_target_vendor") ;
75
+ set_cfg ( " libc_packedN") ;
76
+ set_cfg ( " libc_cfg_target_vendor") ;
79
77
}
80
78
81
79
// Rust >= 1.40 supports #[non_exhaustive].
82
80
if rustc_minor_ver >= 40 || rustc_dep_of_std {
83
- println ! ( "cargo:rustc-cfg= libc_non_exhaustive") ;
81
+ set_cfg ( " libc_non_exhaustive") ;
84
82
}
85
83
86
84
// Rust >= 1.47 supports long array:
87
85
if rustc_minor_ver >= 47 || rustc_dep_of_std {
88
- println ! ( "cargo:rustc-cfg= libc_long_array") ;
86
+ set_cfg ( " libc_long_array") ;
89
87
}
90
88
91
89
if rustc_minor_ver >= 51 || rustc_dep_of_std {
92
- println ! ( "cargo:rustc-cfg= libc_ptr_addr_of") ;
90
+ set_cfg ( " libc_ptr_addr_of") ;
93
91
}
94
92
95
93
// Rust >= 1.37.0 allows underscores as anonymous constant names.
96
94
if rustc_minor_ver >= 37 || rustc_dep_of_std {
97
- println ! ( "cargo:rustc-cfg= libc_underscore_const_names") ;
95
+ set_cfg ( " libc_underscore_const_names") ;
98
96
}
99
97
100
98
// #[thread_local] is currently unstable
101
99
if rustc_dep_of_std {
102
- println ! ( "cargo:rustc-cfg= libc_thread_local") ;
100
+ set_cfg ( " libc_thread_local") ;
103
101
}
104
102
105
103
// Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C".
106
104
if rustc_minor_ver >= 62 {
107
- println ! ( "cargo:rustc-cfg= libc_const_extern_fn") ;
105
+ set_cfg ( " libc_const_extern_fn") ;
108
106
} else {
109
107
// Rust < 1.62.0 requires a crate feature and feature gate.
110
108
if const_extern_fn_cargo_feature {
111
109
if !is_nightly || rustc_minor_ver < 40 {
112
110
panic ! ( "const-extern-fn requires a nightly compiler >= 1.40" ) ;
113
111
}
114
- println ! ( "cargo:rustc-cfg= libc_const_extern_fn_unstable") ;
115
- println ! ( "cargo:rustc-cfg= libc_const_extern_fn") ;
112
+ set_cfg ( " libc_const_extern_fn_unstable") ;
113
+ set_cfg ( " libc_const_extern_fn") ;
116
114
}
117
115
}
118
116
}
@@ -181,3 +179,7 @@ fn which_freebsd() -> Option<i32> {
181
179
_ => None ,
182
180
}
183
181
}
182
+
183
+ fn set_cfg ( cfg : & str ) {
184
+ println ! ( "cargo:rustc-cfg={}" , cfg) ;
185
+ }
0 commit comments