fix multiple redefined values on linux build
841 | pub const FP_ZERO: u32 = 2;
| --------------------------- previous definition of the value `FP_ZERO` here
...
8117 | pub const FP_ZERO: _bindgen_ty_2 = 2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FP_ZERO` redefined here
Signed-off-by: Nikola Pajkovsky <nikola.pajkovsky@livesporttv.cz>
This commit is contained in:
@ -14,5 +14,5 @@ build = "build.rs"
|
|||||||
libc = ">=0.2"
|
libc = ">=0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = "0.31"
|
bindgen = "0.52.0"
|
||||||
pkg-config = ">=0.3"
|
pkg-config = ">=0.3"
|
||||||
|
|||||||
45
build.rs
45
build.rs
@ -87,6 +87,37 @@ fn main() {
|
|||||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
let bindings_path_str = out_dir.join("bindings.rs");
|
let bindings_path_str = out_dir.join("bindings.rs");
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct IgnoreMacros(HashSet<String>);
|
||||||
|
|
||||||
|
impl bindgen::callbacks::ParseCallbacks for IgnoreMacros {
|
||||||
|
fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior {
|
||||||
|
if self.0.contains(name) {
|
||||||
|
bindgen::callbacks::MacroParsingBehavior::Ignore
|
||||||
|
} else {
|
||||||
|
bindgen::callbacks::MacroParsingBehavior::Default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let ignored_macros = IgnoreMacros(
|
||||||
|
vec![
|
||||||
|
"FP_INFINITE".into(),
|
||||||
|
"FP_NAN".into(),
|
||||||
|
"FP_NORMAL".into(),
|
||||||
|
"FP_SUBNORMAL".into(),
|
||||||
|
"FP_ZERO".into(),
|
||||||
|
"IPPORT_RESERVED".into(),
|
||||||
|
"FP_INT_UPWARD".into(),
|
||||||
|
"FP_INT_DOWNWARD".into(),
|
||||||
|
"FP_INT_TOWARDZERO".into(),
|
||||||
|
"FP_INT_TONEARESTFROMZERO".into(),
|
||||||
|
"FP_INT_TONEAREST".into(),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
if !Path::new(&bindings_path_str).exists() {
|
if !Path::new(&bindings_path_str).exists() {
|
||||||
// Create the header file that rust-bindgen needs as input.
|
// Create the header file that rust-bindgen needs as input.
|
||||||
let gen_h_path = out_dir.join("gen.h");
|
let gen_h_path = out_dir.join("gen.h");
|
||||||
@ -101,17 +132,9 @@ fn main() {
|
|||||||
.ctypes_prefix("libc")
|
.ctypes_prefix("libc")
|
||||||
.raw_line("extern crate libc;")
|
.raw_line("extern crate libc;")
|
||||||
.header(gen_h_path.to_str().unwrap())
|
.header(gen_h_path.to_str().unwrap())
|
||||||
// https://github.com/rust-lang-nursery/rust-bindgen/issues/687
|
.parse_callbacks(Box::new(ignored_macros))
|
||||||
.blacklist_type("FP_NAN")
|
.blacklist_type("timex")
|
||||||
.blacklist_type("FP_INFINITE")
|
.blacklist_function("clock_adjtime");
|
||||||
.blacklist_type("FP_ZERO")
|
|
||||||
.blacklist_type("FP_SUBNORMAL")
|
|
||||||
.blacklist_type("FP_NORMAL")
|
|
||||||
.blacklist_type("FP_INT_UPWARD")
|
|
||||||
.blacklist_type("FP_INT_DOWNWARD")
|
|
||||||
.blacklist_type("FP_INT_TOWARDZERO")
|
|
||||||
.blacklist_type("FP_INT_TONEARESTFROMZERO")
|
|
||||||
.blacklist_type("FP_INT_TONEAREST");
|
|
||||||
|
|
||||||
for d in include_dirs {
|
for d in include_dirs {
|
||||||
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
|
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
|
||||||
|
|||||||
Reference in New Issue
Block a user