I'm using bindgen to generate bindings for playerctl. It uses types and functions from glib, which bindgen is able to generate by itself. However, bindings to glib already exist in the glib-sys crate.
I know for certain that _GList and glib_sys::GList are identical. Here is the struct from that bindgen generated from glib, located in glib_sys:
In a few of my tests, I attempted to replace a few bindgen-generated functions and structs with identical ones from glib-sys. They appear to not be compatible:
expected raw pointer `*mut glib_sys::GList`
found raw pointer `*mut _GList`
How can I avoid this? I need to somehow instruct bindgen to use glib_sys instead of re-generating everything.
let bindings = bindgen::Builder::default()
// ...
.allowlist_var("Playerctl_.*")
.allowlist_type("Playerctl_.*")
.allowlist_function("playerctl_.*")
This prevents most, but not all glib items from being generated. Some essential structs that appear in playerctl's function signatures, like GList from earlier, are still generated.
I replaced .blocklist_type("_G_*") with .blocklist_type(r"_G\w+"). Now, the crate fails to build with this error:
error[E0412]: cannot find type `_GList` in this scope
--> /path/playerctl-sys/target/debug/build/playerctl-sys-e80adf4f6de29338/out/bindings.rs:24:18
|
24 | pub type GList = _GList;
| ^^^^^^ not found in this scope