1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 02:57:44 +00:00

change ~ remove transition-only and unneeded code for independent sub-crates

This commit is contained in:
Roy Ivy III 2020-05-05 23:38:56 -05:00
parent f051f62445
commit 0cb5fbd6b5
4 changed files with 2 additions and 106 deletions

View file

@ -29,7 +29,6 @@ pub fn main() {
}
crates.sort();
let mut cf = File::create(Path::new(&out_dir).join("uutils_crates.rs")).unwrap();
let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap();
mf.write_all(
@ -44,42 +43,7 @@ pub fn main() {
for krate in crates {
match krate.as_ref() {
"arch"
| "base32" | "base64" | "basename"
| "cat" | "chgrp" | "chmod" | "chown" | "chroot" | "cksum" | "comm" | "cp" | "cut"
| "date" | "df" | "dircolors" | "dirname" | "du"
| "echo" | "env" | "expand" | "expr"
| "factor" | "fmt" | "fold"
| "groups"
| "head" | "hostid" | "hostname"
| "id" | "install"
| "join"
| "kill"
| "link" | "ln" | "logname" | "ls"
| "mkdir" | "mkfifo" | "mknod" | "mktemp" | "more" | "mv"
| "nice" | "nl" | "nohup" | "nproc" | "numfmt"
| "od"
| "paste" | "pathchk" | "pinky" | "printenv" | "printf" | "ptx" | "pwd"
| "readlink" | "realpath" | "relpath" | "rm" | "rmdir"
| "seq" | "shred" | "shuf" | "sleep" | "sort" | "split" | "stat" | "stdbuf" | "sum" | "sync"
| "tac" | "tail" | "tee" | "test" | "timeout" | "touch" | "tr" | "truncate" | "tsort" | "tty"
| "uname" | "unexpand" | "uniq" | "unlink" | "uptime" | "users"
| "wc" | "who" | "whoami"
| "yes"
| "false" | "true"
| "hashsum"
| "uu_test"
=> {
// cf.write_all(format!("extern crate {krate};\n", krate = krate).as_bytes())
// .unwrap();
}
_ => {
cf.write_all(format!("extern crate uu_{krate};\n", krate = krate).as_bytes())
.unwrap();
}
}
match krate.as_ref() {
// ToDO: add another bypass method for publishing name collisions requiring a non-`uu_` prefix for a util
// * use "uu_" prefix as bypass method to avoid name collisions with imported crates, when necessary (eg, 'test')
k if k.starts_with("uu_")
=> mf
@ -88,34 +52,6 @@ pub fn main() {
.as_bytes(),
)
.unwrap(),
"arch"
| "base32" | "base64" | "basename"
| "cat" | "chgrp" | "chmod" | "chown" | "chroot" | "cksum" | "comm" | "cp" | "cut"
| "date" | "df" | "dircolors" | "dirname" | "du"
| "echo" | "env" | "expand" | "expr"
| "factor" | "fmt" | "fold"
| "groups"
| "head" | "hostid" | "hostname"
| "id" | "install"
| "join"
| "kill"
| "link" | "ln" | "logname" | "ls"
| "mkdir" | "mkfifo" | "mknod" | "mktemp" | "more" | "mv"
| "nice" | "nl" | "nohup" | "nproc" | "numfmt"
| "od"
| "paste" | "pathchk" | "pinky" | "printenv" | "printf" | "ptx" | "pwd"
| "readlink" | "realpath" | "relpath" | "rm" | "rmdir"
| "seq" | "shred" | "shuf" | "sleep" | "sort" | "split" | "stat" | "stdbuf" | "sum" | "sync"
| "tac" | "tail" | "tee" | "timeout" | "touch" | "tr" | "truncate" | "tsort" | "tty"
| "uname" | "unexpand" | "uniq" | "unlink" | "uptime" | "users"
| "wc" | "who" | "whoami"
| "yes"
=> mf
.write_all(
format!("map.insert(\"{krate}\", {krate}::uumain);\n", krate = krate)
.as_bytes(),
)
.unwrap(),
"false" | "true" => mf
.write_all(
format!("map.insert(\"{krate}\", r#{krate}::uumain);\n", krate = krate)
@ -148,7 +84,7 @@ pub fn main() {
_ => mf
.write_all(
format!(
"map.insert(\"{krate}\", uu_{krate}::uumain);\n",
"map.insert(\"{krate}\", {krate}::uumain);\n",
krate = krate
)
.as_bytes(),
@ -159,6 +95,5 @@ pub fn main() {
mf.write_all(b"map\n}\n").unwrap();
cf.flush().unwrap();
mf.flush().unwrap();
}

View file

@ -12,8 +12,6 @@
// spell-checker:ignore (uutils) coreutils sigpipe uucore uumain uutils
// spell-checker:ignore (shell) busybox symlinks
include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs"));
extern crate lazy_static;
extern crate textwrap;
extern crate uucore;

View file

@ -1,36 +0,0 @@
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
static TEMPLATE: &str = "\
extern crate uu_@UTIL_CRATE@;
extern crate uucore;
use std::io::Write;
use uu_@UTIL_CRATE@::uumain;
fn main() {
uucore::panic::install_sigpipe_hook();
let code = uumain(uucore::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().expect(\"could not flush stdout\");
std::process::exit(code);
}
";
pub fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let pkgname = env::var("CARGO_PKG_NAME").unwrap();
let main = TEMPLATE.replace("@UTIL_CRATE@", &pkgname);
let mut file = File::create(&Path::new(&out_dir).join("main.rs")).unwrap();
write!(file, "{}", main).unwrap();
}

View file

@ -1 +0,0 @@
include!(concat!(env!("OUT_DIR"), "/main.rs"));