2 use std::path::PathBuf;
4 let out_dir: PathBuf = std::env::var_os("OUT_DIR")
5 .expect("ENV Var 'OUT_DIR' Expected")
7 let top_dir: PathBuf = std::env::var_os("CARGO_MANIFEST_DIR")
8 .expect("ENV Var 'CARGO_MANIFEST_DIR' Expected")
11 let libbcachefs_inc_dir = std::path::Path::new("../..");
13 let _libbcachefs_dir = top_dir.join("libbcachefs").join("libbcachefs");
14 let bindings = bindgen::builder()
18 .join("libbcachefs_wrapper.h")
24 libbcachefs_inc_dir.join("include").display()
26 .clang_arg(format!("-I{}", libbcachefs_inc_dir.display()))
27 .clang_arg("-DZSTD_STATIC_LINKING_ONLY")
28 .clang_arg("-DNO_BCACHEFS_FS")
29 .clang_arg("-D_GNU_SOURCE")
34 .default_enum_style(bindgen::EnumVariation::Rust {
37 .allowlist_function(".*bch2_.*")
38 .allowlist_function("bio_.*")
39 .allowlist_function("bch2_super_write_fd")
40 .allowlist_function("derive_passphrase")
41 .allowlist_function("request_key")
42 .allowlist_function("add_key")
43 .allowlist_function("keyctl_search")
44 .blocklist_type("bch_extent_ptr")
45 .blocklist_type("btree_node")
46 .blocklist_type("bch_extent_crc32")
47 .blocklist_type("rhash_lock_head")
48 .blocklist_type("srcu_struct")
49 .allowlist_var("BCH_.*")
50 .allowlist_var("KEY_SPEC_.*")
51 .allowlist_type("bch_kdf_types")
52 .allowlist_type("bch_sb_field_.*")
53 .allowlist_type("bch_encrypted_key")
54 .allowlist_type("nonce")
55 .newtype_enum("bch_kdf_types")
56 .opaque_type("gendisk")
58 .opaque_type("gc_stripe")
59 .opaque_type("open_bucket.*")
61 .expect("BindGen Generation Failiure: [libbcachefs_wrapper]");
63 .write_to_file(out_dir.join("bcachefs.rs"))
64 .expect("Writing to output file failed for: `bcachefs.rs`");
66 let keyutils = pkg_config::probe_library("libkeyutils").expect("Failed to find keyutils lib");
67 let bindings = bindgen::builder()
71 .join("keyutils_wrapper.h")
79 .map(|p| format!("-I{}", p.display())),
82 .expect("BindGen Generation Failiure: [Keyutils]");
84 .write_to_file(out_dir.join("keyutils.rs"))
85 .expect("Writing to output file failed for: `keyutils.rs`");