diff options
Diffstat (limited to 'release/src/main.rs')
| -rw-r--r-- | release/src/main.rs | 55 |
1 files changed, 22 insertions, 33 deletions
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()); |
