Skip to content

Add cargo features #1197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,55 @@ exclude = [
libc = { version = "0.2.60", features = [ "extra_traits" ] }
bitflags = "1.1"
cfg-if = "0.1.10"
void = "1.0.2"
void = { version = "1.0.2", optional = true }

[features]
default = [
"inotify", "epoll", "socket", "ifaddrs", "ptrace", "pthread", "memfd",
"quota", "select", "reboot", "signal", "signalfd", "sendfile", "aio", "wait",
"mount", "ucontext", "utsname", "uio", "fcntl", "unistd", "pty", "features",
"dir", "env", "kmod", "mqueue", "net", "sched", "event", "eventfd", "ioctl",
"mman", "stat", "statfs", "statvfs", "termios", "time", "poll"
]
inotify = []
epoll = []
socket = ["ifaddrs", "uio", "time"]
ifaddrs = ["net"]
ptrace = []
pthread = []
memfd = []
quota = []
select = []
reboot = ["void"]
signal = []
signalfd = ["signal"]
sendfile = []
aio = ["signal"]
wait = ["signal"]
mount = []
ucontext = []
utsname = []
uio = ["unistd"]
fcntl = ["uio", "stat"]
unistd = ["void", "fcntl"]
pty = ["fcntl", "unistd"]
features = ["utsname"]
dir = []
env = []
kmod = []
mqueue = []
net = []
sched = []
event = []
eventfd = []
ioctl = []
mman = []
stat = ["time"]
statfs = []
statvfs = []
termios = []
time = []
poll = []

[target.'cfg(target_os = "dragonfly")'.build-dependencies]
cc = "1"
Expand Down
39 changes: 27 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![cfg_attr(test, deny(warnings))]
#![recursion_limit = "500"]
#![deny(unused)]
#![allow(unused_macros)]
#![deny(unstable_features)]
#![deny(missing_copy_implementations)]
#![deny(missing_debug_implementations)]
Expand All @@ -20,6 +21,7 @@
extern crate bitflags;
#[macro_use]
extern crate cfg_if;
#[cfg(any(feature = "unistd", feature = "reboot"))]
extern crate void;

// Re-exported external crates
Expand All @@ -29,47 +31,60 @@ pub extern crate libc;
#[macro_use] mod macros;

// Public crates
#[cfg(feature = "dir")]
pub mod dir;
#[cfg(feature = "env")]
pub mod env;
pub mod errno;
#[deny(missing_docs)]
#[cfg(feature = "features")]
pub mod features;
#[cfg(feature = "fcntl")]
pub mod fcntl;
#[deny(missing_docs)]
#[cfg(any(target_os = "android",
#[cfg(all(feature = "ifaddrs",
any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
target_os = "openbsd")))]
pub mod ifaddrs;
#[cfg(any(target_os = "android",
target_os = "linux"))]
#[cfg(all(feature = "kmod",
any(target_os = "android",
target_os = "linux")))]
pub mod kmod;
#[cfg(any(target_os = "android",
target_os = "linux"))]
#[cfg(all(feature = "mount",
any(target_os = "android",
target_os = "linux")))]
pub mod mount;
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "fushsia",
target_os = "linux",
target_os = "netbsd"))]
#[cfg(all(feature = "mqueue",
any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "fushsia",
target_os = "linux",
target_os = "netbsd")))]
pub mod mqueue;
#[deny(missing_docs)]
#[cfg(feature = "net")]
pub mod net;
#[deny(missing_docs)]
#[cfg(feature = "poll")]
pub mod poll;
#[deny(missing_docs)]
#[cfg(feature = "pty")]
pub mod pty;
#[cfg(feature = "sched")]
pub mod sched;
pub mod sys;
// This can be implemented for other platforms as soon as libc
// provides bindings for them.
#[cfg(all(target_os = "linux",
#[cfg(all(target_os = "linux", feature = "ucontext",
any(target_arch = "x86", target_arch = "x86_64")))]
pub mod ucontext;
#[cfg(feature = "unistd")]
pub mod unistd;

/*
Expand Down
87 changes: 52 additions & 35 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
@@ -1,100 +1,117 @@
#[cfg(any(target_os = "dragonfly",
#[cfg(all(feature = "aio",
any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd"))]
target_os = "netbsd")))]
pub mod aio;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(all(feature = "epoll", any(target_os = "android", target_os = "linux")))]
pub mod epoll;

#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
#[cfg(all(feature = "event",
any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd")))]
pub mod event;

#[cfg(target_os = "linux")]
#[cfg(all(feature = "eventfd", target_os = "linux"))]
pub mod eventfd;

#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
#[cfg(all(feature = "ioctl",
any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd")))]
#[macro_use]
pub mod ioctl;

#[cfg(target_os = "linux")]
#[cfg(all(feature = "memfd", target_os = "linux"))]
pub mod memfd;

#[cfg(feature = "mman")]
pub mod mman;

#[cfg(feature = "pthread")]
pub mod pthread;

#[cfg(any(target_os = "android",
#[cfg(all(feature = "ptrace",
any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
target_os = "openbsd")))]
pub mod ptrace;

#[cfg(target_os = "linux")]
#[cfg(all(feature = "quota", target_os = "linux"))]
pub mod quota;

#[cfg(any(target_os = "linux"))]
#[cfg(all(feature = "reboot", target_os = "linux"))]
pub mod reboot;

#[cfg(feature = "select")]
pub mod select;

#[cfg(any(target_os = "android",
#[cfg(all(feature = "sendfile",
any(target_os = "android",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos"))]
target_os = "macos")))]
pub mod sendfile;

#[cfg(feature = "signal")]
pub mod signal;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(all(feature = "signalfd", any(target_os = "android", target_os = "linux")))]
pub mod signalfd;

#[cfg(feature = "socket")]
pub mod socket;

#[cfg(feature = "stat")]
pub mod stat;

#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "openbsd"
))]
#[cfg(all(feature = "statfs",
any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "openbsd")))]
pub mod statfs;

#[cfg(feature = "statvfs")]
pub mod statvfs;

#[cfg(any(target_os = "android", target_os = "linux"))]
pub mod sysinfo;

#[cfg(feature = "termios")]
pub mod termios;

#[cfg(feature = "time")]
pub mod time;

#[cfg(feature = "uio")]
pub mod uio;

#[cfg(feature = "utsname")]
pub mod utsname;

#[cfg(feature = "wait")]
pub mod wait;

#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(all(feature = "inotify", any(target_os = "android", target_os = "linux")))]
pub mod inotify;