forked from rusterlium/erlang_nif-sys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
30 lines (25 loc) · 810 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
// build.rs
//
// Execute Erlang script to generate API lists and extract config.
//
use std::os::raw::c_ulong;
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
// use environment escript if available
let escript = env::var("ESCRIPT").unwrap_or("escript".to_string());
// get size of C long
let ulong_size = std::mem::size_of::<c_ulong>();
// setup output directory
let out_dir = env::var("OUT_DIR")
.map_err(|_|"Can't read OUT_DIR env variable.")
.unwrap();
let dst = Path::new(&out_dir);
match Command::new(escript).arg("gen_api.erl").arg(ulong_size.to_string()).arg(dst).status()
.map_err(|_|"Failed to start gen_api.erl. Is 'escript' available in the path?")
.unwrap().success() {
true => (),
false => panic!("gen_api.erl encountered an error.")
}
}