mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #740 from jbcrail/simplify-build
Refactor and simplify build for utilities
This commit is contained in:
+2
-2
@@ -177,5 +177,5 @@ rand="*"
|
||||
tempdir="*"
|
||||
|
||||
[[bin]]
|
||||
name="uutils"
|
||||
path="src/uutils/uutils.rs"
|
||||
name = "uutils"
|
||||
path = "src/uutils/uutils.rs"
|
||||
|
||||
@@ -168,11 +168,6 @@ test_integration_$(1): build_exe_$(1)
|
||||
${CARGO} test --test $(1) --features $(1) --no-default-features
|
||||
endef
|
||||
|
||||
define TEST_UNIT
|
||||
test_unit_$(1):
|
||||
${CARGO} test -p $(1)
|
||||
endef
|
||||
|
||||
# Output names
|
||||
EXES := \
|
||||
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
||||
@@ -213,9 +208,8 @@ build-uutils: $(addprefix build_exe_,$(EXES))
|
||||
build: build-uutils
|
||||
|
||||
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
|
||||
$(foreach test,$(TESTS),$(eval $(call TEST_UNIT,$(test))))
|
||||
|
||||
test: $(addprefix test_integration_,$(TESTS)) $(addprefix test_unit_,$(TESTS))
|
||||
test: $(addprefix test_integration_,$(TESTS))
|
||||
|
||||
clean:
|
||||
$(RM) -rf $(BUILDDIR)
|
||||
|
||||
@@ -12,49 +12,43 @@ pub fn main() {
|
||||
if val == "1" && key.starts_with(feature_prefix) {
|
||||
let krate = key[feature_prefix.len()..].to_lowercase();
|
||||
match krate.as_ref() {
|
||||
"default" | "unix" | "generic" => continue,
|
||||
_ => {},
|
||||
"default" | "unix" | "generic" => continue,
|
||||
_ => {},
|
||||
}
|
||||
crates.push(krate.to_string());
|
||||
}
|
||||
}
|
||||
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("
|
||||
type UtilityMap = HashMap<&'static str, fn(Vec<String>) -> i32>;
|
||||
|
||||
fn util_map() -> UtilityMap {
|
||||
let mut map: UtilityMap = HashMap::new();\n".as_bytes()).unwrap();
|
||||
|
||||
for krate in crates {
|
||||
match krate.as_ref() {
|
||||
"false" | "true" => {},
|
||||
"test" => cf.write_all(format!("extern crate uu{krate};\n", krate=krate).as_bytes()).unwrap(),
|
||||
_ => cf.write_all(format!("extern crate {krate} as uu{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() {
|
||||
"hashsum" => {
|
||||
mf.write_all("map.insert(\"hashsum\", uuhashsum::uumain);
|
||||
map.insert(\"md5sum\", uuhashsum::uumain);
|
||||
map.insert(\"sha1sum\", uuhashsum::uumain);
|
||||
map.insert(\"sha224sum\", uuhashsum::uumain);
|
||||
map.insert(\"sha256sum\", uuhashsum::uumain);
|
||||
map.insert(\"sha384sum\", uuhashsum::uumain);
|
||||
map.insert(\"sha512sum\", uuhashsum::uumain);\n".as_bytes()).unwrap();
|
||||
mf.write_all("map.insert(\"hashsum\", uu_hashsum::uumain);
|
||||
map.insert(\"md5sum\", uu_hashsum::uumain);
|
||||
map.insert(\"sha1sum\", uu_hashsum::uumain);
|
||||
map.insert(\"sha224sum\", uu_hashsum::uumain);
|
||||
map.insert(\"sha256sum\", uu_hashsum::uumain);
|
||||
map.insert(\"sha384sum\", uu_hashsum::uumain);
|
||||
map.insert(\"sha512sum\", uu_hashsum::uumain);\n".as_bytes()).unwrap();
|
||||
},
|
||||
"false" =>
|
||||
mf.write_all("fn uufalse(_: Vec<String>) -> i32 { 1 }
|
||||
map.insert(\"false\", uufalse as fn(Vec<String>) -> i32);\n".as_bytes()).unwrap(),
|
||||
"true" =>
|
||||
mf.write_all("fn uutrue(_: Vec<String>) -> i32 { 0 }
|
||||
map.insert(\"true\", uutrue as fn(Vec<String>) -> i32);\n".as_bytes()).unwrap(),
|
||||
_ =>
|
||||
mf.write_all(format!("map.insert(\"{krate}\", uu{krate}::uumain as fn(Vec<String>) -> i32);\n", krate= krate).as_bytes()).unwrap(),
|
||||
mf.write_all(format!("map.insert(\"{krate}\", uu_{krate}::uumain);\n", krate=krate).as_bytes()).unwrap(),
|
||||
}
|
||||
}
|
||||
mf.write_all("map
|
||||
}\n".as_bytes()).unwrap();
|
||||
|
||||
mf.write_all("map\n}\n".as_bytes()).unwrap();
|
||||
|
||||
cf.flush().unwrap();
|
||||
mf.flush().unwrap();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "base64"
|
||||
name = "uu_base64"
|
||||
path = "base64.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -14,5 +14,5 @@ rustc-serialize = "*"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
name="base64"
|
||||
path="base64.rs"
|
||||
name = "base64"
|
||||
path = "main.rs"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "base64"]
|
||||
#![crate_name = "uu_base64"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -159,8 +159,3 @@ fn help(opts: Options) {
|
||||
fn version() {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate uu_base64;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_base64::uumain(std::env::args().collect()));
|
||||
}
|
||||
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "basename"
|
||||
name = "uu_basename"
|
||||
path = "basename.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -13,5 +13,5 @@ libc = "*"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
name="basename"
|
||||
path="basename.rs"
|
||||
name = "basename"
|
||||
path = "main.rs"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "basename"]
|
||||
#![crate_name = "uu_basename"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -105,8 +105,3 @@ fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||
|
||||
name.to_string()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate uu_basename;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_basename::uumain(std::env::args().collect()));
|
||||
}
|
||||
+3
-3
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "cat"
|
||||
name = "uu_cat"
|
||||
path = "cat.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -13,5 +13,5 @@ libc = "*"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
name="cat"
|
||||
path="cat.rs"
|
||||
name = "cat"
|
||||
path = "main.rs"
|
||||
|
||||
+1
-8
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "cat"]
|
||||
#![crate_name = "uu_cat"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -339,10 +339,3 @@ impl<'a, W: Write> Drop for UnsafeWriter<'a, W> {
|
||||
let _ = self.flush_buf();
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ai ts=4 sw=4 sts=4 et : */
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate uu_cat;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_cat::uumain(std::env::args().collect()));
|
||||
}
|
||||
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "chmod"
|
||||
name = "uu_chmod"
|
||||
path = "chmod.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -18,5 +18,5 @@ uucore = { path="../uucore" }
|
||||
walker = "*"
|
||||
|
||||
[[bin]]
|
||||
name="chmod"
|
||||
path="chmod.rs"
|
||||
name = "chmod"
|
||||
path = "main.rs"
|
||||
|
||||
+1
-6
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "chmod"]
|
||||
#![crate_name = "uu_chmod"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -319,8 +319,3 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate uu_chmod;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_chmod::uumain(std::env::args().collect()));
|
||||
}
|
||||
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "chroot"
|
||||
name = "uu_chroot"
|
||||
path = "chroot.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -13,5 +13,5 @@ libc = "*"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
name="chroot"
|
||||
path="chroot.rs"
|
||||
name = "chroot"
|
||||
path = "main.rs"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "chroot"]
|
||||
#![crate_name = "uu_chroot"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -216,8 +216,3 @@ If $(SHELL) is not set, /bin/sh is used.", NAME, VERSION);
|
||||
|
||||
print!("{}", options.usage(&msg));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate uu_chroot;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_chroot::uumain(std::env::args().collect()));
|
||||
}
|
||||
@@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[lib]
|
||||
name = "cksum"
|
||||
name = "uu_cksum"
|
||||
path = "cksum.rs"
|
||||
|
||||
[dependencies]
|
||||
@@ -13,5 +13,5 @@ libc = "*"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
name="cksum"
|
||||
path="cksum.rs"
|
||||
name = "cksum"
|
||||
path = "main.rs"
|
||||
|
||||
+1
-6
@@ -1,4 +1,4 @@
|
||||
#![crate_name = "cksum"]
|
||||
#![crate_name = "uu_cksum"]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
@@ -128,8 +128,3 @@ Print CRC and size for each file.", NAME, VERSION);
|
||||
|
||||
exit_code
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user