From a6a28957b3b470dc1e782c852b047bffa0bc5e54 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 24 Mar 2021 00:49:08 +0100 Subject: [PATCH] Fix feature-related compilation issues. --- Cargo.toml | 8 ++++---- src/lib.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4ea3a94..e615f88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,12 +32,12 @@ url = "1.0" std = ["managed/std"] alloc = ["managed/alloc"] verbose = [] -ethernet = [] -"phy-raw_socket" = ["std", "libc"] -"phy-tap_interface" = ["std", "libc"] +ethernet = ["socket"] +"phy-raw_socket" = ["std", "libc", "ethernet"] +"phy-tap_interface" = ["std", "libc", "ethernet"] "proto-ipv4" = [] "proto-igmp" = ["proto-ipv4"] -"proto-dhcpv4" = ["proto-ipv4", "socket-raw"] +"proto-dhcpv4" = ["proto-ipv4", "socket-raw", "ethernet"] "proto-ipv6" = [] "socket" = [] "socket-raw" = ["socket"] diff --git a/src/lib.rs b/src/lib.rs index 8f28466..624b6b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,6 +83,20 @@ compile_error!("at least one socket needs to be enabled"); */ #[cfg(feature = "alloc")] extern crate alloc; +#[cfg(not(any(feature = "proto-ipv4", feature = "proto-ipv6")))] +compile_error!("You must enable at least one of the following features: proto-ipv4, proto-ipv6"); + +#[cfg(all( + feature = "socket", + not(any( + feature = "socket-raw", + feature = "socket-udp", + feature = "socket-tcp", + feature = "socket-icmp", + )) +))] +compile_error!("If you enable the socket feature, you must enable at least one of the following features: socket-raw, socket-udp, socket-tcp, socket-icmp"); + use core::fmt; #[macro_use]