diff --git a/Cargo.toml b/Cargo.toml index c71f768e5ef..5cf0d4b26a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -310,7 +310,6 @@ numfmt = { optional = true, version = "0.13.0", package = "uu_numfmt", path = "s od = { optional = true, version = "0.13.0", package = "uu_od", path = "src/uu/od" } paste = { optional = true, version = "0.13.0", package = "uu_paste", path = "src/uu/paste" } pathchk = { optional = true, version = "0.13.0", package = "uu_pathchk", path = "src/uu/pathchk" } -pinky = { optional = true, version = "0.13.0", package = "uu_pinky", path = "src/uu/pinky" } pr = { optional = true, version = "0.13.0", package = "uu_pr", path = "src/uu/pr" } printenv = { optional = true, version = "0.13.0", package = "uu_printenv", path = "src/uu/printenv" } printf = { optional = true, version = "0.13.0", package = "uu_printf", path = "src/uu/printf" } @@ -349,7 +348,6 @@ uptime = { optional = true, version = "0.13.0", package = "uu_uptime", path = "s users = { optional = true, version = "0.13.0", package = "uu_users", path = "src/uu/users" } vdir = { optional = true, version = "0.13.0", package = "uu_vdir", path = "src/uu/vdir" } wc = { optional = true, version = "0.13.0", package = "uu_wc", path = "src/uu/wc" } -who = { optional = true, version = "0.13.0", package = "uu_who", path = "src/uu/who" } whoami = { optional = true, version = "0.13.0", package = "uu_whoami", path = "src/uu/whoami" } yes = { optional = true, version = "0.13.0", package = "uu_yes", path = "src/uu/yes" } @@ -399,6 +397,10 @@ runcon = { optional = true, version = "0.13.0", package = "uu_runcon", path = "s # Not needed for now. Keep as examples: #pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`) +[target.'cfg(any(target_vendor = "apple", target_os = "cygwin", target_os = "freebsd", target_os = "linux", target_os = "netbsd"))'.dependencies] +pinky = { optional = true, version = "0.13.0", package = "uu_pinky", path = "src/uu/pinky" } +who = { optional = true, version = "0.13.0", package = "uu_who", path = "src/uu/who" } + [target.'cfg(unix)'.dev-dependencies] nix = { workspace = true, features = ["fs", "signal"] } rlimit = { workspace = true } diff --git a/build.rs b/build.rs index 923b2f44d1a..8eec770c58a 100644 --- a/build.rs +++ b/build.rs @@ -41,6 +41,7 @@ pub fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let target_os = env::var_os("CARGO_CFG_TARGET_OS").unwrap(); + let target_vendor = env::var_os("CARGO_CFG_TARGET_VENDOR").unwrap(); for (key, val) in env::vars() { if val == "1" && key.starts_with(ENV_FEATURE_PREFIX) { let krate = key[ENV_FEATURE_PREFIX.len()..].to_lowercase(); @@ -50,6 +51,15 @@ pub fn main() { "chcon" | "runcon" if !(target_os == "linux" || target_os == "android") => { continue; } + "pinky" | "who" + if !(target_vendor == "apple" + || target_os == "cygwin" + || target_os == "freebsd" + || target_os == "linux" + || target_os == "netbsd") => + { + continue; + } "default" | "macos" | "unix" | "windows" | "selinux" | "zip" | "clap_complete" | "clap_mangen" | "fluent_syntax" | "openssl" => continue, // common/standard feature names "nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => { diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index 515c65db03c..5c88546a2a9 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -17,7 +17,7 @@ readme.workspace = true path = "src/pinky.rs" doctest = false -[dependencies] +[target.'cfg(any(target_vendor = "apple", target_os = "cygwin", target_os = "freebsd", target_os = "linux", target_os = "netbsd"))'.dependencies] clap = { workspace = true } fluent = { workspace = true } uucore = { workspace = true, features = ["utmpx", "entries"] } @@ -31,3 +31,4 @@ workspace = true [[bin]] name = "pinky" path = "src/main.rs" +required-features = ["uucore/default"] diff --git a/src/uu/pinky/locales/en-US.ftl b/src/uu/pinky/locales/en-US.ftl index eba1148b7c2..ae5364dc2d2 100644 --- a/src/uu/pinky/locales/en-US.ftl +++ b/src/uu/pinky/locales/en-US.ftl @@ -37,6 +37,3 @@ pinky-directory-label = Directory: pinky-shell-label = Shell: pinky-project-label = Project: pinky-plan-label = Plan - -# Status messages -pinky-unsupported-openbsd = unsupported command on OpenBSD diff --git a/src/uu/pinky/locales/fr-FR.ftl b/src/uu/pinky/locales/fr-FR.ftl index 81a0b3f3ce8..7d7688c287b 100644 --- a/src/uu/pinky/locales/fr-FR.ftl +++ b/src/uu/pinky/locales/fr-FR.ftl @@ -37,6 +37,3 @@ pinky-directory-label = Répertoire : pinky-shell-label = Shell : pinky-project-label = Projet : pinky-plan-label = Plan - -# Messages de statut -pinky-unsupported-openbsd = commande non prise en charge sur OpenBSD diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 9dea772e479..80f0064a07c 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -3,6 +3,14 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +#![cfg(any( + target_vendor = "apple", + target_os = "cygwin", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", +))] + use clap::{Arg, ArgAction, Command}; use uucore::format_usage; use uucore::translate; diff --git a/src/uu/pinky/src/platform/mod.rs b/src/uu/pinky/src/platform/mod.rs index e0e87dca1bf..906b7e7dbb9 100644 --- a/src/uu/pinky/src/platform/mod.rs +++ b/src/uu/pinky/src/platform/mod.rs @@ -3,12 +3,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -#[cfg(not(target_os = "openbsd"))] mod unix; -#[cfg(not(target_os = "openbsd"))] -pub use self::unix::*; -#[cfg(target_os = "openbsd")] -mod openbsd; -#[cfg(target_os = "openbsd")] -pub use self::openbsd::*; +pub use self::unix::*; diff --git a/src/uu/pinky/src/platform/openbsd.rs b/src/uu/pinky/src/platform/openbsd.rs deleted file mode 100644 index ad3a4a9bf1d..00000000000 --- a/src/uu/pinky/src/platform/openbsd.rs +++ /dev/null @@ -1,20 +0,0 @@ -// This file is part of the uutils coreutils package. -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -// Specific implementation for OpenBSD: tool unsupported (utmpx not supported) - -use crate::uu_app; - -use uucore::error::UResult; -use uucore::translate; - -use std::io; -use std::io::prelude::*; - -pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let _matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?; - writeln!(io::stdout(), "{}", translate!("pinky-unsupported-openbsd"))?; - Ok(()) -} diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index 1e8d2d2298d..54e86178c1c 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -18,7 +18,7 @@ path = "src/who.rs" test = false doctest = false -[dependencies] +[target.'cfg(any(target_vendor = "apple", target_os = "cygwin", target_os = "freebsd", target_os = "linux", target_os = "netbsd"))'.dependencies] clap = { workspace = true } fluent = { workspace = true } rustix = { workspace = true, features = ["fs", "termios"] } @@ -33,3 +33,4 @@ workspace = true [[bin]] name = "who" path = "src/main.rs" +required-features = ["uucore/default"] diff --git a/src/uu/who/locales/en-US.ftl b/src/uu/who/locales/en-US.ftl index 2984c2fdcc5..cca15b31852 100644 --- a/src/uu/who/locales/en-US.ftl +++ b/src/uu/who/locales/en-US.ftl @@ -54,6 +54,3 @@ who-heading-exit = EXIT # Error messages who-canonicalize-error = failed to canonicalize { $host } - -# Platform-specific messages -who-unsupported-openbsd = unsupported command on OpenBSD diff --git a/src/uu/who/locales/fr-FR.ftl b/src/uu/who/locales/fr-FR.ftl index 0c853e51ee9..5cfb7c2d233 100644 --- a/src/uu/who/locales/fr-FR.ftl +++ b/src/uu/who/locales/fr-FR.ftl @@ -53,6 +53,3 @@ who-heading-exit = SORTIE # Error messages who-canonicalize-error = échec de canonicalisation de { $host } - -# Platform-specific messages -who-unsupported-openbsd = commande non prise en charge sur OpenBSD diff --git a/src/uu/who/src/platform/mod.rs b/src/uu/who/src/platform/mod.rs index e0e87dca1bf..906b7e7dbb9 100644 --- a/src/uu/who/src/platform/mod.rs +++ b/src/uu/who/src/platform/mod.rs @@ -3,12 +3,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -#[cfg(not(target_os = "openbsd"))] mod unix; -#[cfg(not(target_os = "openbsd"))] -pub use self::unix::*; -#[cfg(target_os = "openbsd")] -mod openbsd; -#[cfg(target_os = "openbsd")] -pub use self::openbsd::*; +pub use self::unix::*; diff --git a/src/uu/who/src/platform/openbsd.rs b/src/uu/who/src/platform/openbsd.rs deleted file mode 100644 index f5871382b11..00000000000 --- a/src/uu/who/src/platform/openbsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -// This file is part of the uutils coreutils package. -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -// Specific implementation for OpenBSD: tool unsupported (utmpx not supported) - -use crate::uu_app; - -use uucore::error::UResult; -use uucore::translate; - -pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let _matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?; - println!("{}", translate!("who-unsupported-openbsd")); - Ok(()) -} diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index e82990b7924..c0478cd21b0 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -5,6 +5,14 @@ // spell-checker:ignore (ToDO) runlevel mesg +#![cfg(any( + target_vendor = "apple", + target_os = "cygwin", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", +))] + use clap::{Arg, ArgAction, Command}; use uucore::format_usage; use uucore::translate; diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index 60a130e0782..fec5839a2b5 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -3,12 +3,17 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -#[cfg(not(target_os = "openbsd"))] +#![cfg(any( + target_vendor = "apple", + target_os = "cygwin", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", +))] + use uucore::entries::{Locate, Passwd}; use uutests::new_ucmd; -#[cfg(not(target_os = "openbsd"))] use uutests::util::{TestScenario, expected_result}; -#[cfg(not(target_os = "openbsd"))] use uutests::{unwrap_or_return, util_name}; #[test] @@ -17,7 +22,6 @@ fn test_invalid_arg() { } #[test] -#[cfg(not(target_os = "openbsd"))] fn test_long_format() { use pinky::capitalize; @@ -43,7 +47,6 @@ fn test_long_format() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_long_format_multiple_users() { // multiple instances of one account we know exists, // the account of the test runner, @@ -61,7 +64,6 @@ fn test_long_format_multiple_users() { } #[test] -#[cfg(not(target_os = "openbsd"))] fn test_long_format_numeric_operand_is_not_a_uid() { // No account is named "+0", so it must not be looked up as uid 0. new_ucmd!() @@ -78,7 +80,6 @@ fn test_long_format_wo_user() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_short_format_i() { // allow whitespace variation // * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant @@ -98,7 +99,6 @@ fn test_short_format_i() { /// Remove the `Idle` header and every `HH:MM`-looking token so only the stable /// fields are compared. #[cfg(unix)] -#[cfg(not(target_os = "openbsd"))] fn strip_volatile_fields(fields: &[&str]) -> Vec { fn is_clock_value(s: &str) -> bool { let bytes = s.as_bytes(); @@ -116,7 +116,6 @@ fn strip_volatile_fields(fields: &[&str]) -> Vec { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_lookup() { let args = ["--lookup"]; let ts = TestScenario::new(util_name!()); @@ -132,7 +131,6 @@ fn test_lookup() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_short_format_q() { // allow whitespace variation // * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant @@ -150,7 +148,6 @@ fn test_short_format_q() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_no_flag() { let ts = TestScenario::new(util_name!()); let actual = ts.ucmd().succeeds().stdout_move_str(); diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index 2456ad0fbb2..6d67b2c299d 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -5,6 +5,14 @@ // spell-checker:ignore (flags) runlevel mesg +#![cfg(any( + target_vendor = "apple", + target_os = "cygwin", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", +))] + use uutests::new_ucmd; use uutests::unwrap_or_return; use uutests::util::{TestScenario, expected_result, gnu_cmd_result}; @@ -27,7 +35,6 @@ fn test_count() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] #[cfg_attr( all(target_arch = "aarch64", target_os = "linux"), ignore = "Issue #7174 - Test not supported on ARM64 Linux" @@ -72,7 +79,6 @@ fn test_short() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_login() { let ts = TestScenario::new(util_name!()); for opt in ["-l", "--login", "--log"] { @@ -83,7 +89,6 @@ fn test_login() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_m() { let ts = TestScenario::new(util_name!()); let expected_stdout = unwrap_or_return!(expected_result(&ts, &["-m"])).stdout_move_str(); @@ -92,7 +97,6 @@ fn test_m() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_process() { let ts = TestScenario::new(util_name!()); for opt in ["-p", "--process", "--p"] { @@ -103,7 +107,6 @@ fn test_process() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_runlevel() { let ts = TestScenario::new(util_name!()); for opt in ["-r", "--runlevel", "--r"] { @@ -117,7 +120,6 @@ fn test_runlevel() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_time() { let ts = TestScenario::new(util_name!()); for opt in ["-t", "--time", "--t"] { @@ -153,7 +155,6 @@ fn test_mesg() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_arg1_arg2() { let args = ["am", "i"]; let ts = TestScenario::new(util_name!()); @@ -208,7 +209,6 @@ fn test_lookup() { #[cfg(unix)] #[test] -#[cfg(not(target_os = "openbsd"))] fn test_dead() { let ts = TestScenario::new(util_name!()); for opt in ["-d", "--dead", "--de"] {