ruster_unsafe 0.4.0

Create Erlang NIF modules in Rust using the C NIF API.
// build.rs
//
// Execute Erlang script to generate API lists and extract config.
//

extern crate libc;
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::<libc::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.")
		}
}