mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 04:40:52 +00:00

* Define configs in YAML files * Fix error message string * Cleanup * Fix rebase * Experiment: Value is String * More i64 -> i128 * More i64 -> i128 * yml -> yaml * Clippy * Expect * Test more * Explicit `trunc` * fmt * Typo * `is_tooling` -> `ignore_feature_gates` * Fix * Briefly explain the config format * Evaluate conditions in order, first match wins * Address review * Move evalexpr I128 support into separate file
42 lines
1.5 KiB
Rust
42 lines
1.5 KiB
Rust
use std::error::Error as StdError;
|
|
|
|
use esp_config::{Value, generate_config_from_yaml_definition};
|
|
use esp_metadata::{Chip, Config};
|
|
|
|
fn main() -> Result<(), Box<dyn StdError>> {
|
|
// Load the configuration file for the configured device:
|
|
let chip = Chip::from_cargo_feature()?;
|
|
let config = Config::for_chip(&chip);
|
|
|
|
// Define all necessary configuration symbols for the configured device:
|
|
config.define_symbols();
|
|
|
|
// emit config
|
|
println!("cargo:rerun-if-changed=./esp_config.yml");
|
|
let cfg_yaml = std::fs::read_to_string("./esp_config.yml")
|
|
.expect("Failed to read esp_config.yml for esp-hal-embassy");
|
|
let crate_config =
|
|
generate_config_from_yaml_definition(&cfg_yaml, true, true, Some(config.clone())).unwrap();
|
|
|
|
println!("cargo:rustc-check-cfg=cfg(integrated_timers)");
|
|
println!("cargo:rustc-check-cfg=cfg(single_queue)");
|
|
println!("cargo:rustc-check-cfg=cfg(generic_timers)");
|
|
|
|
match &crate_config["ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE"] {
|
|
Value::String(s) if s.as_str() == "single-integrated" => {
|
|
println!("cargo:rustc-cfg=integrated_timers");
|
|
println!("cargo:rustc-cfg=single_queue");
|
|
}
|
|
Value::String(s) if s.as_str() == "multiple-integrated" => {
|
|
println!("cargo:rustc-cfg=integrated_timers");
|
|
}
|
|
Value::String(s) if s.as_str() == "generic" => {
|
|
println!("cargo:rustc-cfg=generic_timers");
|
|
println!("cargo:rustc-cfg=single_queue");
|
|
}
|
|
_ => unreachable!(),
|
|
}
|
|
|
|
Ok(())
|
|
}
|