refactor(version): one komorebi-version crate for Linux and macOS

version-linux (komorebi-for-kde/version, shadow-rs 2) and version-macos
(komorebi-for-mac/version, shadow-rs 1) had the same build.rs and the same lib.rs. They
are now one package, crates/komorebi-version (lib name version, shadow-rs from the
workspace), and the KDE and macOS daemons, their command lines and the unified komorebic
depend on it under the key version. The extern crate lines of komorebic/src/main.rs that
renamed the two crates are gone, and the two deny.toml clarify entries name the new
package.

komorebi-daemon/tests/linux_version.rs read the version out of the old crate's Cargo.toml
text, which no longer has a number (it is inherited); it now expects the package version,
which is the workspace version.

Verified: cargo test -p komorebi -p komorebic -p komorebi-client -p komorebi-linux (KDE
side, native Linux) all pass, including the version test; cargo check --target
aarch64-apple-darwin of the macOS packages with the fake C compiler passes. Windows and
nix were not run for this revision (Windows does not use the crate; nix runs at the end of
the stack).
This commit is contained in:
LGUG2Z committed 2026-11-05 15:03:27 -08:00
1 parent 0180d80fa6
commit cce2886622
18 files changed
+38 -110

No files matched your search

Generated
+12 -20
View File
@@ -3661,6 +3661,7 @@ dependencies = [
"komorebi-settings",
"komorebi-themes",
"komorebi-transport",
"komorebi-version",
"lazy_static",
"nanoid 0.5.0",
"parking_lot 0.13.0",
@@ -3676,7 +3677,6 @@ dependencies = [
"tracing-appender",
"tracing-subscriber",
"uuid",
"version-linux",
"zbus 6.1.0",
]
@@ -3705,6 +3705,7 @@ dependencies = [
"komorebi-settings",
"komorebi-themes",
"komorebi-transport",
"komorebi-version",
"lazy_static",
"nanoid 0.4.0",
"objc2 0.6.5",
@@ -3731,7 +3732,6 @@ dependencies = [
"tracing-appender",
"tracing-subscriber",
"uuid",
"version-macos",
]
[[package]]
@@ -3809,6 +3809,13 @@ dependencies = [
"uds_windows",
]
[[package]]
name = "komorebi-version"
version = "0.2.0"
dependencies = [
"shadow-rs 2.0.0",
]
[[package]]
name = "komorebi-windows"
version = "0.2.0"
@@ -3883,6 +3890,7 @@ dependencies = [
"komorebi-config",
"komorebi-hotkeys",
"komorebi-linux",
"komorebi-version",
"komorebic-core",
"lazy_static",
"miette",
@@ -3897,8 +3905,6 @@ dependencies = [
"sysinfo 0.39.6",
"sysinfo 0.40.0",
"thiserror 2.0.21",
"version-linux",
"version-macos",
"which",
"win-msgbox",
"windows 0.62.2",
@@ -3929,12 +3935,12 @@ dependencies = [
"komorebi-config",
"komorebi-hotkeys",
"komorebi-linux",
"komorebi-version",
"komorebic-core",
"lazy_static",
"schemars 1.2.3",
"serde_json_lenient",
"sysinfo 0.40.0",
"version-linux",
]
[[package]]
@@ -3949,6 +3955,7 @@ dependencies = [
"fs-tail",
"komorebi-client-macos",
"komorebi-config",
"komorebi-version",
"komorebic-core",
"lazy_static",
"reqwest",
@@ -3956,7 +3963,6 @@ dependencies = [
"serde_json_lenient",
"shadow-rs 1.7.1",
"sysinfo 0.38.4",
"version-macos",
]
[[package]]
@@ -7851,20 +7857,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version-linux"
version = "0.2.0"
dependencies = [
"shadow-rs 2.0.0",
]
[[package]]
name = "version-macos"
version = "0.2.0"
dependencies = [
"shadow-rs 1.7.1",
]
[[package]]
name = "version_check"
version = "0.9.5"
+1 -2
View File
@@ -30,12 +30,11 @@ members = [
"komorebi-for-kde/komorebic",
"komorebi-for-kde/komorebi-client",
"komorebi-for-kde/komorebi-hotkeys",
"komorebi-for-kde/version",
"komorebi-for-mac/komorebi",
"komorebi-for-mac/komorebic",
"komorebi-for-mac/komorebi-client",
"komorebi-for-mac/komorebi-bar",
"komorebi-for-mac/version",
"crates/komorebi-version",
]
default-members = [
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "komorebi-version"
description = "The version string that the Linux and macOS komorebi binaries report"
version.workspace = true
edition = "2024"
[dependencies]
shadow-rs = { workspace = true }
[build-dependencies]
shadow-rs = { workspace = true }
[lib]
name = "version"
File renamed without changes.
File renamed without changes.
+3 -9
View File
@@ -13,15 +13,9 @@ fn reports_the_package_version() {
assert!(output.status.success());
let stdout = String::from_utf8(output.stdout).expect("utf-8 output");
// the version the KDE daemon reports is that of the KDE `version` crate (the workspace version of
// komorebi for KDE), not of this package, which is shared with the other platforms
let manifest = include_str!("../../komorebi-for-kde/version/Cargo.toml");
let version = manifest
.lines()
.find_map(|line| line.strip_prefix("version = \""))
.and_then(|rest| rest.strip_suffix('"'))
.expect("the version crate has a version");
let expected = format!("komorebi {version}");
// every package of the workspace has the workspace version, so this package's is the one the
// `komorebi-version` crate reports
let expected = format!("komorebi {}", env!("CARGO_PKG_VERSION"));
assert_eq!(stdout.lines().next(), Some(expected.as_str()));
}
+1 -1
View File
@@ -79,7 +79,7 @@ expression = "LicenseRef-Komorebi-2.0"
license-files = []
[[licenses.clarify]]
crate = "version-linux"
crate = "komorebi-version"
expression = "LicenseRef-Komorebi-2.0"
license-files = []
+1 -1
View File
@@ -20,7 +20,7 @@ komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features
"schemars",
] }
komorebi-transport = { path = "../../crates/komorebi-transport" }
version = { package = "version-linux", path = "../version" }
version = { package = "komorebi-version", path = "../../crates/komorebi-version" }
clap = { version = "4", features = ["derive", "wrap_help"] }
color-eyre = { version = "0.6" }
+1 -1
View File
@@ -12,7 +12,7 @@ komorebi = { package = "komorebi-linux", path = "../komorebi", default-features
komorebi-client = { package = "komorebi-client-linux", path = "../komorebi-client", default-features = false }
komorebi-hotkeys = { path = "../komorebi-hotkeys" }
komorebic-core = { path = "../../crates/komorebic-core" }
version = { package = "version-linux", path = "../version" }
version = { package = "komorebi-version", path = "../../crates/komorebi-version" }
clap = { version = "4", features = ["derive", "wrap_help"] }
clap_complete = "4"
-13
View File
@@ -1,13 +0,0 @@
[package]
name = "version-linux"
edition = "2024"
version.workspace = true
[dependencies]
shadow-rs = { version = "2" }
[build-dependencies]
shadow-rs = { version = "2" }
[lib]
name = "version"
+1 -1
View File
@@ -84,7 +84,7 @@ expression = "LicenseRef-Komorebi-2.0"
license-files = []
[[licenses.clarify]]
crate = "version-macos"
crate = "komorebi-version"
expression = "LicenseRef-Komorebi-2.0"
license-files = []
+1 -1
View File
@@ -22,7 +22,7 @@ komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features
] }
komorebi-transport = { path = "../../crates/komorebi-transport" }
quickxml_to_serde = { git = "https://github.com/LGUG2Z/quickxml_to_serde.git", version = "0.6.1" }
version = { package = "version-macos", path = "../version" }
version = { package = "komorebi-version", path = "../../crates/komorebi-version" }
base64 = "0.22"
block2 = "0.6"
+1 -1
View File
@@ -10,7 +10,7 @@ komorebi-config = { path = "../../crates/komorebi-config", default-features = fa
] }
komorebi-client = { package = "komorebi-client-macos", path = "../komorebi-client", default-features = false }
komorebic-core = { path = "../../crates/komorebic-core" }
version = { package = "version-macos", path = "../version" }
version = { package = "komorebi-version", path = "../../crates/komorebi-version" }
clap = { version = "4", features = ["derive", "wrap_help"] }
clap_complete = "4"
-13
View File
@@ -1,13 +0,0 @@
[package]
name = "version-macos"
edition = "2024"
version.workspace = true
[dependencies]
shadow-rs = { version = "1" }
[build-dependencies]
shadow-rs = { version = "1" }
[lib]
name = "version"
-40
View File
@@ -1,40 +0,0 @@
use std::fs::File;
use std::io::Write;
use shadow_rs::SdResult;
use shadow_rs::ShadowBuilder;
fn main() {
let shadow_build = ShadowBuilder::builder().hook(raw_hook).build().unwrap();
let is_flake_build = shadow_build
.map
.get("BRANCH")
.map_or_else(|| true, |entry| entry.v.is_empty());
if is_flake_build {
ShadowBuilder::builder().hook(flake_hook).build().unwrap();
}
}
const RAW_VERSION_CONST: &str = r##"pub const LONG_VERSION:&str = shadow_rs::formatcp!(r#"{}
branch:{}
commit_hash:{}
build_env:{},{}"#,PKG_VERSION, BRANCH, COMMIT_HASH, RUST_VERSION, RUST_CHANNEL
);
"##;
fn raw_hook(mut file: &File) -> SdResult<()> {
writeln!(file, "{RAW_VERSION_CONST}")?;
Ok(())
}
const FLAKE_VERSION_CONST: &str = r##"pub const LONG_VERSION:&str = shadow_rs::formatcp!(r#"{}
commit_hash:{}
build_env:{},{}"#,PKG_VERSION, env!("COMMIT_HASH"), RUST_VERSION, RUST_CHANNEL
);"##;
fn flake_hook(mut file: &File) -> SdResult<()> {
writeln!(file, "{FLAKE_VERSION_CONST}")?;
Ok(())
}
-3
View File
@@ -1,3 +0,0 @@
shadow_rs::shadow!(build);
pub use build::LONG_VERSION;
+2 -2
View File
@@ -42,12 +42,12 @@ windows = { workspace = true }
[target.'cfg(target_os = "linux")'.dependencies]
komorebi-linux = { package = "komorebi-linux", path = "../komorebi-for-kde/komorebi", default-features = false }
komorebi-hotkeys = { path = "../komorebi-for-kde/komorebi-hotkeys" }
version-linux = { package = "version-linux", path = "../komorebi-for-kde/version" }
version = { package = "komorebi-version", path = "../crates/komorebi-version" }
clap_complete = "4"
sysinfo = "0.40"
[target.'cfg(target_os = "macos")'.dependencies]
version-macos = { package = "version-macos", path = "../komorebi-for-mac/version" }
version = { package = "komorebi-version", path = "../crates/komorebi-version" }
clap_complete = "4"
reqwest = { version = "0.12", features = ["blocking"] }
sysinfo = "0.38"
-2
View File
@@ -12,12 +12,10 @@ cfg_select! {
}
target_os = "linux" => {
extern crate komorebi_linux as komorebi;
extern crate version_linux as version;
mod linux;
use linux as platform;
}
target_os = "macos" => {
extern crate version_macos as version;
mod macos;
use macos as platform;
}