diff --git a/Cargo.lock b/Cargo.lock index c23cb4b2..de187233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index c71a638a..b32d2555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = [ diff --git a/crates/komorebi-version/Cargo.toml b/crates/komorebi-version/Cargo.toml new file mode 100644 index 00000000..dc954782 --- /dev/null +++ b/crates/komorebi-version/Cargo.toml @@ -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" diff --git a/komorebi-for-kde/version/build.rs b/crates/komorebi-version/build.rs similarity index 100% rename from komorebi-for-kde/version/build.rs rename to crates/komorebi-version/build.rs diff --git a/komorebi-for-kde/version/src/lib.rs b/crates/komorebi-version/src/lib.rs similarity index 100% rename from komorebi-for-kde/version/src/lib.rs rename to crates/komorebi-version/src/lib.rs diff --git a/komorebi-daemon/tests/linux_version.rs b/komorebi-daemon/tests/linux_version.rs index fd627c96..cd48fab4 100644 --- a/komorebi-daemon/tests/linux_version.rs +++ b/komorebi-daemon/tests/linux_version.rs @@ -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())); } diff --git a/komorebi-for-kde/deny.toml b/komorebi-for-kde/deny.toml index a474e33a..f1702518 100644 --- a/komorebi-for-kde/deny.toml +++ b/komorebi-for-kde/deny.toml @@ -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 = [] diff --git a/komorebi-for-kde/komorebi/Cargo.toml b/komorebi-for-kde/komorebi/Cargo.toml index f9527b5d..29971a87 100644 --- a/komorebi-for-kde/komorebi/Cargo.toml +++ b/komorebi-for-kde/komorebi/Cargo.toml @@ -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" } diff --git a/komorebi-for-kde/komorebic/Cargo.toml b/komorebi-for-kde/komorebic/Cargo.toml index 30d60cdc..7740edf0 100644 --- a/komorebi-for-kde/komorebic/Cargo.toml +++ b/komorebi-for-kde/komorebic/Cargo.toml @@ -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" diff --git a/komorebi-for-kde/version/Cargo.toml b/komorebi-for-kde/version/Cargo.toml deleted file mode 100644 index b810aec5..00000000 --- a/komorebi-for-kde/version/Cargo.toml +++ /dev/null @@ -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" diff --git a/komorebi-for-mac/deny.toml b/komorebi-for-mac/deny.toml index 8fb6302c..17252297 100644 --- a/komorebi-for-mac/deny.toml +++ b/komorebi-for-mac/deny.toml @@ -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 = [] diff --git a/komorebi-for-mac/komorebi/Cargo.toml b/komorebi-for-mac/komorebi/Cargo.toml index 08052a15..9d280a7a 100644 --- a/komorebi-for-mac/komorebi/Cargo.toml +++ b/komorebi-for-mac/komorebi/Cargo.toml @@ -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" diff --git a/komorebi-for-mac/komorebic/Cargo.toml b/komorebi-for-mac/komorebic/Cargo.toml index 40da0276..c3ee2259 100644 --- a/komorebi-for-mac/komorebic/Cargo.toml +++ b/komorebi-for-mac/komorebic/Cargo.toml @@ -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" diff --git a/komorebi-for-mac/version/Cargo.toml b/komorebi-for-mac/version/Cargo.toml deleted file mode 100644 index 4f941efd..00000000 --- a/komorebi-for-mac/version/Cargo.toml +++ /dev/null @@ -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" diff --git a/komorebi-for-mac/version/build.rs b/komorebi-for-mac/version/build.rs deleted file mode 100644 index 1b80c0a1..00000000 --- a/komorebi-for-mac/version/build.rs +++ /dev/null @@ -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(()) -} diff --git a/komorebi-for-mac/version/src/lib.rs b/komorebi-for-mac/version/src/lib.rs deleted file mode 100644 index b537c9ce..00000000 --- a/komorebi-for-mac/version/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -shadow_rs::shadow!(build); - -pub use build::LONG_VERSION; diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index 059014ef..3734f5ec 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -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" diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 97ddef85..c56c56ad 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -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; }