mirror of
https://github.com/uutils/coreutils
synced 2024-11-15 09:27:21 +00:00
30bba07f9c
squashed: a2c6b27 - build: automatically generate main() files c942f0f - remove MULTICALL=1 build from travis cb7b35b - make: remove unnecessary shell command 69bbb31 - update README 03a3168 - all: move main() into separate file that links against util crate 8276384 - make: always build multicall binary aa4edeb - make: avoid 'rustc --crate-file-name'
40 lines
889 B
Rust
40 lines
889 B
Rust
use std::io::{File, Truncate, ReadWrite};
|
|
use std::os;
|
|
use std::path::Path;
|
|
use std::str::replace;
|
|
|
|
static TEMPLATE : &'static str = r"
|
|
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;
|
|
}
|
|
|
|
let crat = match args.get(1).as_slice() {
|
|
"true" => "uutrue",
|
|
"false" => "uufalse",
|
|
"sync" => "uusync",
|
|
s => s.clone(),
|
|
};
|
|
let outfile = args.get(2).as_slice();
|
|
|
|
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()) {
|
|
Err(e) => fail!("{}", e),
|
|
_ => (),
|
|
}
|
|
}
|