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 let out_dir: PathBuf = std::env::var_os("OUT_DIR")
14 .expect("ENV Var 'OUT_DIR' Expected")
16 let top_dir: PathBuf = std::env::var_os("CARGO_MANIFEST_DIR")
17 .expect("ENV Var 'CARGO_MANIFEST_DIR' Expected")
20 let libbcachefs_inc_dir = std::path::Path::new("../..");
22 let _libbcachefs_dir = top_dir.join("libbcachefs").join("libbcachefs");
23 let bindings = bindgen::builder()
27 .join("libbcachefs_wrapper.h")
33 libbcachefs_inc_dir.join("include").display()
35 .clang_arg(format!("-I{}", libbcachefs_inc_dir.display()))
36 .clang_arg("-DZSTD_STATIC_LINKING_ONLY")
37 .clang_arg("-DNO_BCACHEFS_FS")
38 .clang_arg("-D_GNU_SOURCE")
39 .clang_arg("-fkeep-inline-functions")
43 .default_enum_style(bindgen::EnumVariation::Rust {
46 .allowlist_function(".*bch2_.*")
47 .allowlist_function("bio_.*")
48 .allowlist_function("derive_passphrase")
49 .allowlist_function("request_key")
50 .allowlist_function("add_key")
51 .allowlist_function("keyctl_search")
52 .allowlist_function("match_string")
53 .allowlist_function("printbuf.*")
54 .blocklist_type("bch_extent_ptr")
55 .blocklist_type("btree_node")
56 .blocklist_type("bch_extent_crc32")
57 .blocklist_type("rhash_lock_head")
58 .blocklist_type("srcu_struct")
59 .allowlist_var("BCH_.*")
60 .allowlist_var("KEY_SPEC_.*")
61 .allowlist_var("Fix753_FMODE_.*")
62 .allowlist_var("bch.*")
63 .allowlist_var("__bch2.*")
64 .allowlist_var("__BTREE_ITER.*")
65 .allowlist_var("BTREE_ITER.*")
66 .blocklist_item("bch2_bkey_ops")
67 .allowlist_type("bch_.*")
68 .allowlist_type("fsck_err_opts")
69 .rustified_enum("fsck_err_opts")
70 .allowlist_type("nonce")
71 .no_debug("bch_replicas_padded")
72 .newtype_enum("bch_kdf_types")
73 .rustified_enum("bch_key_types")
74 .opaque_type("gendisk")
75 .opaque_type("gc_stripe")
76 .opaque_type("open_bucket.*")
77 .opaque_type("replicas_delta_list")
78 .no_copy("btree_trans")
82 .generate_inline_functions(true)
83 .parse_callbacks(Box::new(Fix753 {}))
85 .expect("BindGen Generation Failiure: [libbcachefs_wrapper]");
87 .write_to_file(out_dir.join("bcachefs.rs"))
88 .expect("Writing to output file failed for: `bcachefs.rs`");
90 let keyutils = pkg_config::probe_library("libkeyutils").expect("Failed to find keyutils lib");
91 let bindings = bindgen::builder()
95 .join("keyutils_wrapper.h")
103 .map(|p| format!("-I{}", p.display())),
106 .expect("BindGen Generation Failiure: [Keyutils]");
108 .write_to_file(out_dir.join("keyutils.rs"))
109 .expect("Writing to output file failed for: `keyutils.rs`");