2015-02-06 13:48:07 +00:00
|
|
|
use std::env;
|
2015-04-16 04:59:33 +00:00
|
|
|
use std::io::Write;
|
|
|
|
use std::fs::File;
|
2014-06-25 16:47:34 +00:00
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
static TEMPLATE: &'static str = "\
|
2015-04-16 04:59:33 +00:00
|
|
|
extern crate @UTIL_CRATE@ as uu@UTIL_CRATE@;
|
2014-06-25 16:47:34 +00:00
|
|
|
|
2015-05-30 23:02:33 +00:00
|
|
|
use std::io::Write;
|
2015-01-10 21:00:15 +00:00
|
|
|
use uu@UTIL_CRATE@::uumain;
|
2014-06-25 16:47:34 +00:00
|
|
|
|
|
|
|
fn main() {
|
2015-05-30 23:02:33 +00:00
|
|
|
let code = uumain(std::env::args().collect());
|
|
|
|
|
|
|
|
// Since stdout is line-buffered by default, we need to ensure any pending
|
|
|
|
// writes are flushed before exiting. Ideally, this should be enforced by
|
|
|
|
// each utility.
|
|
|
|
//
|
|
|
|
// See: https://github.com/rust-lang/rust/issues/23818
|
|
|
|
//
|
|
|
|
std::io::stdout().flush().unwrap();
|
|
|
|
|
|
|
|
std::process::exit(code);
|
2014-06-25 16:47:34 +00:00
|
|
|
}
|
|
|
|
";
|
|
|
|
|
|
|
|
fn main() {
|
2015-02-13 19:57:47 +00:00
|
|
|
let args : Vec<String> = env::args().collect();
|
2014-06-25 16:47:34 +00:00
|
|
|
if args.len() != 3 {
|
|
|
|
println!("usage: mkbuild <crate> <outfile>");
|
2015-05-19 01:22:51 +00:00
|
|
|
std::process::exit(1);
|
2014-06-25 16:47:34 +00:00
|
|
|
}
|
|
|
|
|
2015-04-25 22:22:56 +00:00
|
|
|
let crat = match &args[1][..] {
|
|
|
|
"false" => "uufalse",
|
|
|
|
"test" => "uutest",
|
|
|
|
"true" => "uutrue",
|
|
|
|
_ => &args[1][..],
|
|
|
|
};
|
2015-04-16 04:59:33 +00:00
|
|
|
let outfile = &args[2][..];
|
2014-06-25 16:47:34 +00:00
|
|
|
|
2014-12-25 18:55:32 +00:00
|
|
|
let main = TEMPLATE.replace("@UTIL_CRATE@", crat);
|
2015-04-16 04:59:33 +00:00
|
|
|
match File::create(outfile) {
|
|
|
|
Ok(mut out) => match out.write_all(main.as_bytes()) {
|
|
|
|
Err(e) => panic!("{}", e),
|
|
|
|
_ => (),
|
|
|
|
},
|
2014-10-30 09:06:47 +00:00
|
|
|
Err(e) => panic!("{}", e),
|
2014-06-25 16:47:34 +00:00
|
|
|
}
|
|
|
|
}
|