-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.rs
38 lines (29 loc) · 956 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
30
31
32
33
34
35
36
37
38
use std::env;
fn main() {
build_fathom();
generate_bindings();
}
fn build_fathom() {
let cc = &mut cc::Build::new();
cc.file("./deps/fathom/src/tbprobe.c");
cc.include("./deps/fathom/src");
cc.define("_CRT_SECURE_NO_WARNINGS", None);
let target_cpu = env::var("TARGET_CPU").unwrap_or("native".to_string());
cc.flag(&format!("-march={}", target_cpu));
// MSVC doesn't support stdatomic.h, so use clang on Windows
if env::consts::OS == "windows" {
cc.compiler("clang");
}
cc.compile("fathom");
}
fn generate_bindings() {
let bindings = bindgen::Builder::default()
.header("./deps/fathom/src/tbprobe.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.layout_tests(false)
.generate()
.expect("Unable to generate bindings");
bindings
.write_to_file("./src/tablebase/bindings.rs")
.expect("Couldn't write bindings!");
}