mirror of
https://github.com/uutils/coreutils.git
synced 2026-05-06 07:26:38 -04:00
build: sort coreutils entries at build time (#10820)
This commit is contained in:
@@ -72,26 +72,37 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
let mut phf_map = phf_codegen::OrderedMap::<&str>::new();
|
||||
let mut entries = Vec::new();
|
||||
|
||||
for krate in &crates {
|
||||
let map_value = format!("({krate}::uumain, {krate}::uu_app)");
|
||||
match krate.as_ref() {
|
||||
// 'test' is named uu_test to avoid collision with rust core crate 'test'.
|
||||
// It can also be invoked by name '[' for the '[ expr ] syntax'.
|
||||
"uu_test" => {
|
||||
phf_map.entry("test", map_value.clone());
|
||||
phf_map.entry("[", map_value.clone());
|
||||
entries.push(("test", map_value.clone()));
|
||||
entries.push(("[", map_value.clone()));
|
||||
}
|
||||
k if k.starts_with(OVERRIDE_PREFIX) => {
|
||||
phf_map.entry(&k[OVERRIDE_PREFIX.len()..], map_value.clone());
|
||||
entries.push((&k[OVERRIDE_PREFIX.len()..], map_value.clone()));
|
||||
}
|
||||
"false" | "true" => {
|
||||
phf_map.entry(krate, format!("(r#{krate}::uumain, r#{krate}::uu_app)"));
|
||||
entries.push((
|
||||
krate.as_str(),
|
||||
format!("(r#{krate}::uumain, r#{krate}::uu_app)"),
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
phf_map.entry(krate, map_value.clone());
|
||||
entries.push((krate.as_str(), map_value.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
entries.sort_by_key(|(name, _)| *name);
|
||||
|
||||
for (name, value) in entries {
|
||||
phf_map.entry(name, value);
|
||||
}
|
||||
|
||||
write!(mf, "{}", phf_map.build()).unwrap();
|
||||
mf.write_all(b"\n}\n").unwrap();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ fn usage<T>(utils: &UtilityMap<T>, name: &str) {
|
||||
println!("Options:");
|
||||
println!(" --list lists all defined functions, one per row\n");
|
||||
println!("Currently defined functions:\n");
|
||||
let display_list = utils.keys().copied().sorted_unstable().join(", ");
|
||||
let display_list = utils.keys().copied().join(", ");
|
||||
let width = cmp::min(textwrap::termwidth(), 100) - 4 * 2; // (opinion/heuristic) max 100 chars wide with 4 character side indentions
|
||||
println!(
|
||||
"{}",
|
||||
@@ -81,8 +81,7 @@ fn main() {
|
||||
usage(&utils, binary_as_util);
|
||||
process::exit(0);
|
||||
}
|
||||
let mut utils: Vec<_> = utils.keys().collect();
|
||||
utils.sort();
|
||||
let utils: Vec<_> = utils.keys().collect();
|
||||
for util in utils {
|
||||
println!("{util}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user