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 libbcachefs_inc_dir = std::path::Path::new("../..");
24 let _libbcachefs_dir = top_dir.join("libbcachefs").join("libbcachefs");
25 let bindings = bindgen::builder()
29 .join("libbcachefs_wrapper.h")
35 libbcachefs_inc_dir.join("include").display()
37 .clang_arg(format!("-I{}", libbcachefs_inc_dir.display()))
38 .clang_arg("-DZSTD_STATIC_LINKING_ONLY")
39 .clang_arg("-DNO_BCACHEFS_FS")
40 .clang_arg("-D_GNU_SOURCE")
41 .clang_arg("-DRUST_BINDGEN")
42 .clang_arg("-fkeep-inline-functions")
46 .default_enum_style(bindgen::EnumVariation::Rust {
49 .allowlist_function("bcachefs_usage")
50 .allowlist_function("raid_init")
51 .allowlist_function("cmd_.*")
52 .allowlist_function(".*_cmds")
53 .allowlist_function(".*bch2_.*")
54 .allowlist_function("bio_.*")
55 .allowlist_function("derive_passphrase")
56 .allowlist_function("request_key")
57 .allowlist_function("add_key")
58 .allowlist_function("keyctl_search")
59 .allowlist_function("match_string")
60 .allowlist_function("printbuf.*")
61 .blocklist_type("bch_extent_ptr")
62 .blocklist_type("btree_node")
63 .blocklist_type("bch_extent_crc32")
64 .blocklist_type("rhash_lock_head")
65 .blocklist_type("srcu_struct")
66 .allowlist_var("BCH_.*")
67 .allowlist_var("KEY_SPEC_.*")
68 .allowlist_var("Fix753_FMODE_.*")
69 .allowlist_var("bch.*")
70 .allowlist_var("__bch2.*")
71 .allowlist_var("__BTREE_ITER.*")
72 .allowlist_var("BTREE_ITER.*")
73 .blocklist_item("bch2_bkey_ops")
74 .allowlist_type("bch_.*")
75 .allowlist_type("fsck_err_opts")
76 .rustified_enum("fsck_err_opts")
77 .allowlist_type("nonce")
78 .no_debug("bch_replicas_padded")
79 .newtype_enum("bch_kdf_types")
80 .rustified_enum("bch_key_types")
81 .opaque_type("gendisk")
82 .opaque_type("gc_stripe")
83 .opaque_type("open_bucket.*")
84 .opaque_type("replicas_delta_list")
85 .no_copy("btree_trans")
89 .generate_inline_functions(true)
90 .parse_callbacks(Box::new(Fix753 {}))
92 .expect("BindGen Generation Failiure: [libbcachefs_wrapper]");
94 .write_to_file(out_dir.join("bcachefs.rs"))
95 .expect("Writing to output file failed for: `bcachefs.rs`");
97 let keyutils = pkg_config::probe_library("libkeyutils").expect("Failed to find keyutils lib");
98 let bindings = bindgen::builder()
102 .join("keyutils_wrapper.h")
110 .map(|p| format!("-I{}", p.display())),
113 .expect("BindGen Generation Failiure: [Keyutils]");
115 .write_to_file(out_dir.join("keyutils.rs"))
116 .expect("Writing to output file failed for: `keyutils.rs`");