diff --git a/Cargo.toml b/Cargo.toml index e746c5752..93ac9659c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,85 +4,86 @@ version = "0.0.1" authors = [] build = "build.rs" - [features] -default = ["all"] -all = [ - "base64", - "basename", - "cat", - "chmod", - "chroot", - "cksum", - "comm", - "cp", - "cut", - "dirname", - "du", - "echo", - "env", - "expand", - "expr", - "factor", - "false", - "fmt", - "fold", - "groups", - "hashsum", - "head", - "hostid", - "hostname", - "id", - "kill", - "link", - "ln", - "logname", - "mkdir", - "mkfifo", - "mv", - "nice", - "nl", - "nohup", - "nproc", - "od", - "paste", - "printenv", - "ptx", - "pwd", - "readlink", - "realpath", - "relpath", - "rm", - "rmdir", - "seq", - "shuf", - "sleep", - "sort", - "split", - "stdbuf", - "sum", - "sync", - "tac", - "tail", - "tee", - "test", - "timeout", - "touch", - "tr", - "true", - "truncate", - "tsort", - "tty", - "uname", - "unexpand", - "uniq", - "unlink", - "uptime", - "users", - "wc", - "whoami", - "yes", +unix = [ + "chroot", + "du", + "groups", + "hostid", + "hostname", + "id", + "kill", + "logname", + "mkfifo", + "mv", + "nice", + "nohup", + "stdbuf", + "timeout", + "touch", + "tty", + "uname", + "unlink", + "uptime", + "users", ] +generic = [ + "base64", + "basename", + "cat", + "chmod", + "cksum", + "comm", + "cp", + "cut", + "dirname", + "echo", + "env", + "expand", + "expr", + "factor", + "false", + "fmt", + "fold", + "hashsum", + "head", + "link", + "ln", + "mkdir", + "nl", + "nproc", + "od", + "paste", + "printenv", + "ptx", + "pwd", + "readlink", + "realpath", + "relpath", + "rm", + "rmdir", + "seq", + "shuf", + "sleep", + "sort", + "split", + "sum", + "sync", + "tac", + "tail", + "tee", + "test", + "tr", + "true", + "truncate", + "tsort", + "unexpand", + "uniq", + "wc", + "whoami", + "yes", +] +default = ["generic", "unix"] [dependencies] uucore = { path="src/uucore" } @@ -178,4 +179,3 @@ tempdir="*" [[bin]] name="uutils" path="src/uutils/uutils.rs" - diff --git a/build.rs b/build.rs index 71ffd8cc1..9ce14b5a5 100644 --- a/build.rs +++ b/build.rs @@ -12,8 +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" => continue, - "all" => continue, + "default" | "unix" | "generic" => continue, _ => {}, } crates.push(krate.to_string()); diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index f1c4e97de..fa55bafbe 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -15,9 +15,8 @@ extern crate libc; #[macro_use] extern crate uucore; -use std::ffi::CString; use std::fs; -use std::io::{Error, Write}; +use std::io::Write; use std::path::{Path, PathBuf}; use uucore::fs::UUPathExt; @@ -137,6 +136,9 @@ fn mkdir(path: &Path, mode: u16, verbose: bool) -> i32 { #[cfg(unix)] fn chmod(path: &Path, mode: u16) -> i32 { + use std::ffi::CString; + use std::io::Error; + let directory = CString::new(path.as_os_str().to_str().unwrap()).unwrap_or_else(|e| crash!(1, "{}", e)); let mode = mode as libc::mode_t; diff --git a/src/test/test.rs b/src/test/test.rs index ee0303ea2..9cd3a589d 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -12,7 +12,7 @@ extern crate libc; use std::collections::HashMap; -use std::ffi::{CString, OsString}; +use std::ffi::OsString; use std::env::{args_os}; use std::str::{from_utf8}; @@ -328,6 +328,8 @@ enum PathCondition { fn path(path: &[u8], cond: PathCondition) -> bool { use libc::{stat, lstat, S_IFMT, S_IFLNK, S_IFBLK, S_IFCHR, S_IFDIR, S_IFREG}; use libc::{S_IFIFO, mode_t}; + use std::ffi::CString; + static S_ISUID: mode_t = 0o4000; static S_ISGID: mode_t = 0o2000; static S_IFSOCK: mode_t = 0o140000; diff --git a/src/uucore/lib.rs b/src/uucore/lib.rs index adbe7fe80..17fd1071f 100644 --- a/src/uucore/lib.rs +++ b/src/uucore/lib.rs @@ -4,10 +4,11 @@ extern crate time; #[macro_use] mod macros; -pub mod c_types; pub mod fs; pub mod parse_time; -pub mod process; + +#[cfg(unix)] pub mod c_types; +#[cfg(unix)] pub mod process; #[cfg(unix)] pub mod signals; #[cfg(unix)] pub mod utmpx; diff --git a/src/whoami/platform/windows.rs b/src/whoami/platform/windows.rs index 0a8611952..eda1753bb 100644 --- a/src/whoami/platform/windows.rs +++ b/src/whoami/platform/windows.rs @@ -9,8 +9,6 @@ extern crate winapi; extern crate advapi32; - -#[macro_use] extern crate uucore; use std::ffi::OsString;