-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
29 lines (23 loc) · 786 Bytes
/
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
use std::env;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = cc::Build::new();
let builder = builder
.file("fatfs/source/ff.c")
.file("fatfs/source/ffunicode.c");
builder.compile("fatfs");
let target = env::var("TARGET")?;
let bindings = bindgen::Builder::default()
.header("fatfs/source/ff.h")
.clang_arg(format!("--target={}", target))
.use_core()
.ctypes_prefix("cty")
.derive_copy(false)
.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(())
}