2014-06-25 16:47:34 +00:00
|
|
|
use std::io::{File, Truncate, ReadWrite};
|
|
|
|
use std::os;
|
|
|
|
use std::path::Path;
|
|
|
|
use std::str::replace;
|
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
static TEMPLATE: &'static str = "\
|
2014-06-25 16:47:34 +00:00
|
|
|
extern crate @UTIL_CRATE@;
|
|
|
|
|
|
|
|
use std::os;
|
|
|
|
use @UTIL_CRATE@::uumain;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
os::set_exit_status(uumain(os::args()));
|
|
|
|
}
|
|
|
|
";
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let args = os::args();
|
|
|
|
if args.len() != 3 {
|
|
|
|
println!("usage: mkbuild <crate> <outfile>");
|
|
|
|
os::set_exit_status(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-20 01:13:55 +00:00
|
|
|
let crat = match args[1].as_slice() {
|
2014-07-12 01:12:29 +00:00
|
|
|
"test" => "uutest",
|
2014-06-25 16:47:34 +00:00
|
|
|
"true" => "uutrue",
|
|
|
|
"false" => "uufalse",
|
|
|
|
"sync" => "uusync",
|
|
|
|
s => s.clone(),
|
|
|
|
};
|
2014-07-20 01:13:55 +00:00
|
|
|
let outfile = args[2].as_slice();
|
2014-06-25 16:47:34 +00:00
|
|
|
|
|
|
|
let main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat);
|
|
|
|
let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite);
|
|
|
|
|
|
|
|
match out.write(main.as_bytes()) {
|
2014-10-30 09:06:47 +00:00
|
|
|
Err(e) => panic!("{}", e),
|
2014-06-25 16:47:34 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|