From 8a320ca9da61956b55e3de81212dad5deace0084 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Mon, 5 Nov 2018 22:23:57 +1300 Subject: [PATCH] Assume atmega328 when building documentation This allows 'cargo doc', and notably, docs.rs to work. --- core_generator/build.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core_generator/build.rs b/core_generator/build.rs index cd2bf15..f6840ad 100644 --- a/core_generator/build.rs +++ b/core_generator/build.rs @@ -8,6 +8,10 @@ use std::io; use std::io::prelude::*; 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 { 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"); } - let current_mcu = avr_mcu::current::mcu() - .expect("no target cpu specified"); + let current_mcu = if cfg!(arch = "avr") { + avr_mcu::current::mcu() + .expect("no target cpu specified") + } else { + avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS) + }; + generate_config_module().unwrap(); generate_cores(&[current_mcu]).unwrap(); }