]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: Add Version information to command line tool
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 11:32:35 +0000 (13:32 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 18:08:56 +0000 (20:08 +0200)
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 <jan.kiszka@siemens.com>
tools/Makefile
tools/jailhouse.c

index 13fc67175e22e6c2313f8453b2dec8cb590d6fb1..879465aeba0f5ed80b12a46260163ac60fbdbd90 100644 (file)
@@ -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
 
index 11e2ddebec3e0ecfe4c0478a1e65c2c63d2fbb95..9a65b41005359361f64c0c8139f57e4285168676 100644 (file)
@@ -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;
 }