Move the target-cpu feature enable logic back into a build script

It didn't do anything in the core generator.
This commit is contained in:
Dylan McKay 2021-01-29 21:46:01 +13:00
parent 5557377087
commit ba6dec1b60
3 changed files with 16 additions and 11 deletions

View File

@ -32,5 +32,8 @@ avr-std-stub = { version = "1.0", optional = true }
const_env--value = "0.1" const_env--value = "0.1"
target-cpu-macro = "0.1" target-cpu-macro = "0.1"
[build-dependencies]
avr-mcu = "0.3"
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true # we specifically want to enable 'all-mcus' for documentation all-features = true # we specifically want to enable 'all-mcus' for documentation

13
build.rs Normal file
View File

@ -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_{}", &current_mcu_name);
}

View File

@ -137,14 +137,6 @@ 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 = 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 microcontrollers = avr_mcu::microcontrollers();
let (count_total, mut cores_successful, mut cores_failed) = (microcontrollers.len(), Vec::new(), Vec::new()); let (count_total, mut cores_successful, mut cores_failed) = (microcontrollers.len(), Vec::new(), Vec::new());
@ -184,9 +176,6 @@ fn main() {
println!("statistics:"); println!("statistics:");
println!(" total successful: {}", cores_successful.len()); println!(" total successful: {}", cores_successful.len());
println!(" total failed: {}", cores_failed.len()); println!(" total failed: {}", cores_failed.len());
println!("cargo:rustc-cfg=avr_mcu_{}", normalize_device_name(&current_mcu_name));
} }
fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> { fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {