Skip to contentSkip to conversation

rust: centralize config in workspace root

PATCH In review Stefan Zabka 1 participant 2 messages May 2, 2025 Rust

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: centralize config in workspace root

This commit bundles common config option in the workspace root and applies them through <config>.workspace = true

---
 rust/Cargo.toml                 |  7 +++++++
 rust/hw/char/pl011/Cargo.toml   | 11 ++++++-----
 rust/hw/timer/hpet/Cargo.toml   |  9 ++++++---
 rust/qemu-api-macros/Cargo.toml | 11 ++++++-----
 rust/qemu-api/Cargo.toml        | 15 +++++++--------
 5 files changed, 32 insertions(+), 21 deletions(-)
rust/Cargo.toml +7 -0
index ab1185a8143..5ace47c69be 100644
@@ -7,6 +7,13 @@ members = [
     "hw/timer/hpet",
 ]
 
+[workspace.package]
+edition = "2021"
+homepage = "https://www.qemu.org"
+license = "GPL-2.0-or-later"
+repository = "https://gitlab.com/qemu-project/qemu/"
+rust-version = "1.63.0"
+
 [workspace.lints.rust]
 unexpected_cfgs = { level = "deny", check-cfg = [
     'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)',
rust/hw/char/pl011/Cargo.toml +6 -5
index f2296cad58b..a1f431ab4a3 100644
@@ -1,15 +1,16 @@
 [package]
 name = "pl011"
 version = "0.1.0"
-edition = "2021"
 authors = ["Manos Pitsidianakis <[email protected]>"]
-license = "GPL-2.0-or-later"
 description = "pl011 device model for QEMU"
 resolver = "2"
 publish = false
-keywords = []
-categories = []
-rust-version = "1.63.0"
+
+edition.workspace = true
+homepage.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
 
 [lib]
 crate-type = ["staticlib"]
rust/hw/timer/hpet/Cargo.toml +6 -3
index 147f216e725..6f075027843 100644
@@ -1,11 +1,14 @@
 [package]
 name = "hpet"
 version = "0.1.0"
-edition = "2021"
 authors = ["Zhao Liu <[email protected]>"]
-license = "GPL-2.0-or-later"
 description = "IA-PC High Precision Event Timer emulation in Rust"
-rust-version = "1.63.0"
+
+edition.workspace = true
+homepage.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
 
 [lib]
 crate-type = ["staticlib"]
rust/qemu-api-macros/Cargo.toml +6 -5
index 89dee1cfb39..0cd40c8e168 100644
@@ -1,15 +1,16 @@
 [package]
 name = "qemu_api_macros"
 version = "0.1.0"
-edition = "2021"
 authors = ["Manos Pitsidianakis <[email protected]>"]
-license = "GPL-2.0-or-later"
 description = "Rust bindings for QEMU - Utility macros"
 resolver = "2"
 publish = false
-keywords = []
-categories = []
-rust-version = "1.63.0"
+
+edition.workspace = true
+homepage.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
 
 [lib]
 proc-macro = true
rust/qemu-api/Cargo.toml +7 -8
index 57747bc9341..ca1b04269fd 100644
@@ -1,18 +1,17 @@
 [package]
 name = "qemu_api"
 version = "0.1.0"
-edition = "2021"
 authors = ["Manos Pitsidianakis <[email protected]>"]
-license = "GPL-2.0-or-later"
-readme = "README.md"
-homepage = "https://www.qemu.org"
 description = "Rust bindings for QEMU"
-repository = "https://gitlab.com/qemu-project/qemu/"
+readme = "README.md"
 resolver = "2"
 publish = false
-keywords = []
-categories = []
-rust-version = "1.63.0"
+
+edition.workspace = true
+homepage.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
 
 [dependencies]
 qemu_api_macros = { path = "../qemu-api-macros" }
Signature · 1 line
2.49.0
#1 lore raw

Just realised that I forgot to CC Paolo and also that I didn't strictly enforce the tag order of name, version, authors and then alphabetically like I wanted to.

I hope this is still enough of an improvement over the status quo.

I also considered centralising the publish = false but as the hpet crate didn't have it, I wasn't sure if I was introducing unintended behaviour.

I also just discovered [here](https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions) that the resolver in the sub crates is ignored when a workspace resolver is set, so it would probably be more correct to just remove the entry entirely.

Please lmk whether that should be part of a v2 for this patch (series) or if I should create new separate series for that.

Best
Stefan