From b21161b7bd9159dc8f1967035e2c15ded0460f43 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 17 Dec 2024 16:51:55 -0500 Subject: [PATCH] build-sys: Drop custom version glue code It was annoying me that rust-analyzer was showing an error for our `version.rs`. Something we're doing there is wrong, maybe related to the output directory? But when I dig in a bit I don't understand how we ended up with this custom code when the clap docs show use of the `clap::crate_version` macro which looks just fine to me. Not having a `build.rs` just simplifies things. Signed-off-by: Colin Walters --- lib/Cargo.toml | 1 - lib/build.rs | 22 ---------------------- lib/src/cli.rs | 4 +--- 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 lib/build.rs diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 12af3d64b..793aafcba 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -9,7 +9,6 @@ version = "1.1.3" # For now don't bump this above what is currently shipped in RHEL9; # also keep in sync with the version in cli. rust-version = "1.75.0" -build = "build.rs" include = ["/src", "LICENSE-APACHE", "LICENSE-MIT"] diff --git a/lib/build.rs b/lib/build.rs deleted file mode 100644 index 54746b354..000000000 --- a/lib/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! Our build script, which basically today just generates a version. - -use std::env; -use std::fs; -use std::path::Path; - -fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join("version.rs"); - fs::write( - dest_path, - " - #[allow(dead_code)] - #[allow(clippy::all)] - use clap::crate_version; - #[doc=r#\"Version string\"#] - pub const CLAP_LONG_VERSION: &str = crate_version!(); - ", - ) - .unwrap(); - println!("cargo:rerun-if-changed=build.rs"); -} diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 8e429fe93..87dbb2865 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -32,8 +32,6 @@ use crate::spec::Host; use crate::spec::ImageReference; use crate::utils::sigpolicy_from_opts; -include!(concat!(env!("OUT_DIR"), "/version.rs")); - /// Perform an upgrade operation #[derive(Debug, Parser, PartialEq, Eq)] pub(crate) struct UpgradeOpts { @@ -398,7 +396,7 @@ impl InternalsOpts { #[derive(Debug, Parser, PartialEq, Eq)] #[clap(name = "bootc")] #[clap(rename_all = "kebab-case")] -#[clap(version,long_version=CLAP_LONG_VERSION)] +#[clap(version,long_version=clap::crate_version!())] #[allow(clippy::large_enum_variant)] pub(crate) enum Opt { /// Download and queue an updated container image to apply.