macro_rules! include_proto {
( $( $list:literal ),* $(,)? ) => {
mutually_exclusive_features!($($list),*);
include_proto!(@with_default $($list),*);
};
(@with_default $default:literal, $( $other:literal ),* $(,)? ) => {
#[cfg(not(any(
feature = $default,
$(feature = $other),*
)))]
include!(concat!(env!("OUT_DIR"), "/esphome_proto_", $default, ".rs")); #[cfg(all(feature = $default, not(any($(feature = $other),*))))]
include!(concat!(env!("OUT_DIR"), "/esphome_proto_", $default, ".rs"));
include_proto!(@with_version $($other),*; $default);
};
(@with_version $version:literal, $( $other:literal ),* $(,)? ; $( $other_seen:literal ),* $(,)?) => {
#[cfg(all(feature = $version, not(any( $(feature = $other),* , $(feature = $other_seen),* ))))]
include!(concat!(env!("OUT_DIR"), "/esphome_proto_", $version, ".rs"));
include_proto!(@with_version $($other),*; $version, $($other_seen),*);
};
(@with_version $version:literal; $( $other_seen:literal ),* $(,)?) => {
#[cfg(all(feature = $version, not(any($(feature = $other_seen),*))))]
include!(concat!(env!("OUT_DIR"), "/esphome_proto_", $version, ".rs"));
};
}
macro_rules! mutually_exclusive_features {
( $( $list:literal ),* $(,)? ) => {
mutually_exclusive_features!(@with_version $($list),* ;);
};
(@with_version $version:literal, $( $other:literal ),* $(,)? ; $( $other_seen:literal ),* $(,)?) => {
#[cfg(all(
feature = $version,
any($(feature = $other),* , $(feature = $other_seen),*)
))]
compile_error!(concat!("Cannot combine multiple API version features with ", $version, ". Please enable only one of them."));
mutually_exclusive_features!(@with_version $($other),*; $version, $($other_seen),*);
};
(@with_version $version:literal; $( $other_seen:literal ),* $(,)?) => {
#[cfg(all(
feature = $version,
any($(feature = $other_seen),*)
))]
compile_error!(concat!("Cannot combine multiple API version features with ", $version, ". Please enable only one of them."));
};
}