Files
komorebi/crates/komorebi-version/build.rs
T
LGUG2Z cce2886622 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).
2026-11-05 15:03:27 -08:00

41 lines
1.0 KiB
Rust

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(())
}