From bf7c4e165946f7a5be48c9d7e8abb8e68f066882 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Mon, 4 Dec 2023 20:54:18 -0500 Subject: use workspace inheritance for common version (#8925) --- helix-loader/Cargo.toml | 12 ++++++------ helix-loader/build.rs | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'helix-loader') diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml index b32318d0..1a98e94b 100644 --- a/helix-loader/Cargo.toml +++ b/helix-loader/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "helix-loader" -version = "0.6.0" -description = "A post-modern text editor." -authors = ["Blaž Hrastnik "] +description = "Build bootstrapping for Helix crates" +version.workspace = true +authors.workspace = true edition.workspace = true license.workspace = true rust-version.workspace = true -categories = ["editor"] -repository = "https://github.com/helix-editor/helix" -homepage = "https://helix-editor.com" +categories.workspace = true +repository.workspace = true +homepage.workspace = true [[bin]] name = "hx-loader" diff --git a/helix-loader/build.rs b/helix-loader/build.rs index 74ba2a2b..a4562c00 100644 --- a/helix-loader/build.rs +++ b/helix-loader/build.rs @@ -2,7 +2,17 @@ use std::borrow::Cow; use std::path::Path; use std::process::Command; -const VERSION: &str = include_str!("../VERSION"); +const MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR"); +const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR"); +const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH"); + +fn get_calver() -> String { + if PATCH == "0" { + format!("{MAJOR}.{MINOR}") + } else { + format!("{MAJOR}.{MINOR}.{PATCH}") + } +} fn main() { let git_hash = Command::new("git") @@ -12,9 +22,10 @@ fn main() { .filter(|output| output.status.success()) .and_then(|x| String::from_utf8(x.stdout).ok()); + let calver = get_calver(); let version: Cow<_> = match &git_hash { - Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(), - None => VERSION.into(), + Some(git_hash) => format!("{} ({})", calver, &git_hash[..8]).into(), + None => calver.into(), }; println!( @@ -22,7 +33,6 @@ fn main() { std::env::var("TARGET").unwrap() ); - println!("cargo:rerun-if-changed=../VERSION"); println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); if git_hash.is_none() { -- cgit v1.2.3-70-g09d2