This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.rs
50 lines (45 loc) · 1.69 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
41
42
43
44
45
46
47
48
49
50
fn main() {
// Ensure that only a single chip is specified
let chip_features = [
cfg!(feature = "esp32"),
cfg!(feature = "esp32c2"),
cfg!(feature = "esp32c3"),
cfg!(feature = "esp32c6"),
cfg!(feature = "esp32h2"),
cfg!(feature = "esp32p4"),
cfg!(feature = "esp32s2"),
cfg!(feature = "esp32s3"),
];
match chip_features.iter().filter(|&&f| f).count() {
1 => {}
n => panic!("Exactly 1 chip must be enabled via its Cargo feature, {n} provided"),
};
// Ensure that only a single communication method is specified
let method_features = [cfg!(feature = "uart"), cfg!(feature = "jtag-serial")];
match method_features.iter().filter(|&&f| f).count() {
1 => {}
n => panic!(
"Exactly 1 communication method must be enabled via its Cargo feature, {n} provided"
),
}
// Ensure that, if the `jtag-serial` communication method feature is enabled,
// either the `esp32c3`, `esp32c6`, `esp32h2`, or `esp32s3` chip feature is
// enabled.
if cfg!(feature = "jtag-serial")
&& !(cfg!(feature = "esp32c3")
|| cfg!(feature = "esp32c6")
|| cfg!(feature = "esp32h2")
|| cfg!(feature = "esp32p4")
|| cfg!(feature = "esp32s3"))
{
panic!(
"The `jtag-serial` feature is only supported by the ESP32-C3, ESP32-C6, ESP32-H2, and ESP32-S3"
);
}
// Ensure that, if the `colors` is used with `log`.`
if cfg!(feature = "colors") && !cfg!(feature = "log") {
println!(
"cargo:warning=The `colors` feature is only effective when using the `log` feature"
);
}
}