From cf47de0f63fe369fe97483cc7b576e287fa4d7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 20 Dec 2024 16:19:48 +0100 Subject: [PATCH] Change separator to _CONFIG_ --- esp-config/CHANGELOG.md | 2 +- esp-config/src/generate.rs | 61 +++++++++++++++++--------------- esp-hal-embassy/CHANGELOG.md | 2 +- esp-hal-embassy/MIGRATING-0.5.md | 6 ++-- esp-hal/CHANGELOG.md | 2 +- esp-hal/MIGRATING-0.22.md | 6 ++-- esp-ieee802154/CHANGELOG.md | 2 +- esp-ieee802154/MIGRATING-0.4.md | 6 ++-- esp-ieee802154/src/lib.rs | 2 +- esp-wifi/CHANGELOG.md | 2 +- esp-wifi/MIGRATING-0.11.md | 6 ++-- esp-wifi/src/lib.rs | 45 ++++++++++++----------- examples/.cargo/config.toml | 2 +- 13 files changed, 75 insertions(+), 69 deletions(-) diff --git a/esp-config/CHANGELOG.md b/esp-config/CHANGELOG.md index c2f39d7247..140d4472f7 100644 --- a/esp-config/CHANGELOG.md +++ b/esp-config/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Crate prefixes and configuration keys are now separated by two underscores (`__`) (#2848) +- Crate prefixes and configuration keys are now separated by `_CONFIG_` (#2848) ### Removed diff --git a/esp-config/src/generate.rs b/esp-config/src/generate.rs index 1e97753b49..3a9f671152 100644 --- a/esp-config/src/generate.rs +++ b/esp-config/src/generate.rs @@ -264,7 +264,7 @@ pub fn generate_config( let mut selected_config = String::from(SELECTED_TABLE_HEADER); // Ensure that the prefix is `SCREAMING_SNAKE_CASE`: - let prefix = format!("{}__", screaming_snake_case(crate_name)); + let prefix = format!("{}_CONFIG_", screaming_snake_case(crate_name)); // Build a lookup table for any provided validators; we must prefix the // name of the config and transform it to SCREAMING_SNAKE_CASE so that @@ -464,10 +464,10 @@ mod test { fn env_override() { temp_env::with_vars( [ - ("ESP_TEST__NUMBER", Some("0xaa")), - ("ESP_TEST__NUMBER_SIGNED", Some("-999")), - ("ESP_TEST__STRING", Some("Hello world!")), - ("ESP_TEST__BOOL", Some("true")), + ("ESP_TEST_CONFIG_NUMBER", Some("0xaa")), + ("ESP_TEST_CONFIG_NUMBER_SIGNED", Some("-999")), + ("ESP_TEST_CONFIG_STRING", Some("Hello world!")), + ("ESP_TEST_CONFIG_BOOL", Some("true")), ], || { let configs = generate_config( @@ -491,28 +491,28 @@ mod test { // some values have changed assert_eq!( - match configs.get("ESP_TEST__NUMBER").unwrap() { + match configs.get("ESP_TEST_CONFIG_NUMBER").unwrap() { Value::Integer(num) => *num, _ => unreachable!(), }, 0xaa ); assert_eq!( - match configs.get("ESP_TEST__NUMBER_SIGNED").unwrap() { + match configs.get("ESP_TEST_CONFIG_NUMBER_SIGNED").unwrap() { Value::Integer(num) => *num, _ => unreachable!(), }, -999 ); assert_eq!( - match configs.get("ESP_TEST__STRING").unwrap() { + match configs.get("ESP_TEST_CONFIG_STRING").unwrap() { Value::String(val) => val, _ => unreachable!(), }, "Hello world!" ); assert_eq!( - match configs.get("ESP_TEST__BOOL").unwrap() { + match configs.get("ESP_TEST_CONFIG_BOOL").unwrap() { Value::Bool(val) => *val, _ => unreachable!(), }, @@ -521,21 +521,21 @@ mod test { // the rest are the defaults assert_eq!( - match configs.get("ESP_TEST__NUMBER_DEFAULT").unwrap() { + match configs.get("ESP_TEST_CONFIG_NUMBER_DEFAULT").unwrap() { Value::Integer(num) => *num, _ => unreachable!(), }, 999 ); assert_eq!( - match configs.get("ESP_TEST__STRING_DEFAULT").unwrap() { + match configs.get("ESP_TEST_CONFIG_STRING_DEFAULT").unwrap() { Value::String(val) => val, _ => unreachable!(), }, "Demo" ); assert_eq!( - match configs.get("ESP_TEST__BOOL_DEFAULT").unwrap() { + match configs.get("ESP_TEST_CONFIG_BOOL_DEFAULT").unwrap() { Value::Bool(val) => *val, _ => unreachable!(), }, @@ -549,10 +549,10 @@ mod test { fn builtin_validation_passes() { temp_env::with_vars( [ - ("ESP_TEST__POSITIVE_NUMBER", Some("7")), - ("ESP_TEST__NEGATIVE_NUMBER", Some("-1")), - ("ESP_TEST__NON_NEGATIVE_NUMBER", Some("0")), - ("ESP_TEST__RANGE", Some("9")), + ("ESP_TEST_CONFIG_POSITIVE_NUMBER", Some("7")), + ("ESP_TEST_CONFIG_NEGATIVE_NUMBER", Some("-1")), + ("ESP_TEST_CONFIG_NON_NEGATIVE_NUMBER", Some("0")), + ("ESP_TEST_CONFIG_RANGE", Some("9")), ], || { generate_config( @@ -591,7 +591,7 @@ mod test { #[test] fn custom_validation_passes() { - temp_env::with_vars([("ESP_TEST__NUMBER", Some("13"))], || { + temp_env::with_vars([("ESP_TEST_CONFIG_NUMBER", Some("13"))], || { generate_config( "esp-test", &[( @@ -615,7 +615,7 @@ mod test { #[test] #[should_panic] fn builtin_validation_bails() { - temp_env::with_vars([("ESP_TEST__POSITIVE_NUMBER", Some("-99"))], || { + temp_env::with_vars([("ESP_TEST_CONFIG_POSITIVE_NUMBER", Some("-99"))], || { generate_config( "esp-test", &[( @@ -632,7 +632,7 @@ mod test { #[test] #[should_panic] fn custom_validation_bails() { - temp_env::with_vars([("ESP_TEST__NUMBER", Some("37"))], || { + temp_env::with_vars([("ESP_TEST_CONFIG_NUMBER", Some("37"))], || { generate_config( "esp-test", &[( @@ -658,8 +658,8 @@ mod test { fn env_unknown_bails() { temp_env::with_vars( [ - ("ESP_TEST__NUMBER", Some("0xaa")), - ("ESP_TEST__RANDOM_VARIABLE", Some("")), + ("ESP_TEST_CONFIG_NUMBER", Some("0xaa")), + ("ESP_TEST_CONFIG_RANDOM_VARIABLE", Some("")), ], || { generate_config( @@ -674,7 +674,7 @@ mod test { #[test] #[should_panic] fn env_invalid_values_bails() { - temp_env::with_vars([("ESP_TEST__NUMBER", Some("Hello world"))], || { + temp_env::with_vars([("ESP_TEST_CONFIG_NUMBER", Some("Hello world"))], || { generate_config( "esp-test", &[("number", "NA", Value::Integer(999), None)], @@ -685,12 +685,15 @@ mod test { #[test] fn env_unknown_prefix_is_ignored() { - temp_env::with_vars([("ESP_TEST_OTHER__NUMBER", Some("Hello world"))], || { - generate_config( - "esp-test", - &[("number", "NA", Value::Integer(999), None)], - false, - ); - }); + temp_env::with_vars( + [("ESP_TEST_OTHER_CONFIG_NUMBER", Some("Hello world"))], + || { + generate_config( + "esp-test", + &[("number", "NA", Value::Integer(999), None)], + false, + ); + }, + ); } } diff --git a/esp-hal-embassy/CHANGELOG.md b/esp-hal-embassy/CHANGELOG.md index 6e939afc3c..03e83cbdce 100644 --- a/esp-hal-embassy/CHANGELOG.md +++ b/esp-hal-embassy/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump MSRV to 1.83 (#2615) -- Config: Crate prefixes and configuration keys are now separated by two underscores (`__`) (#2848) +- Config: Crate prefixes and configuration keys are now separated by `_CONFIG_` (#2848) ### Fixed diff --git a/esp-hal-embassy/MIGRATING-0.5.md b/esp-hal-embassy/MIGRATING-0.5.md index b32c39ccf7..a8ff858998 100644 --- a/esp-hal-embassy/MIGRATING-0.5.md +++ b/esp-hal-embassy/MIGRATING-0.5.md @@ -4,12 +4,12 @@ To prevent ambiguity between configurations, we had to change the naming format of configuration keys. Before, we used `{prefix}_{key}`, which meant that esp-hal and esp-hal-* configuration keys -were impossible to tell apart. To fix this issue, we are changing the separator from one to two -underscore characters. This also means that users will have to change their `config.toml` +were impossible to tell apart. To fix this issue, we are changing the separator from one underscore +character to `_CONFIG_`. This also means that users will have to change their `config.toml` configurations to match the new format. ```diff [env] -ESP_HAL_EMBASSY_LOW_POWER_WAIT="false" -+ESP_HAL_EMBASSY__LOW_POWER_WAIT="false" ++ESP_HAL_EMBASSY_CONFIG_LOW_POWER_WAIT="false" ``` diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index e899c7574c..e72f1dcced 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -179,7 +179,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `Camera` and `I8080` drivers' constructors now only accepts blocking-mode DMA channels. (#2519) - Many peripherals are now disabled by default and also get disabled when the driver is dropped (#2544) -- Config: Crate prefixes and configuration keys are now separated by two underscores (`__`) (#2848) +- Config: Crate prefixes and configuration keys are now separated by `_CONFIG_` (#2848) ### Fixed diff --git a/esp-hal/MIGRATING-0.22.md b/esp-hal/MIGRATING-0.22.md index f35bdff7e0..7271f1493d 100644 --- a/esp-hal/MIGRATING-0.22.md +++ b/esp-hal/MIGRATING-0.22.md @@ -348,12 +348,12 @@ The reexports that were previously part of the prelude are available through oth To prevent ambiguity between configurations, we had to change the naming format of configuration keys. Before, we used `{prefix}_{key}`, which meant that esp-hal and esp-hal-* configuration keys -were impossible to tell apart. To fix this issue, we are changing the separator from one to two -underscore characters. This also means that users will have to change their `config.toml` +were impossible to tell apart. To fix this issue, we are changing the separator from one underscore +character to `_CONFIG_`. This also means that users will have to change their `config.toml` configurations to match the new format. ```diff [env] -ESP_HAL_PLACE_SPI_DRIVER_IN_RAM="true" -+ESP_HAL__PLACE_SPI_DRIVER_IN_RAM="true" ++ESP_HAL_CONFIG_PLACE_SPI_DRIVER_IN_RAM="true" ``` diff --git a/esp-ieee802154/CHANGELOG.md b/esp-ieee802154/CHANGELOG.md index 7d00f341d3..b11f9205d7 100644 --- a/esp-ieee802154/CHANGELOG.md +++ b/esp-ieee802154/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump MSRV to 1.83 (#2615) -- Config: Crate prefixes and configuration keys are now separated by two underscores (`__`) (#2848) +- Config: Crate prefixes and configuration keys are now separated by `_CONFIG_` (#2848) ### Fixed diff --git a/esp-ieee802154/MIGRATING-0.4.md b/esp-ieee802154/MIGRATING-0.4.md index 6ea64e39bc..3f3c1717d2 100644 --- a/esp-ieee802154/MIGRATING-0.4.md +++ b/esp-ieee802154/MIGRATING-0.4.md @@ -4,12 +4,12 @@ To prevent ambiguity between configurations, we had to change the naming format of configuration keys. Before, we used `{prefix}_{key}`, which meant that esp-hal and esp-hal-* configuration keys -were impossible to tell apart. To fix this issue, we are changing the separator from one to two -underscore characters. This also means that users will have to change their `config.toml` +were impossible to tell apart. To fix this issue, we are changing the separator from one underscore +character to `_CONFIG_`. This also means that users will have to change their `config.toml` configurations to match the new format. ```diff [env] -ESP_IEEE802154_RX_QUEUE_SIZE = "50" -+ESP_IEEE802154__RX_QUEUE_SIZE = "50" ++ESP_IEEE802154_CONFIG_RX_QUEUE_SIZE = "50" ``` diff --git a/esp-ieee802154/src/lib.rs b/esp-ieee802154/src/lib.rs index 255495f50c..3dc6bb4036 100644 --- a/esp-ieee802154/src/lib.rs +++ b/esp-ieee802154/src/lib.rs @@ -67,7 +67,7 @@ struct QueueConfig { } pub(crate) const CONFIG: QueueConfig = QueueConfig { - rx_queue_size: esp_config_int!(usize, "ESP_IEEE802154__RX_QUEUE_SIZE"), + rx_queue_size: esp_config_int!(usize, "ESP_IEEE802154_CONFIG_RX_QUEUE_SIZE"), }; /// IEEE 802.15.4 driver configuration diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index 8ac86f0459..259e425d82 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -38,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `phy_enable_usb` is enabled by default (#2446) - Removed `get_` prefixes from functions (#2528) -- Config: Crate prefixes and configuration keys are now separated by two underscores (`__`) (#2848) +- Config: Crate prefixes and configuration keys are now separated by `_CONFIG_` (#2848) ### Fixed diff --git a/esp-wifi/MIGRATING-0.11.md b/esp-wifi/MIGRATING-0.11.md index 566c4d5407..cca35e5209 100644 --- a/esp-wifi/MIGRATING-0.11.md +++ b/esp-wifi/MIGRATING-0.11.md @@ -13,7 +13,7 @@ configurations to match the new format. -ESP_WIFI_RX_QUEUE_SIZE = "16" -ESP_WIFI_STATIC_RX_BUF_NUM = "32" -ESP_WIFI_DYNAMIC_RX_BUF_NUM = "16" -+ESP_WIFI__RX_QUEUE_SIZE = "16" -+ESP_WIFI__STATIC_RX_BUF_NUM = "32" -+ESP_WIFI__DYNAMIC_RX_BUF_NUM = "16" ++ESP_WIFI_CONFIG_RX_QUEUE_SIZE = "16" ++ESP_WIFI_CONFIG_STATIC_RX_BUF_NUM = "32" ++ESP_WIFI_CONFIG_DYNAMIC_RX_BUF_NUM = "16" ``` diff --git a/esp-wifi/src/lib.rs b/esp-wifi/src/lib.rs index 7e9f1842ce..c7178b9518 100644 --- a/esp-wifi/src/lib.rs +++ b/esp-wifi/src/lib.rs @@ -185,27 +185,30 @@ struct Config { } pub(crate) const CONFIG: config::EspWifiConfig = config::EspWifiConfig { - rx_queue_size: esp_config_int!(usize, "ESP_WIFI__RX_QUEUE_SIZE"), - tx_queue_size: esp_config_int!(usize, "ESP_WIFI__TX_QUEUE_SIZE"), - static_rx_buf_num: esp_config_int!(usize, "ESP_WIFI__STATIC_RX_BUF_NUM"), - dynamic_rx_buf_num: esp_config_int!(usize, "ESP_WIFI__DYNAMIC_RX_BUF_NUM"), - static_tx_buf_num: esp_config_int!(usize, "ESP_WIFI__STATIC_TX_BUF_NUM"), - dynamic_tx_buf_num: esp_config_int!(usize, "ESP_WIFI__DYNAMIC_TX_BUF_NUM"), - csi_enable: esp_config_bool!("ESP_WIFI__CSI_ENABLE"), - ampdu_rx_enable: esp_config_bool!("ESP_WIFI__AMPDU_RX_ENABLE"), - ampdu_tx_enable: esp_config_bool!("ESP_WIFI__AMPDU_TX_ENABLE"), - amsdu_tx_enable: esp_config_bool!("ESP_WIFI__AMSDU_TX_ENABLE"), - rx_ba_win: esp_config_int!(usize, "ESP_WIFI__RX_BA_WIN"), - max_burst_size: esp_config_int!(usize, "ESP_WIFI__MAX_BURST_SIZE"), - country_code: esp_config_str!("ESP_WIFI__COUNTRY_CODE"), - country_code_operating_class: esp_config_int!(u8, "ESP_WIFI__COUNTRY_CODE_OPERATING_CLASS"), - mtu: esp_config_int!(usize, "ESP_WIFI__MTU"), - tick_rate_hz: esp_config_int!(u32, "ESP_WIFI__TICK_RATE_HZ"), - listen_interval: esp_config_int!(u16, "ESP_WIFI__LISTEN_INTERVAL"), - beacon_timeout: esp_config_int!(u16, "ESP_WIFI__BEACON_TIMEOUT"), - ap_beacon_timeout: esp_config_int!(u16, "ESP_WIFI__AP_BEACON_TIMEOUT"), - failure_retry_cnt: esp_config_int!(u8, "ESP_WIFI__FAILURE_RETRY_CNT"), - scan_method: esp_config_int!(u32, "ESP_WIFI__SCAN_METHOD"), + rx_queue_size: esp_config_int!(usize, "ESP_WIFI_CONFIG_RX_QUEUE_SIZE"), + tx_queue_size: esp_config_int!(usize, "ESP_WIFI_CONFIG_TX_QUEUE_SIZE"), + static_rx_buf_num: esp_config_int!(usize, "ESP_WIFI_CONFIG_STATIC_RX_BUF_NUM"), + dynamic_rx_buf_num: esp_config_int!(usize, "ESP_WIFI_CONFIG_DYNAMIC_RX_BUF_NUM"), + static_tx_buf_num: esp_config_int!(usize, "ESP_WIFI_CONFIG_STATIC_TX_BUF_NUM"), + dynamic_tx_buf_num: esp_config_int!(usize, "ESP_WIFI_CONFIG_DYNAMIC_TX_BUF_NUM"), + csi_enable: esp_config_bool!("ESP_WIFI_CONFIG_CSI_ENABLE"), + ampdu_rx_enable: esp_config_bool!("ESP_WIFI_CONFIG_AMPDU_RX_ENABLE"), + ampdu_tx_enable: esp_config_bool!("ESP_WIFI_CONFIG_AMPDU_TX_ENABLE"), + amsdu_tx_enable: esp_config_bool!("ESP_WIFI_CONFIG_AMSDU_TX_ENABLE"), + rx_ba_win: esp_config_int!(usize, "ESP_WIFI_CONFIG_RX_BA_WIN"), + max_burst_size: esp_config_int!(usize, "ESP_WIFI_CONFIG_MAX_BURST_SIZE"), + country_code: esp_config_str!("ESP_WIFI_CONFIG_COUNTRY_CODE"), + country_code_operating_class: esp_config_int!( + u8, + "ESP_WIFI_CONFIG_COUNTRY_CODE_OPERATING_CLASS" + ), + mtu: esp_config_int!(usize, "ESP_WIFI_CONFIG_MTU"), + tick_rate_hz: esp_config_int!(u32, "ESP_WIFI_CONFIG_TICK_RATE_HZ"), + listen_interval: esp_config_int!(u16, "ESP_WIFI_CONFIG_LISTEN_INTERVAL"), + beacon_timeout: esp_config_int!(u16, "ESP_WIFI_CONFIG_BEACON_TIMEOUT"), + ap_beacon_timeout: esp_config_int!(u16, "ESP_WIFI_CONFIG_AP_BEACON_TIMEOUT"), + failure_retry_cnt: esp_config_int!(u8, "ESP_WIFI_CONFIG_FAILURE_RETRY_CNT"), + scan_method: esp_config_int!(u32, "ESP_WIFI_CONFIG_SCAN_METHOD"), }; // Validate the configuration at compile time diff --git a/examples/.cargo/config.toml b/examples/.cargo/config.toml index 79a5678200..28c6f091be 100644 --- a/examples/.cargo/config.toml +++ b/examples/.cargo/config.toml @@ -33,7 +33,7 @@ PASSWORD = "PASSWORD" STATIC_IP = "1.1.1.1 " GATEWAY_IP = "1.1.1.1" HOST_IP = "1.1.1.1" -ESP_WIFI__CSI_ENABLE = "true" +ESP_WIFI_CONFIG_CSI_ENABLE = "true" [unstable] build-std = ["alloc", "core"]