Skip to content

Commit ba6dec1

Browse files
committed
Move the target-cpu feature enable logic back into a build script
It didn't do anything in the core generator.
1 parent 5557377 commit ba6dec1

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ avr-std-stub = { version = "1.0", optional = true }
3232
const_env--value = "0.1"
3333
target-cpu-macro = "0.1"
3434

35+
[build-dependencies]
36+
avr-mcu = "0.3"
37+
3538
[package.metadata.docs.rs]
3639
all-features = true # we specifically want to enable 'all-mcus' for documentation

build.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const DEFAULT_MCU_FOR_NON_AVR_DOCS: &'static str = "atmega328";
2+
3+
fn main() {
4+
let current_mcu = if avr_mcu::current::is_compiling_for_avr() {
5+
avr_mcu::current::mcu()
6+
.expect("no target cpu specified")
7+
} else {
8+
avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS)
9+
};
10+
let current_mcu_name = current_mcu.device.name.clone().to_lowercase();
11+
12+
println!("cargo:rustc-cfg=avr_mcu_{}", &current_mcu_name);
13+
}

core_generator/src/main.rs

-11
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,6 @@ fn main() {
137137
fs::create_dir_all(&cores_path()).expect("could not create cores directory");
138138
}
139139

140-
let current_mcu = if avr_mcu::current::is_compiling_for_avr() {
141-
avr_mcu::current::mcu()
142-
.expect("no target cpu specified")
143-
} else {
144-
avr_mcu::microcontroller(DEFAULT_MCU_FOR_NON_AVR_DOCS)
145-
};
146-
let current_mcu_name = current_mcu.device.name.clone();
147-
148140
let microcontrollers = avr_mcu::microcontrollers();
149141
let (count_total, mut cores_successful, mut cores_failed) = (microcontrollers.len(), Vec::new(), Vec::new());
150142

@@ -184,9 +176,6 @@ fn main() {
184176
println!("statistics:");
185177
println!(" total successful: {}", cores_successful.len());
186178
println!(" total failed: {}", cores_failed.len());
187-
188-
189-
println!("cargo:rustc-cfg=avr_mcu_{}", normalize_device_name(&current_mcu_name));
190179
}
191180

192181
fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {

0 commit comments

Comments
 (0)