drying ethcore
This commit is contained in:
@@ -132,3 +132,21 @@ pub fn derive_ipc(src_path: &str) -> Result<(), Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn derive_binary(src_path: &str) -> Result<(), Error> {
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
let file_name = try!(PathBuf::from(src_path).file_name().ok_or(Error::InvalidFileName).map(|val| val.to_str().unwrap().to_owned()));
|
||||
let final_path = Path::new(&out_dir).join(&file_name);
|
||||
|
||||
let mut registry = syntex::Registry::new();
|
||||
register(&mut registry);
|
||||
if let Err(_) = registry.expand("", &Path::new(src_path), &final_path) {
|
||||
// will be reported by compiler
|
||||
return Err(Error::ExpandFailure)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ pub fn main() {
|
||||
codegen::derive_ipc("nested.rs.in").unwrap();
|
||||
codegen::derive_ipc("service.rs.in").unwrap();
|
||||
codegen::derive_ipc("with_attrs.rs.in").unwrap();
|
||||
codegen::derive_ipc("binary.rs.in").unwrap();
|
||||
codegen::derive_binary("binary.rs.in").unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user