From 01b144df2ffbad6c12fe37dd16ec1416af4a42a5 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Thu, 28 Aug 2014 13:32:35 +0200 Subject: [PATCH] tools: Add Version information to command line tool Dump the static version tag from the management tool when invoked with "--version". We don't need precise git-based tracking here as interfaces are fairly decoupled now. Signed-off-by: Jan Kiszka --- tools/Makefile | 3 ++- tools/jailhouse.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 13fc671..879465a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -31,7 +31,8 @@ INSTALL_DIR ?= $(INSTALL) -d -m 755 CC = $(CROSS_COMPILE)gcc CFLAGS = -g -O3 -I.. -DLIBEXECDIR=\"$(libexecdir)\" \ - -Wall -Wmissing-declarations -Wmissing-prototypes + -Wall -Wmissing-declarations -Wmissing-prototypes \ + -DJAILHOUSE_VERSION=\"$(shell cat ../VERSION)\" TARGETS := jailhouse diff --git a/tools/jailhouse.c b/tools/jailhouse.c index 11e2dde..9a65b41 100644 --- a/tools/jailhouse.c +++ b/tools/jailhouse.c @@ -46,7 +46,7 @@ static void __attribute__((noreturn)) help(char *prog, int exit_status) { const struct extension *ext; - printf("Usage: %s { COMMAND | --help }\n" + printf("Usage: %s { COMMAND | --help || --version }\n" "\nAvailable commands:\n" " enable SYSCONFIG\n" " disable\n" @@ -363,10 +363,14 @@ int main(int argc, char *argv[]) } else if (strcmp(argv[1], "config") == 0) { call_extension_script(argv[1], argc, argv); help(argv[0], 1); + } else if (strcmp(argv[1], "--version") == 0) { + printf("Jailhouse management tool %s\n", JAILHOUSE_VERSION); + return 0; } else if (strcmp(argv[1], "--help") == 0) { help(argv[0], 0); - } else + } else { help(argv[0], 1); + } return err ? 1 : 0; } -- 2.39.2