From f051f6244508b8fcefb926e3cefacce2fdb64c5a Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Tue, 5 May 2020 01:47:26 -0500 Subject: [PATCH] change ~ add work-around for crate name collisions - imported crate name collisions bypass implemented ## [why] There may be some core or external crates required/used by this project that collide with uutil names. For example, the `test` util collides with the rust core crate 'test' which is used behind the scenes for testing. Without the renaming scheme used here, cryptic and fatal compiler errors occur when compiling the integration tests. --- Cargo.toml | 6 +++++- build.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a4b2454d3..c81f3946c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -210,6 +210,9 @@ feat_os_windows_legacy = [ "touch", "whoami", ] +## +# * bypass ~ use "uu_" prefix to avoid collision with rust core 'test' crate (o/w surfaces as compiler errors during testing) +test = [ "uu_test" ] [workspace] @@ -218,6 +221,8 @@ lazy_static = { version="1.3" } textwrap = { version="=0.11.0", features=["term_size"] } # !maint: [2020-05-10; rivy] unstable crate using undocumented features; pinned currently, will review uucore = { version="0.0.2", package="uucore", git="https://github.com/uutils/uucore.git", branch="master" } # * uutils +uu_test = { optional=true, version="0.0.1", package="uu_test", path="src/uu/test" } +# arch = { optional=true, version="0.0.1", package="uu_arch", path="src/uu/arch" } base32 = { optional=true, version="0.0.1", package="uu_base32", path="src/uu/base32" } base64 = { optional=true, version="0.0.1", package="uu_base64", path="src/uu/base64" } @@ -294,7 +299,6 @@ sync = { optional=true, version="0.0.1", package="uu_sync", path="src/uu/syn tac = { optional=true, version="0.0.1", package="uu_tac", path="src/uu/tac" } tail = { optional=true, version="0.0.1", package="uu_tail", path="src/uu/tail" } tee = { optional=true, version="0.0.1", package="uu_tee", path="src/uu/tee" } -test = { optional=true, version="0.0.1", package="uu_test", path="src/uu/test" } timeout = { optional=true, version="0.0.1", package="uu_timeout", path="src/uu/timeout" } touch = { optional=true, version="0.0.1", package="uu_touch", path="src/uu/touch" } tr = { optional=true, version="0.0.1", package="uu_tr", path="src/uu/tr" } diff --git a/build.rs b/build.rs index c51ce1481..4dcac8111 100644 --- a/build.rs +++ b/build.rs @@ -68,6 +68,7 @@ pub fn main() { | "yes" | "false" | "true" | "hashsum" + | "uu_test" => { // cf.write_all(format!("extern crate {krate};\n", krate = krate).as_bytes()) // .unwrap(); @@ -79,6 +80,14 @@ pub fn main() { } match krate.as_ref() { + // * use "uu_" prefix as bypass method to avoid name collisions with imported crates, when necessary (eg, 'test') + k if k.starts_with("uu_") + => mf + .write_all( + format!("map.insert(\"{k}\", {krate}::uumain);\n", k = krate.clone().remove("uu_".len()), krate = krate) + .as_bytes(), + ) + .unwrap(), "arch" | "base32" | "base64" | "basename" | "cat" | "chgrp" | "chmod" | "chown" | "chroot" | "cksum" | "comm" | "cp" | "cut" @@ -97,7 +106,7 @@ pub fn main() { | "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" + | "tac" | "tail" | "tee" | "timeout" | "touch" | "tr" | "truncate" | "tsort" | "tty" | "uname" | "unexpand" | "uniq" | "unlink" | "uptime" | "users" | "wc" | "who" | "whoami" | "yes"