~ruther/avr-device

a1f82aa7e1db2a9d25a7b229aed1dc75471e73a5 — Rahix 4 years ago ca6cad6
Improve error message when no device is selected

Introduce a new `device-selected` feature to simpilify the logic for
showing an error when no device was selected.
2 files changed, 42 insertions(+), 36 deletions(-)

M Cargo.toml
M src/lib.rs
M Cargo.toml => Cargo.toml +17 -16
@@ 21,22 21,23 @@ include = [
all-features = true

[features]
atmega1280 = []
atmega168 = []
atmega2560 = []
atmega8 = []
atmega328p = []
atmega328pb = []
atmega4809 = []
atmega48p = []
atmega32u4 = []
atmega64 = []
atmega644 = []
attiny84 = []
attiny841 = []
attiny85 = []
attiny861 = []
attiny88 = []
device-selected = []
atmega1280 = ["device-selected"]
atmega168 = ["device-selected"]
atmega2560 = ["device-selected"]
atmega8 = ["device-selected"]
atmega328p = ["device-selected"]
atmega328pb = ["device-selected"]
atmega4809 = ["device-selected"]
atmega48p = ["device-selected"]
atmega32u4 = ["device-selected"]
atmega64 = ["device-selected"]
atmega644 = ["device-selected"]
attiny84 = ["device-selected"]
attiny841 = ["device-selected"]
attiny85 = ["device-selected"]
attiny861 = ["device-selected"]
attiny88 = ["device-selected"]
rt = ["avr-device-macros"]

[dependencies]

M src/lib.rs => src/lib.rs +25 -20
@@ 80,6 80,31 @@ pub use avr_device_macros::interrupt;
#[cfg(feature = "rt")]
pub use avr_device_macros::entry;

#[cfg(not(feature = "device-selected"))]
compile_error!(
    "This crate requires you to specify your target chip as a feature.

    Please select one of the following:

    * atmega1280
    * atmega168
    * atmega2560
    * atmega328p
    * atmega328pb
    * atmega32u4
    * atmega4809
    * atmega48p
    * atmega64
    * atmega644
    * atmega8
    * attiny84
    * attiny841
    * attiny85
    * attiny861
    * attiny88
    "
);

#[allow(non_camel_case_types, unused_attributes, unreachable_patterns)]
mod devices;



@@ 115,23 140,3 @@ pub use crate::devices::attiny85;
pub use crate::devices::attiny861;
#[cfg(feature = "attiny88")]
pub use crate::devices::attiny88;

#[cfg(not(any(
    feature = "atmega1280",
    feature = "atmega168",
    feature = "atmega2560",
    feature = "atmega8",
    feature = "atmega328p",
    feature = "atmega328pb",
    feature = "atmega32u4",
    feature = "atmega4809",
    feature = "atmega48p",
    feature = "atmega64",
    feature = "atmega644",
    feature = "attiny84",
    feature = "attiny841",
    feature = "attiny85",
    feature = "attiny861",
    feature = "attiny88",
)))]
compile_error!("You need to select at least one chip as a feature!");

Do not follow this link