From 190a3ec8f13c8ab3d4c4e3028bd908a58dd43afc Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sat, 23 Sep 2017 17:09:48 +1200 Subject: [PATCH] Add a cores::current module for getting the current microcontroller --- build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 9f1ea92..d114de1 100644 --- a/build.rs +++ b/build.rs @@ -44,8 +44,12 @@ fn generate_cores_mod_rs(mcus: &[Mcu]) -> Result<(), io::Error> { writeln!(w, "//! Cores")?; writeln!(w)?; for mcu in mcus { + let module_name = core_module_name(mcu); writeln!(w, "/// The {}.", mcu.device.name)?; - writeln!(w, "pub mod {};", core_module_name(mcu))?; + writeln!(w, "pub mod {};", module_name)?; + + writeln!(w, "#[cfg(all(target_arch = \"avr\", target_cpu = \"{}\"))]", module_name)?; + writeln!(w, "pub use self::{} as current;", module_name)?; } writeln!(w) }