From e37468b630af868e56f473b540cb1d377e24a74b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 24 Nov 2016 17:15:43 -0500 Subject: [PATCH 1/3] Turn off utmpx and signals for Fuchsia. Fuchsia uses musl as its libc; musl only has stub implementation for utmpx. From their wiki, that is deliberately chosen. Fuchsia doesn't have signals mechanism. --- src/uucore/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uucore/lib.rs b/src/uucore/lib.rs index 5f19aa718..9b1a5e763 100644 --- a/src/uucore/lib.rs +++ b/src/uucore/lib.rs @@ -16,7 +16,7 @@ pub mod encoding; #[cfg(feature = "parse_time")] pub mod parse_time; -#[cfg(all(unix, feature = "utmpx"))] +#[cfg(all(unix, not(target_os = "fuchsia"), feature = "utmpx"))] pub mod utmpx; #[cfg(all(unix, feature = "utsname"))] pub mod utsname; @@ -24,7 +24,7 @@ pub mod utsname; pub mod entries; #[cfg(all(unix, feature = "process"))] pub mod process; -#[cfg(all(unix, feature = "signals"))] +#[cfg(all(unix, not(target_os = "fuchsia"), feature = "signals"))] pub mod signals; #[cfg(all(windows, feature = "wide"))] From 59c12433e0605b9960facd208f66249f232feddd Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 24 Nov 2016 17:30:03 -0500 Subject: [PATCH 2/3] Add Fuchsia as recognized host OS in uname. --- src/uname/uname.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 9fae33259..db5723d8c 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -28,6 +28,8 @@ static HOST_OS: &'static str = "FreeBSD"; static HOST_OS: &'static str = "OpenBSD"; #[cfg(target_os = "macos")] static HOST_OS: &'static str = "Darwin"; +#[cfg(target_os = "fuchsia")] +static HOST_OS: &'static str = "Fuchsia"; pub fn uumain(args: Vec) -> i32 { let mut opts = new_coreopts!(SYNTAX, SUMMARY, ""); From 546f2855d5fa31abcc4f91524b1aca87a12d9ab6 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 24 Nov 2016 17:54:47 -0500 Subject: [PATCH 3/3] Create a new feature for Fuchsia-enabled utilities. --- Cargo.toml | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ build.rs | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6e5ee3705..752439f51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,89 @@ unix = [ "users", "who", ] +# Feature "fuchsia" contains the exclusive list of utilities +# that can be compiled and run on Fuchsia. Should be built +# with --no-default-features when selecting this feature. +# TODO: merge with "generic"/"unix" to avoid duplication +# once we support all utilities in that feature. +fuchsia = [ + # From unix + "arch", + "chgrp", + "chmod", + "chown", + "du", + "groups", + "hostid", + "install", + "logname", + "mkfifo", + "mknod", + "nice", + "pathchk", + "stdbuf", + "touch", + "tty", + "uname", + "unlink", + + # From generic + "base32", + "base64", + "basename", + "cat", + "cksum", + "comm", + "cp", + "cut", + "dircolors", + "dirname", + "echo", + "env", + "expand", + "expr", + "factor", + "false", + "fmt", + "fold", + "hashsum", + "head", + "link", + "ln", + "mkdir", + "mv", + "nl", + "od", + "paste", + "printenv", + "printf", + "pwd", + "readlink", + "realpath", + "relpath", + "rm", + "rmdir", + "seq", + "shred", + "shuf", + "sleep", + "sort", + "split", + "sum", + "sync", + "tac", + "tail", + "tee", + "test", + "tr", + "true", + "truncate", + "tsort", + "unexpand", + "wc", + "whoami", + "yes", +] generic = [ "base32", "base64", diff --git a/build.rs b/build.rs index f06e751bf..1548858b4 100644 --- a/build.rs +++ b/build.rs @@ -12,7 +12,7 @@ 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" | "nightly" | "test_unimplemented" => continue, + "default" | "unix" | "fuchsia" | "generic" | "nightly" | "test_unimplemented" => continue, _ => {}, } crates.push(krate.to_string());