-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
34 lines (31 loc) · 1.07 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
#[toml_cfg::toml_config]
pub struct Config {
#[default("localhost")]
mqtt_host: &'static str,
#[default("")]
mqtt_user: &'static str,
#[default("")]
mqtt_pass: &'static str,
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}
fn main() {
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
panic!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
}
// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
panic!("You need to set the Wi-Fi credentials in `cfg.toml`!");
}
if app_config.mqtt_host == "yourpc.local"
|| app_config.mqtt_user == "horse"
|| app_config.mqtt_pass == "CorrectHorseBatteryStaple"
{
panic!("You need to set the MQTT credentials in `cfg.toml`!");
}
embuild::espidf::sysenv::output();
}