use std::env; use std::path::PathBuf; fn main() -> Result<(), Box> { let mut builder = cc::Build::new(); let target = env::var("TARGET")?; let builder = builder .flag("-std=c11") .flag("-DLFS_NO_DEBUG") .flag("-DLFS_NO_WARN") .flag("-DLFS_NO_ERROR") .file("littlefs/lfs.c") .file("littlefs/lfs_util.c") .file("string.c"); #[cfg(feature = "software-intrinsics")] let builder = builder.flag("-DLFS_NO_INTRINSICS"); #[cfg(not(feature = "assertions"))] let builder = builder.flag("-DLFS_NO_ASSERT"); #[cfg(feature = "trace")] let builder = builder.flag("-DLFS_YES_TRACE"); #[cfg(not(feature = "malloc"))] builder.flag("-DLFS_NO_MALLOC"); builder.compile("lfs-sys"); let bindings = bindgen::Builder::default() .header("littlefs/lfs.h") .clang_arg(format!("--target={}", target)) .use_core() .allowlist_item("lfs_.*") .allowlist_item("LFS_.*") .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); Ok(()) }