diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-08-15 15:30:14 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2025-08-25 19:44:50 +0200 |
| commit | 9f12852c389d65a8b2e252e027f69dfef2383736 (patch) | |
| tree | 8dc1f32170a62d2a82e033f57ccf423b648b93e5 /release | |
| parent | 3f21c9022396fb2f77b4521dda67728520b999a9 (diff) | |
Read crate configs from metadata.
Diffstat (limited to 'release')
| -rw-r--r-- | release/Cargo.toml | 7 | ||||
| -rw-r--r-- | release/config.toml | 46 | ||||
| -rw-r--r-- | release/src/main.rs | 55 | ||||
| -rw-r--r-- | release/src/semver_check.rs | 14 | ||||
| -rw-r--r-- | release/src/types.rs | 27 |
5 files changed, 53 insertions, 96 deletions
diff --git a/release/Cargo.toml b/release/Cargo.toml index 461021e0a..3e4094eed 100644 --- a/release/Cargo.toml +++ b/release/Cargo.toml | |||
| @@ -19,5 +19,8 @@ simple_logger = "5.0.0" | |||
| 19 | temp-file = "0.1.9" | 19 | temp-file = "0.1.9" |
| 20 | flate2 = "1.1.1" | 20 | flate2 = "1.1.1" |
| 21 | 21 | ||
| 22 | [patch.crates-io] | 22 | #[patch.crates-io] |
| 23 | cargo-semver-checks = { path = "../../cargo-semver-checks" } | 23 | #cargo-semver-checks = { path = "../../cargo-semver-checks" } |
| 24 | |||
| 25 | [package.metadata.embassy] | ||
| 26 | skip = true | ||
diff --git a/release/config.toml b/release/config.toml deleted file mode 100644 index 014c73a91..000000000 --- a/release/config.toml +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | |||
| 2 | embassy-stm32 = { features = ["defmt", "unstable-pac", "exti", "time-driver-any", "time", "stm32h755zi-cm7", "dual-bank"], target = "thumbv7em-none-eabi" } | ||
| 3 | embassy-nrf = { features = ["nrf52840", "time", "defmt", "unstable-pac", "gpiote", "time-driver-rtc1"], target = "thumbv7em-none-eabihf" } | ||
| 4 | |||
| 5 | embassy-rp = { features = ["defmt", "unstable-pac", "time-driver", "rp2040"], target = "thumbv6m-none-eabi" } | ||
| 6 | cyw43 = { features = ["defmt", "firmware-logs"], target = "thumbv6m-none-eabi" } | ||
| 7 | cyw43-pio = { features = ["defmt", "embassy-rp/rp2040"], target = "thumbv6m-none-eabi" } | ||
| 8 | |||
| 9 | embassy-boot = { features = ["defmt"] } | ||
| 10 | embassy-boot-nrf = { features = ["defmt", "embassy-nrf/nrf52840"], target = "thumbv7em-none-eabihf" } | ||
| 11 | embassy-boot-rp = { features = ["defmt", "embassy-rp/rp2040"], target = "thumbv6m-none-eabi" } | ||
| 12 | embassy-boot-stm32 = { features = ["defmt", "embassy-stm32/stm32f429zi"], target = "thumbv7em-none-eabi" } | ||
| 13 | |||
| 14 | embassy-time = { features = ["defmt", "std"] } | ||
| 15 | embassy-time-driver = { } | ||
| 16 | embassy-time-queue-utils = { features = ["defmt"] } | ||
| 17 | |||
| 18 | embassy-futures = { } | ||
| 19 | embassy-embedded-hal = { features = ["time"] } | ||
| 20 | embassy-hal-internal = { } | ||
| 21 | embassy-executor = { features = ["defmt", "arch-cortex-m", "executor-thread", "executor-interrupt"], target = "thumbv7em-none-eabi" } | ||
| 22 | embassy-executor-macros = { } | ||
| 23 | embassy-sync = { } | ||
| 24 | |||
| 25 | embassy-net = { features = ["defmt", "tcp", "udp", "raw", "dns", "icmp", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "multicast", "dhcpv4-hostname"] } | ||
| 26 | embassy-net-ppp = { } | ||
| 27 | embassy-net-esp-hosted = {} | ||
| 28 | embassy-net-driver-channel = {} | ||
| 29 | embassy-net-wiznet = {} | ||
| 30 | embassy-net-nrf91 = { features = ["defmt", "nrf-pac/nrf9160"] } | ||
| 31 | embassy-net-driver = {} | ||
| 32 | embassy-net-tuntap = {} | ||
| 33 | embassy-net-adin1110 = {} | ||
| 34 | embassy-net-enc28j60 = {} | ||
| 35 | |||
| 36 | embassy-usb-driver = { } | ||
| 37 | embassy-usb-dfu = { features = ["dfu"] } | ||
| 38 | embassy-usb-synopsys-otg = { } | ||
| 39 | embassy-usb = { features = ["defmt", "usbd-hid"] } | ||
| 40 | embassy-usb-logger = { } | ||
| 41 | |||
| 42 | # Unreleased | ||
| 43 | # embassy-stm32-wpan = {} | ||
| 44 | # embassy-imxrt = {} | ||
| 45 | # embassy-nxp = {} | ||
| 46 | # embassy-mspm0 = {} | ||
diff --git a/release/src/main.rs b/release/src/main.rs index 0dbcc5d45..a49d8f36c 100644 --- a/release/src/main.rs +++ b/release/src/main.rs | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | use simple_logger::SimpleLogger; | ||
| 2 | use std::collections::{BTreeMap, HashMap}; | 1 | use std::collections::{BTreeMap, HashMap}; |
| 3 | use std::fs; | 2 | use std::fs; |
| 4 | use std::path::{Path, PathBuf}; | 3 | use std::path::{Path, PathBuf}; |
| @@ -6,9 +5,11 @@ use std::process::Command as ProcessCommand; | |||
| 6 | 5 | ||
| 7 | use anyhow::{anyhow, Result}; | 6 | use anyhow::{anyhow, Result}; |
| 8 | use clap::{Parser, Subcommand}; | 7 | use clap::{Parser, Subcommand}; |
| 8 | use log::info; | ||
| 9 | use petgraph::graph::{Graph, NodeIndex}; | 9 | use petgraph::graph::{Graph, NodeIndex}; |
| 10 | use petgraph::visit::Bfs; | 10 | use petgraph::visit::Bfs; |
| 11 | use petgraph::{Directed, Direction}; | 11 | use petgraph::{Directed, Direction}; |
| 12 | use simple_logger::SimpleLogger; | ||
| 12 | use toml_edit::{DocumentMut, Item, Value}; | 13 | use toml_edit::{DocumentMut, Item, Value}; |
| 13 | use types::*; | 14 | use types::*; |
| 14 | 15 | ||
| @@ -63,15 +64,6 @@ enum Command { | |||
| 63 | }, | 64 | }, |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | fn load_release_config(repo: &Path) -> ReleaseConfig { | ||
| 67 | let config_path = repo.join("release/config.toml"); | ||
| 68 | if !config_path.exists() { | ||
| 69 | return HashMap::new(); | ||
| 70 | } | ||
| 71 | let content = fs::read_to_string(&config_path).expect("Failed to read release/config.toml"); | ||
| 72 | toml::from_str(&content).expect("Invalid TOML format in release/config.toml") | ||
| 73 | } | ||
| 74 | |||
| 75 | fn update_version(c: &mut Crate, new_version: &str) -> Result<()> { | 67 | fn update_version(c: &mut Crate, new_version: &str) -> Result<()> { |
| 76 | let path = c.path.join("Cargo.toml"); | 68 | let path = c.path.join("Cargo.toml"); |
| 77 | c.version = new_version.to_string(); | 69 | c.version = new_version.to_string(); |
| @@ -122,12 +114,10 @@ fn update_versions(to_update: &Crate, dep: &CrateId, new_version: &str) -> Resul | |||
| 122 | 114 | ||
| 123 | fn list_crates(root: &PathBuf) -> Result<BTreeMap<CrateId, Crate>> { | 115 | fn list_crates(root: &PathBuf) -> Result<BTreeMap<CrateId, Crate>> { |
| 124 | let d = std::fs::read_dir(root)?; | 116 | let d = std::fs::read_dir(root)?; |
| 125 | let release_config = load_release_config(root); | ||
| 126 | let mut crates = BTreeMap::new(); | 117 | let mut crates = BTreeMap::new(); |
| 127 | for c in d { | 118 | for c in d { |
| 128 | let entry = c?; | 119 | let entry = c?; |
| 129 | let name = entry.file_name().to_str().unwrap().to_string(); | 120 | if entry.file_type()?.is_dir() { |
| 130 | if entry.file_type()?.is_dir() && name.starts_with("embassy-") { | ||
| 131 | let path = root.join(entry.path()); | 121 | let path = root.join(entry.path()); |
| 132 | let entry = path.join("Cargo.toml"); | 122 | let entry = path.join("Cargo.toml"); |
| 133 | if entry.exists() { | 123 | if entry.exists() { |
| @@ -135,6 +125,8 @@ fn list_crates(root: &PathBuf) -> Result<BTreeMap<CrateId, Crate>> { | |||
| 135 | let parsed: ParsedCrate = toml::from_str(&content)?; | 125 | let parsed: ParsedCrate = toml::from_str(&content)?; |
| 136 | let id = parsed.package.name; | 126 | let id = parsed.package.name; |
| 137 | 127 | ||
| 128 | let metadata = &parsed.package.metadata.embassy; | ||
| 129 | |||
| 138 | let mut dependencies = Vec::new(); | 130 | let mut dependencies = Vec::new(); |
| 139 | for (k, _) in parsed.dependencies { | 131 | for (k, _) in parsed.dependencies { |
| 140 | if k.starts_with("embassy-") { | 132 | if k.starts_with("embassy-") { |
| @@ -142,18 +134,19 @@ fn list_crates(root: &PathBuf) -> Result<BTreeMap<CrateId, Crate>> { | |||
| 142 | } | 134 | } |
| 143 | } | 135 | } |
| 144 | 136 | ||
| 145 | if let Some(config) = release_config.get(&id) { | 137 | crates.insert( |
| 146 | crates.insert( | 138 | id.clone(), |
| 147 | id.clone(), | 139 | Crate { |
| 148 | Crate { | 140 | name: id, |
| 149 | name: id, | 141 | version: parsed.package.version, |
| 150 | version: parsed.package.version, | 142 | path, |
| 151 | path, | 143 | dependencies, |
| 152 | dependencies, | 144 | config: metadata.build.first().cloned().unwrap_or_else(|| BuildConfig { |
| 153 | config: config.clone(), | 145 | features: vec![], |
| 154 | }, | 146 | target: None, |
| 155 | ); | 147 | }), |
| 156 | } | 148 | }, |
| 149 | ); | ||
| 157 | } | 150 | } |
| 158 | } | 151 | } |
| 159 | } | 152 | } |
| @@ -313,10 +306,8 @@ fn main() -> Result<()> { | |||
| 313 | c.path.join("Cargo.toml").display().to_string(), | 306 | c.path.join("Cargo.toml").display().to_string(), |
| 314 | ]; | 307 | ]; |
| 315 | 308 | ||
| 316 | if let Some(features) = &c.config.features { | 309 | args.push("--features".into()); |
| 317 | args.push("--features".into()); | 310 | args.push(c.config.features.join(",")); |
| 318 | args.push(features.join(",")); | ||
| 319 | } | ||
| 320 | 311 | ||
| 321 | if let Some(target) = &c.config.target { | 312 | if let Some(target) = &c.config.target { |
| 322 | args.push("--target".into()); | 313 | args.push("--target".into()); |
| @@ -376,10 +367,8 @@ fn publish_release(_repo: &Path, c: &Crate, push: bool) -> Result<()> { | |||
| 376 | c.path.join("Cargo.toml").display().to_string(), | 367 | c.path.join("Cargo.toml").display().to_string(), |
| 377 | ]; | 368 | ]; |
| 378 | 369 | ||
| 379 | if let Some(features) = &c.config.features { | 370 | args.push("--features".into()); |
| 380 | args.push("--features".into()); | 371 | args.push(c.config.features.join(",")); |
| 381 | args.push(features.join(",")); | ||
| 382 | } | ||
| 383 | 372 | ||
| 384 | if let Some(target) = &c.config.target { | 373 | if let Some(target) = &c.config.target { |
| 385 | args.push("--target".into()); | 374 | args.push("--target".into()); |
diff --git a/release/src/semver_check.rs b/release/src/semver_check.rs index 7b2e50672..96f8ebe2e 100644 --- a/release/src/semver_check.rs +++ b/release/src/semver_check.rs | |||
| @@ -23,11 +23,9 @@ pub fn minimum_update(krate: &Crate) -> Result<ReleaseType, anyhow::Error> { | |||
| 23 | semver_check.with_default_features(); | 23 | semver_check.with_default_features(); |
| 24 | semver_check.set_baseline(baseline); | 24 | semver_check.set_baseline(baseline); |
| 25 | semver_check.set_packages(vec![package_name]); | 25 | semver_check.set_packages(vec![package_name]); |
| 26 | if let Some(features) = &krate.config.features { | 26 | let extra_current_features = krate.config.features.clone(); |
| 27 | let extra_current_features = features.clone(); | 27 | let extra_baseline_features = krate.config.features.clone(); |
| 28 | let extra_baseline_features = features.clone(); | 28 | semver_check.set_extra_features(extra_current_features, extra_baseline_features); |
| 29 | semver_check.set_extra_features(extra_current_features, extra_baseline_features); | ||
| 30 | } | ||
| 31 | if let Some(target) = &krate.config.target { | 29 | if let Some(target) = &krate.config.target { |
| 32 | semver_check.set_build_target(target.clone()); | 30 | semver_check.set_build_target(target.clone()); |
| 33 | } | 31 | } |
| @@ -70,11 +68,7 @@ pub(crate) fn build_doc_json(krate: &Crate) -> Result<PathBuf, anyhow::Error> { | |||
| 70 | .join(format!("{}.json", krate.name.to_string().replace("-", "_"))); | 68 | .join(format!("{}.json", krate.name.to_string().replace("-", "_"))); |
| 71 | 69 | ||
| 72 | std::fs::remove_file(¤t_path).ok(); | 70 | std::fs::remove_file(¤t_path).ok(); |
| 73 | let features = if let Some(features) = &krate.config.features { | 71 | let features = krate.config.features.clone(); |
| 74 | features.clone() | ||
| 75 | } else { | ||
| 76 | vec![] | ||
| 77 | }; | ||
| 78 | 72 | ||
| 79 | log::info!("Building doc json for {} with features: {:?}", krate.name, features); | 73 | log::info!("Building doc json for {} with features: {:?}", krate.name, features); |
| 80 | 74 | ||
diff --git a/release/src/types.rs b/release/src/types.rs index 56a886e6f..39e8e9f48 100644 --- a/release/src/types.rs +++ b/release/src/types.rs | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | use serde::Deserialize; | ||
| 2 | use std::collections::{BTreeMap, HashMap}; | 1 | use std::collections::{BTreeMap, HashMap}; |
| 3 | use std::path::PathBuf; | 2 | use std::path::PathBuf; |
| 4 | 3 | ||
| 4 | use serde::Deserialize; | ||
| 5 | |||
| 5 | #[derive(Debug, Deserialize)] | 6 | #[derive(Debug, Deserialize)] |
| 6 | pub struct ParsedCrate { | 7 | pub struct ParsedCrate { |
| 7 | pub package: ParsedPackage, | 8 | pub package: ParsedPackage, |
| @@ -12,15 +13,31 @@ pub struct ParsedCrate { | |||
| 12 | pub struct ParsedPackage { | 13 | pub struct ParsedPackage { |
| 13 | pub name: String, | 14 | pub name: String, |
| 14 | pub version: String, | 15 | pub version: String, |
| 16 | #[serde(default)] | ||
| 17 | pub metadata: Metadata, | ||
| 18 | } | ||
| 19 | |||
| 20 | #[derive(Debug, Deserialize, Default)] | ||
| 21 | pub struct Metadata { | ||
| 22 | #[serde(default)] | ||
| 23 | pub embassy: MetadataEmbassy, | ||
| 24 | } | ||
| 25 | |||
| 26 | #[derive(Debug, Deserialize, Default)] | ||
| 27 | pub struct MetadataEmbassy { | ||
| 28 | #[serde(default)] | ||
| 29 | pub skip: bool, | ||
| 30 | #[serde(default)] | ||
| 31 | pub build: Vec<BuildConfig>, | ||
| 15 | } | 32 | } |
| 16 | 33 | ||
| 17 | #[derive(Debug, Clone, Deserialize)] | 34 | #[derive(Debug, Clone, Deserialize)] |
| 18 | pub struct CrateConfig { | 35 | pub struct BuildConfig { |
| 19 | pub features: Option<Vec<String>>, | 36 | #[serde(default)] |
| 37 | pub features: Vec<String>, | ||
| 20 | pub target: Option<String>, | 38 | pub target: Option<String>, |
| 21 | } | 39 | } |
| 22 | 40 | ||
| 23 | pub type ReleaseConfig = HashMap<String, CrateConfig>; | ||
| 24 | pub type CrateId = String; | 41 | pub type CrateId = String; |
| 25 | 42 | ||
| 26 | #[derive(Debug, Clone)] | 43 | #[derive(Debug, Clone)] |
| @@ -28,6 +45,6 @@ pub struct Crate { | |||
| 28 | pub name: String, | 45 | pub name: String, |
| 29 | pub version: String, | 46 | pub version: String, |
| 30 | pub path: PathBuf, | 47 | pub path: PathBuf, |
| 31 | pub config: CrateConfig, | ||
| 32 | pub dependencies: Vec<CrateId>, | 48 | pub dependencies: Vec<CrateId>, |
| 49 | pub config: BuildConfig, // TODO make this a vec. | ||
| 33 | } | 50 | } |
