diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 1f0059df43f..043cdda2e77 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -116,36 +116,9 @@ pub fn build_documentation( let mut features = vec![chip.to_string()]; - // future enhancement: see https://github.com/esp-rs/esp-hal/issues/2195 - if matches!(package, Package::EspHal) { - features.push("ci".to_owned()); - - if [Chip::Esp32, Chip::Esp32s2, Chip::Esp32s3].contains(&chip) { - features.push("quad-psram".to_owned()); - } - } - let chip = Config::for_chip(&chip); - if matches!(package, Package::EspWifi) { - let wifi = chip.contains("wifi"); - let ble = chip.contains("ble"); - if wifi { - features.push("wifi".to_owned()); - features.push("wifi-default".to_owned()); - features.push("esp-now".to_owned()); - features.push("sniffer".to_owned()); - features.push("utils".to_owned()); - features.push("embassy-net".to_owned()); - } - if ble { - features.push("ble".to_owned()); - } - if wifi && ble { - features.push("coex".to_owned()); - } - features.push("async".to_owned()); - } + features.extend(apply_feature_rules(&package, chip)); // Build up an array of command-line arguments to pass to `cargo`: let builder = CargoArgsBuilder::default() @@ -174,6 +147,37 @@ pub fn build_documentation( Ok(docs_path) } +fn apply_feature_rules(package: &Package, config: &Config) -> Vec { + let chip_name = &config.name(); + + match (package, chip_name.as_str()) { + (Package::EspHal, "esp32") => vec!["quad-psram".to_owned(), "ci".to_owned()], + (Package::EspHal, "esp32s2") => vec!["quad-psram".to_owned(), "ci".to_owned()], + (Package::EspHal, "esp32s3") => vec!["quad-psram".to_owned(), "ci".to_owned()], + (Package::EspHal, _) => vec!["ci".to_owned()], + (Package::EspWifi, _) => { + let mut features = vec![]; + if config.contains("wifi") { + features.push("wifi".to_owned()); + features.push("wifi-default".to_owned()); + features.push("esp-now".to_owned()); + features.push("sniffer".to_owned()); + features.push("utils".to_owned()); + features.push("embassy-net".to_owned()); + } + if config.contains("ble") { + features.push("ble".to_owned()); + } + if config.contains("wifi") && config.contains("ble") { + features.push("coex".to_owned()); + } + features.push("async".to_owned()); + features + } + _ => vec![], + } +} + /// Load all examples at the given path, and parse their metadata. pub fn load_examples(path: &Path, action: CargoAction) -> Result> { let mut examples = Vec::new();