aboutsummaryrefslogtreecommitdiff
path: root/release/src
diff options
context:
space:
mode:
Diffstat (limited to 'release/src')
-rw-r--r--release/src/main.rs55
-rw-r--r--release/src/semver_check.rs14
-rw-r--r--release/src/types.rs27
3 files changed, 48 insertions, 48 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 @@
1use simple_logger::SimpleLogger;
2use std::collections::{BTreeMap, HashMap}; 1use std::collections::{BTreeMap, HashMap};
3use std::fs; 2use std::fs;
4use std::path::{Path, PathBuf}; 3use std::path::{Path, PathBuf};
@@ -6,9 +5,11 @@ use std::process::Command as ProcessCommand;
6 5
7use anyhow::{anyhow, Result}; 6use anyhow::{anyhow, Result};
8use clap::{Parser, Subcommand}; 7use clap::{Parser, Subcommand};
8use log::info;
9use petgraph::graph::{Graph, NodeIndex}; 9use petgraph::graph::{Graph, NodeIndex};
10use petgraph::visit::Bfs; 10use petgraph::visit::Bfs;
11use petgraph::{Directed, Direction}; 11use petgraph::{Directed, Direction};
12use simple_logger::SimpleLogger;
12use toml_edit::{DocumentMut, Item, Value}; 13use toml_edit::{DocumentMut, Item, Value};
13use types::*; 14use types::*;
14 15
@@ -63,15 +64,6 @@ enum Command {
63 }, 64 },
64} 65}
65 66
66fn 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
75fn update_version(c: &mut Crate, new_version: &str) -> Result<()> { 67fn 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
123fn list_crates(root: &PathBuf) -> Result<BTreeMap<CrateId, Crate>> { 115fn 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(&current_path).ok(); 70 std::fs::remove_file(&current_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 @@
1use serde::Deserialize;
2use std::collections::{BTreeMap, HashMap}; 1use std::collections::{BTreeMap, HashMap};
3use std::path::PathBuf; 2use std::path::PathBuf;
4 3
4use serde::Deserialize;
5
5#[derive(Debug, Deserialize)] 6#[derive(Debug, Deserialize)]
6pub struct ParsedCrate { 7pub struct ParsedCrate {
7 pub package: ParsedPackage, 8 pub package: ParsedPackage,
@@ -12,15 +13,31 @@ pub struct ParsedCrate {
12pub struct ParsedPackage { 13pub 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)]
21pub struct Metadata {
22 #[serde(default)]
23 pub embassy: MetadataEmbassy,
24}
25
26#[derive(Debug, Deserialize, Default)]
27pub 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)]
18pub struct CrateConfig { 35pub 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
23pub type ReleaseConfig = HashMap<String, CrateConfig>;
24pub type CrateId = String; 41pub 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}