git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

scratch/test_bindgen.rs (1.7K)

 1 fn main() {
 2     let mut builder = bindgen::Builder::default()
 3         .header("wrapper.h")
 4         .clang_arg("-DWLR_USE_UNSTABLE")
 5         .allowlist_type("pixman_region32")
 6         .allowlist_type("pixman_box32")
 7         .layout_tests(false);
 8 
 9     // Let's query pkg-config for the paths programmatically
10     let pixman = pkg_config::probe_library("pixman-1").unwrap();
11     let wlroots = pkg_config::probe_library("wlroots-0.19").unwrap();
12     let scenefx = pkg_config::probe_library("scenefx-0.4").unwrap();
13     let libinput = pkg_config::probe_library("libinput").unwrap();
14     let libevdev = pkg_config::probe_library("libevdev").unwrap();
15     let wayland_server = pkg_config::probe_library("wayland-server").unwrap();
16     let xkbcommon = pkg_config::probe_library("xkbcommon").unwrap();
17 
18     let mut include_paths = vec![std::path::PathBuf::from("target/debug/build/cce-84dd41093ae4212e/out")];
19     include_paths.extend(pixman.include_paths);
20     include_paths.extend(wlroots.include_paths);
21     include_paths.extend(scenefx.include_paths);
22     include_paths.extend(libinput.include_paths);
23     include_paths.extend(libevdev.include_paths);
24     include_paths.extend(wayland_server.include_paths);
25     include_paths.extend(xkbcommon.include_paths);
26 
27     for path in include_paths {
28         builder = builder.clang_arg(format!("-I{}", path.display()));
29     }
30 
31     let bindings = builder.generate().expect("Failed to generate bindings");
32     let code = bindings.to_string();
33     if let Some(idx) = code.find("pub struct pixman_region32 ") {
34         println!("=== pixman_region32 ===");
35         println!("{}", &code[idx..idx+500]);
36     } else {
37         println!("pixman_region32 not found in generated bindings!");
38     }
39 }