extern crate xdrgen;
use std::process::Command;
use std::fs::OpenOptions;
use std::env;
use std::path::PathBuf;
use std::io::Write;
fn compile(source: &str) {
let cpp = Command::new("/usr/bin/cpp")
.arg("-include")
.arg("libvirt-defs.h")
.arg(source)
.output().unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let mut path = PathBuf::from(out_dir);
path.push(source);
let mut file = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&path).unwrap();
file.write_all(&cpp.stdout).unwrap();
let path_str = format!("{}", path.display());
xdrgen::compile(path_str).unwrap();
}
fn main() {
compile("virnetprotocol.x");
compile("remote_protocol.x");
}