diff --git a/Cargo.toml b/Cargo.toml index 9d269f2..3b9bd23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,5 +32,8 @@ avr-std-stub = { version = "1.0", optional = true } const_env--value = "0.1" target-cpu-macro = "0.1" +[build-dependencies] +avr-mcu = "0.3" + [package.metadata.docs.rs] all-features = true # we specifically want to enable 'all-mcus' for documentation diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..92d4f6d --- /dev/null +++ b/build.rs @@ -0,0 +1,13 @@ +const DEFAULT_MCU_FOR_NON_AVR_DOCS: &'static str = "atmega328"; + +fn main() { + let current_mcu = if avr_mcu::current::is_compiling_for_avr() { + avr_mcu::current::mcu() + .expect("no target cpu specified") + } else { + avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS) + }; + let current_mcu_name = current_mcu.device.name.clone().to_lowercase(); + + println!("cargo:rustc-cfg=avr_mcu_{}", ¤t_mcu_name); +} diff --git a/core_generator/src/main.rs b/core_generator/src/main.rs index 59af759..f30a3d6 100644 --- a/core_generator/src/main.rs +++ b/core_generator/src/main.rs @@ -137,14 +137,6 @@ fn main() { fs::create_dir_all(&cores_path()).expect("could not create cores directory"); } - let current_mcu = if avr_mcu::current::is_compiling_for_avr() { - avr_mcu::current::mcu() - .expect("no target cpu specified") - } else { - avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS) - }; - let current_mcu_name = current_mcu.device.name.clone(); - let microcontrollers = avr_mcu::microcontrollers(); let (count_total, mut cores_successful, mut cores_failed) = (microcontrollers.len(), Vec::new(), Vec::new()); @@ -184,9 +176,6 @@ fn main() { println!("statistics:"); println!(" total successful: {}", cores_successful.len()); println!(" total failed: {}", cores_failed.len()); - - - println!("cargo:rustc-cfg=avr_mcu_{}", normalize_device_name(¤t_mcu_name)); } fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {