Merge branch 'fixup-bitrot'

This commit is contained in:
Dylan McKay 2020-07-25 01:57:09 +12:00
commit 04861a0578
4 changed files with 19 additions and 7 deletions

View File

@ -19,6 +19,10 @@ build = "core_generator/build.rs"
keywords = ["avr", "arduino", "uno"]
[build-dependencies]
avr-mcu = "0.2"
[dependencies]
target-cpu-macro = "0.1"
[build-dependencies]
avr-mcu = "0.3"
target-cpu-fetch = "0.1"

View File

@ -23,7 +23,11 @@ fn cores_path() -> PathBuf {
}
fn core_module_name(mcu: &Mcu) -> String {
mcu.device.name.to_lowercase().to_owned()
normalize_device_name(&mcu.device.name)
}
fn normalize_device_name(device_name: &str) -> String {
device_name.to_lowercase().to_owned()
}
fn main() {
@ -31,15 +35,18 @@ fn main() {
fs::create_dir_all(&cores_path()).expect("could not create cores directory");
}
let current_mcu = if cfg!(arch = "avr") {
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();
generate_config_module().unwrap();
generate_cores(&[current_mcu]).unwrap();
println!("cargo:rustc-cfg=avr_mcu_{}", normalize_device_name(&current_mcu_name));
}
fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {
@ -82,7 +89,7 @@ fn generate_cores_mod_rs(mcus: &[Mcu]) -> Result<(), io::Error> {
writeln!(w, "/// The {}.", mcu.device.name)?;
writeln!(w, "pub mod {};", module_name)?;
writeln!(w, "#[cfg(all(target_arch = \"avr\", target_cpu = \"{}\"))]", module_name)?;
writeln!(w, "#[cfg(avr_mcu_{})]", module_name)?;
writeln!(w, "pub use self::{} as current;", module_name)?;
}
writeln!(w)

View File

@ -1,8 +1,8 @@
#![no_std]
#![no_main]
extern crate arduino;
use arduino::cores::current;
extern crate ruduino;
use ruduino::cores::current;
// Some devices may have multiple SPI modules.
// The ATmega328p only has one.

View File

@ -5,6 +5,7 @@
#![feature(associated_type_defaults)]
#![feature(lang_items)]
#![feature(unwind_attributes)]
#![feature(proc_macro_hygiene)]
#![no_std]