-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.rs
43 lines (34 loc) · 1.16 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::env;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = cc::Build::new();
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")
.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(())
}