-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
26 lines (23 loc) · 979 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
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
let bindings = bindgen::Builder::default()
// I just imported it straight from where it was on my computer.
// If we were building a real module we might not want to do this!
// Also if you're trying this on macOS this header file may not be
// in this particular location
.header("emacs-module.h")
// We want to specify our own emacs_module_init function, so we won't
// generate one in Rust automatically
.blocklist_function("emacs_module_init")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
// Generate the bindings
.generate()
// Explode if something goes wrong
.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!");
}