Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XTASK: add a way to activate features per chip (docs) #2287

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 32 additions & 28 deletions xtask/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -174,6 +147,37 @@ pub fn build_documentation(
Ok(docs_path)
}

fn apply_feature_rules(package: &Package, config: &Config) -> Vec<String> {
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<Vec<Metadata>> {
let mut examples = Vec::new();
Expand Down