-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.rs
40 lines (33 loc) · 1.37 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fn main() {
#[cfg(feature = "stm32f1xx-hal")]
println!("cargo:rustc-link-search=memory.x");
let hse = std::env::var("STM32_ETH_EXAMPLE_HSE");
if let Ok(hse) = hse {
if hse == "bypass" {
println!("cargo:rustc-cfg=hse=\"bypass\"")
} else if hse == "oscillator" {
println!("cargo:rustc-cfg=hse=\"oscillator\"");
} else if hse != "off" {
panic!("Invalid STM32_ETH_EXAMPLE_HSE value. Allowed values: bypass, oscillator, off")
}
}
let example_pins = std::env::var("STM32_ETH_EXAMPLE_PINS");
if let Ok(pins) = example_pins {
if pins == "nucleo" {
println!("cargo:rustc-cfg=pins=\"nucleo\"")
} else if pins != "default" {
panic!("Invalid STM32_ETH_EXAMPLE_PINS value. Allowed values: nucleo, default");
}
}
let pps_pin = std::env::var("STM32_ETH_EXAMPLE_PPS_PIN");
if let Ok(pps_pin) = pps_pin {
if pps_pin == "alternate" {
println!("cargo:rustc-cfg=pps=\"alternate\"")
} else if pps_pin != "default" {
panic!("Invalid STM32_ETH_EXAMPLE_PPS_PIN value. Allowed values: alternate, default");
}
}
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_PPS_PIN");
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_HSE");
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_PINS");
}