-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
26 lines (23 loc) · 878 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
use std::path::Path;
fn main() {
std::fs::create_dir_all("assets/tokens").expect("to create tokens directory");
for game in ["ck3", "hoi4", "eu4", "imperator", "vic3"] {
let fp = format!("assets/tokens/{game}.txt");
let p = std::path::Path::new(&fp);
if !p.exists() {
std::fs::write(p, "").expect("to write file");
}
}
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let out_path = Path::new(&crate_dir).join("target").join("rakaly.h");
cbindgen::Builder::new()
.with_cpp_compat(true)
.with_crate(crate_dir)
.with_language(cbindgen::Language::C)
.with_no_includes()
.with_include("stddef.h")
.with_trailer(include_str!("./src/cpp_helper.h"))
.generate()
.expect("Unable to generate bindings")
.write_to_file(out_path);
}