4 impl bindgen::callbacks::ParseCallbacks for Fix753 {
5 fn item_name(&self, original_item_name: &str) -> Option<String> {
6 Some(original_item_name.trim_start_matches("Fix753_").to_owned())
11 use std::path::PathBuf;
13 println!("cargo:rerun-if-changed=src/libbcachefs_wrapper.h");
15 let out_dir: PathBuf = std::env::var_os("OUT_DIR")
16 .expect("ENV Var 'OUT_DIR' Expected")
18 let top_dir: PathBuf = std::env::var_os("CARGO_MANIFEST_DIR")
19 .expect("ENV Var 'CARGO_MANIFEST_DIR' Expected")
22 let bindings = bindgen::builder()
26 .join("libbcachefs_wrapper.h")
31 .clang_arg("-I../c_src")
32 .clang_arg("-I../include")
33 .clang_arg("-DZSTD_STATIC_LINKING_ONLY")
34 .clang_arg("-DNO_BCACHEFS_FS")
35 .clang_arg("-D_GNU_SOURCE")
36 .clang_arg("-DRUST_BINDGEN")
37 .clang_arg("-fkeep-inline-functions")
41 .default_enum_style(bindgen::EnumVariation::Rust {
44 .allowlist_function("bcachefs_usage")
45 .allowlist_function("raid_init")
46 .allowlist_function("cmd_.*")
47 .allowlist_function(".*_cmds")
48 .allowlist_function(".*bch2_.*")
49 .allowlist_function("bio_.*")
50 .allowlist_function("derive_passphrase")
51 .allowlist_function("request_key")
52 .allowlist_function("add_key")
53 .allowlist_function("keyctl_search")
54 .allowlist_function("match_string")
55 .allowlist_function("printbuf.*")
56 .blocklist_type("bch_extent_ptr")
57 .blocklist_type("btree_node")
58 .blocklist_type("bch_extent_crc32")
59 .blocklist_type("rhash_lock_head")
60 .blocklist_type("srcu_struct")
61 .allowlist_var("BCH_.*")
62 .allowlist_var("KEY_SPEC_.*")
63 .allowlist_var("Fix753_FMODE_.*")
64 .allowlist_var("bch.*")
65 .allowlist_var("__bch2.*")
66 .allowlist_var("__BTREE_ITER.*")
67 .allowlist_var("BTREE_ITER.*")
68 .blocklist_item("bch2_bkey_ops")
69 .allowlist_type("bch_.*")
70 .allowlist_type("fsck_err_opts")
71 .rustified_enum("fsck_err_opts")
72 .allowlist_type("nonce")
73 .no_debug("bch_replicas_padded")
74 .newtype_enum("bch_kdf_types")
75 .rustified_enum("bch_key_types")
76 .opaque_type("gendisk")
77 .opaque_type("gc_stripe")
78 .opaque_type("open_bucket.*")
79 .opaque_type("replicas_delta_list")
80 .no_copy("btree_trans")
84 .generate_inline_functions(true)
85 .parse_callbacks(Box::new(Fix753 {}))
87 .expect("BindGen Generation Failiure: [libbcachefs_wrapper]");
89 .write_to_file(out_dir.join("bcachefs.rs"))
90 .expect("Writing to output file failed for: `bcachefs.rs`");
92 let keyutils = pkg_config::probe_library("libkeyutils").expect("Failed to find keyutils lib");
93 let bindings = bindgen::builder()
97 .join("keyutils_wrapper.h")
105 .map(|p| format!("-I{}", p.display())),
108 .expect("BindGen Generation Failiure: [Keyutils]");
110 .write_to_file(out_dir.join("keyutils.rs"))
111 .expect("Writing to output file failed for: `keyutils.rs`");