Skip to content

Commit a09ea39

Browse files
committed
Only export the inference engine functions in openvino-sys
Previously, many libc types and functions were exported by openvino-sys (and visible in docs.rs). This change tightens up rust-bindgen to only emit the `ie_*` functions (and their recursively-used types, a default setting). It also eliminates some `__uint8_t` and `__int64_t` as well as properly transforming `size_t` to `usize`.
1 parent 522ba25 commit a09ea39

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/openvino-sys/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ fn main() {
3636
file("upstream/inference-engine/ie_bridges/c/include/c_api/ie_c_api.h");
3737
let bindings = bindgen::Builder::default()
3838
.header(openvino_c_api_header.to_string_lossy())
39+
.allowlist_function("ie_.*")
40+
.blocklist_type("__uint8_t")
41+
.blocklist_type("__int64_t")
42+
.size_t_is_usize(true)
3943
// While understanding the warnings in https://docs.rs/bindgen/0.36.0/bindgen/struct.Builder.html#method.rustified_enum
4044
// that these enums could result in unspecified behavior if constructed from an invalid
4145
// value, the expectation here is that OpenVINO only returns valid layout and precision
4246
// values. This assumption is reasonable because otherwise OpenVINO itself would be broken.
4347
.rustified_enum("layout_e")
4448
.rustified_enum("precision_e")
4549
.rustified_enum("resize_alg_e")
50+
.rustified_enum("colorformat_e")
4651
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
4752
.generate()
4853
.expect("generate C API bindings");

0 commit comments

Comments
 (0)