-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
40 lines (37 loc) · 1.13 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fn main() {
// Assert that only one feature flag have been enabled
// for the underlying I/O framework
assert_io_framework_mutual_exclusivity();
}
/// Check the feature flags for the underlying I/O frameworks.
///
/// # Panics
/// If none or more than one feature flag have been enabled for the underlying
/// I/O framework.
fn assert_io_framework_mutual_exclusivity() {
#[allow(unused_mut)]
let mut found: u8 = 0;
cfg_if::cfg_if! {
if #[cfg(feature="netmap")] {
found += 1;
}
};
cfg_if::cfg_if! {
if #[cfg(feature="libpcap")] {
found += 1;
}
};
cfg_if::cfg_if! {
if #[cfg(feature="xdp")] {
found += 1;
}
};
cfg_if::cfg_if! {
if #[cfg(feature="tpacket_v3")] {
found += 1;
}
};
assert!(found >= 1, "Error: no I/O framework found. Enable one of the following features: netmap, libpcap, xdp, tpacket_v3.");
assert!(found <= 1, "Error: more than one I/O framework found. Enable only one of the following features: netmap, libpcap, xdp, tpacket_v3.");
assert_eq!(found, 1);
}