-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
28 lines (23 loc) · 947 Bytes
/
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
use std::error::Error;
#[toml_cfg::toml_config]
pub struct Config {
#[default("")]
wifi_ssid: &'static str,
#[default("")]
wifi_psk: &'static str,
}
fn main() -> Result<(), Box<dyn Error>> {
// Check if the `cfg.toml` file exists and has been filled out.
if !std::path::Path::new("cfg.toml").exists() {
return Err("You need to create a `cfg.toml` file with your Wi-Fi credentials! Start from `cfg.toml.template`.".into());
}
// The constant `CONFIG` is auto-generated by `toml_config`.
let app_config = CONFIG;
if app_config.wifi_ssid == "SET_ME" || app_config.wifi_psk == "SET_ME" {
return Err("You need to set the Wi-Fi credentials in `cfg.toml`!".into());
}
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
embuild::build::CfgArgs::output_propagated("ESP_IDF")?;
embuild::build::LinkArgs::output_propagated("ESP_IDF")?;
Ok(())
}