Skip to content

Commit ad26733

Browse files
Daniel Dulaneybacek
Daniel Dulaney
authored andcommitted
build: upgrade bindgen to 0.51.1
The preivous bindgen version (0.32.0) fails on Rust 1.39 (see rust-lang/rust-bindgen#1627), so an upgrade is needed. However, the new version also breaks when enum values are also defined as macros. Previously, this could be handled with blacklist_type, but the recommended method is by implementing will_parse_macro and returning Ignore for problematic enum variants. This commit implements that method and removes the old method.
1 parent bb2981f commit ad26733

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ libc = "0.2"
2121
num_cpus = "1.0"
2222
cc = "1.0"
2323
pkg-config = "0.3"
24-
bindgen = "0.51"
24+
bindgen = "0.51.1"
2525
regex = "0.2"
2626

2727
[features]

build.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,17 @@ impl ParseCallbacks for IntCallbacks {
102102
}
103103
}
104104

105-
// https://github.com/servo/rust-bindgen/issues/687
106-
// Original fix is broken with bindgen 0.51 and linux 5.2
105+
// https://github.com/rust-lang/rust-bindgen/issues/687#issuecomment-388277405
107106
fn will_parse_macro(&self, name: &str) -> MacroParsingBehavior {
108-
if name.starts_with("FP_") {
109-
MacroParsingBehavior::Ignore
110-
} else {
111-
MacroParsingBehavior::Default
107+
use MacroParsingBehavior::*;
108+
109+
match name {
110+
"FP_INFINITE" => Ignore,
111+
"FP_NAN" => Ignore,
112+
"FP_NORMAL" => Ignore,
113+
"FP_SUBNORMAL" => Ignore,
114+
"FP_ZERO" => Ignore,
115+
_ => Default,
112116
}
113117
}
114118
}
@@ -935,12 +939,6 @@ fn main() {
935939
let mut builder = bindgen::Builder::default()
936940
.clang_args(clang_includes)
937941
.ctypes_prefix("libc")
938-
// https://github.com/servo/rust-bindgen/issues/687
939-
.blacklist_type("FP_NAN")
940-
.blacklist_type("FP_INFINITE")
941-
.blacklist_type("FP_ZERO")
942-
.blacklist_type("FP_SUBNORMAL")
943-
.blacklist_type("FP_NORMAL")
944942
// https://github.com/servo/rust-bindgen/issues/550
945943
.blacklist_type("max_align_t")
946944
.rustified_enum("*")

0 commit comments

Comments
 (0)