drying ethcore
This commit is contained in:
parent
86db5c08fc
commit
d8a3137ce8
@ -14,48 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate syntex;
|
||||
extern crate ethcore_ipc_codegen as codegen;
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
// serialization pass
|
||||
{
|
||||
let src = Path::new("src/types/mod.rs.in");
|
||||
let dst = Path::new(&out_dir).join("types.rs");
|
||||
let mut registry = syntex::Registry::new();
|
||||
codegen::register(&mut registry);
|
||||
registry.expand("", &src, &dst).unwrap();
|
||||
}
|
||||
|
||||
// blockchain client interface
|
||||
{
|
||||
let src = Path::new("src/client/traits.rs");
|
||||
let intermediate = Path::new(&out_dir).join("traits.intermediate.rs.in");
|
||||
let mut registry = syntex::Registry::new();
|
||||
codegen::register(&mut registry);
|
||||
registry.expand("", &src, &intermediate).unwrap();
|
||||
|
||||
let dst = Path::new(&out_dir).join("traits.ipc.rs");
|
||||
let mut registry = syntex::Registry::new();
|
||||
codegen::register(&mut registry);
|
||||
registry.expand("", &intermediate, &dst).unwrap();
|
||||
}
|
||||
|
||||
// chain notify interface
|
||||
{
|
||||
let src = Path::new("src/client/chain_notify.rs");
|
||||
let intermediate = Path::new(&out_dir).join("chain_notify.intermediate.rs.in");
|
||||
let mut registry = syntex::Registry::new();
|
||||
codegen::register(&mut registry);
|
||||
registry.expand("", &src, &intermediate).unwrap();
|
||||
|
||||
let dst = Path::new(&out_dir).join("chain_notify.ipc.rs");
|
||||
let mut registry = syntex::Registry::new();
|
||||
codegen::register(&mut registry);
|
||||
registry.expand("", &intermediate, &dst).unwrap();
|
||||
}
|
||||
codegen::derive_binary("src/types/mod.rs.in");
|
||||
codegen::derive_ipc("src/client/traits.rs");
|
||||
codegen::derive_ipc("src/client/chain_notify.rs");
|
||||
}
|
||||
|
@ -40,13 +40,13 @@ pub use self::traits::{BlockChainClient, MiningBlockChainClient, RemoteClient};
|
||||
|
||||
mod traits {
|
||||
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
|
||||
include!(concat!(env!("OUT_DIR"), "/traits.ipc.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/traits.rs"));
|
||||
}
|
||||
|
||||
pub mod chain_notify {
|
||||
//! Chain notify interface
|
||||
|
||||
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
|
||||
include!(concat!(env!("OUT_DIR"), "/chain_notify.ipc.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/chain_notify.rs"));
|
||||
}
|
||||
|
||||
|
@ -17,4 +17,4 @@
|
||||
//! Types used in the public api
|
||||
|
||||
#![allow(dead_code, unused_assignments, unused_variables)] // codegen issues
|
||||
include!(concat!(env!("OUT_DIR"), "/types.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/mod.rs.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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user