Assume atmega328 when building documentation

This allows 'cargo doc', and notably, docs.rs to work.
This commit is contained in:
Dylan McKay 2018-11-05 22:23:57 +13:00
parent f94b23ed1d
commit 8a320ca9da
1 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,10 @@ use std::io;
use std::io::prelude::*; use std::io::prelude::*;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
/// The MCU that will be assumed when running 'cargo doc' targeting
/// archicectures that are not AVR.
const DEFAULT_MCU_FOR_NON_AVR_DOCS: &'static str = "atmega328";
fn src_path() -> PathBuf { fn src_path() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("src") Path::new(env!("CARGO_MANIFEST_DIR")).join("src")
} }
@ -25,8 +29,13 @@ fn main() {
fs::create_dir_all(&cores_path()).expect("could not create cores directory"); fs::create_dir_all(&cores_path()).expect("could not create cores directory");
} }
let current_mcu = avr_mcu::current::mcu() let current_mcu = if cfg!(arch = "avr") {
.expect("no target cpu specified"); avr_mcu::current::mcu()
.expect("no target cpu specified")
} else {
avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS)
};
generate_config_module().unwrap(); generate_config_module().unwrap();
generate_cores(&[current_mcu]).unwrap(); generate_cores(&[current_mcu]).unwrap();
} }