From 9a94f1f149a3bb35e7e73b410949814c477fa7e6 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Thu, 13 Apr 2023 23:24:03 -0700 Subject: [PATCH] make: Export VERSION and COMMIT These will be consumed by kata-ctl, so export these so that they can be used to replace variables available to the rust binary. Signed-off-by: Archana Shinde --- src/tools/kata-ctl/Makefile | 8 +++++--- src/tools/kata-ctl/src/ops/version.rs.in | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tools/kata-ctl/Makefile b/src/tools/kata-ctl/Makefile index 60abae34b8..fbbd5c112a 100644 --- a/src/tools/kata-ctl/Makefile +++ b/src/tools/kata-ctl/Makefile @@ -12,10 +12,10 @@ PROJECT_COMPONENT = kata-ctl TARGET = $(PROJECT_COMPONENT) VERSION_FILE := ./VERSION -VERSION := $(shell grep -v ^\# $(VERSION_FILE)) +export VERSION := $(shell grep -v ^\# $(VERSION_FILE)) COMMIT_NO := $(shell git rev-parse HEAD 2>/dev/null || true) COMMIT_NO_SHORT := $(shell git rev-parse --short HEAD 2>/dev/null || true) -COMMIT := $(if $(shell git status --porcelain --untracked-files=no 2>/dev/null || true),${COMMIT_NO}-dirty,${COMMIT_NO}) +export COMMIT := $(if $(shell git status --porcelain --untracked-files=no 2>/dev/null || true),${COMMIT_NO}-dirty,${COMMIT_NO}) # Exported to allow cargo to see it export KATA_CTL_VERSION := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION)) @@ -23,7 +23,9 @@ export KATA_CTL_VERSION := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION)) GENERATED_CODE = src/ops/version.rs GENERATED_REPLACEMENTS= \ - KATA_CTL_VERSION + KATA_CTL_VERSION \ + VERSION \ + COMMIT GENERATED_FILES := $(GENERATED_CODE) diff --git a/src/tools/kata-ctl/src/ops/version.rs.in b/src/tools/kata-ctl/src/ops/version.rs.in index 052eccf168..e4a5db3c94 100644 --- a/src/tools/kata-ctl/src/ops/version.rs.in +++ b/src/tools/kata-ctl/src/ops/version.rs.in @@ -10,6 +10,8 @@ use clap::crate_version; const KATA_CTL_VERSION: &str = "@KATA_CTL_VERSION@"; +pub const VERSION: &str = "@VERSION@"; +pub const COMMIT: &str = "@COMMIT@"; pub fn get() -> Result { if KATA_CTL_VERSION.trim().is_empty() {