Commit a611ee27 authored by Adam Wujek's avatar Adam Wujek 💬

tools: add printing version of repo

with -V switch
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent fe6c90a5
......@@ -9,11 +9,12 @@
REPO_PARENT=../..
-include $(REPO_PARENT)/parent_common.mk
M = $(shell /bin/pwd)/../kernel
DESTDIR ?= /usr/local
CFLAGS += -I$(M) -I../lib -Wno-trigraphs -Wall -ggdb $(EXTRACFLAGS)
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -I../kernel -I../lib -Wno-trigraphs -Wall -ggdb $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
LDFLAGS = -L../lib
LDLIBS = -lfdelay
......
......@@ -8,11 +8,13 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "fmc-fdelay-board-time: a tool for manipulating the FMC Fine Delay time base.\n");
fprintf(stderr, "Use: \"%s [-i <index>] [-d <dev>] <command>\"\n",
fprintf(stderr, "Use: \"%s [-V] [-i <index>] [-d <dev>] <command>\"\n",
name);
fprintf(stderr, " where the <command> can be:\n"
" get - shows current time and White Rabbit status.\n"
......@@ -37,6 +39,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
nboards = fdelay_init();
if (nboards < 0) {
......
......@@ -11,9 +11,11 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "%s: Use \"%s [-i <index>] [-d <dev>] [<opts>]\n",
fprintf(stderr, "%s: Use \"%s [-V] [-i <index>] [-d <dev>] [<opts>]\n",
name, name);
fprintf(stderr, " options:\n"
" -c <count> default is 0 and means forever\n"
......@@ -49,6 +51,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
nboards = fdelay_init();
if (nboards < 0) {
......
......@@ -9,9 +9,12 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "%s: Lists boards, takes no arguments\n", name);
fprintf(stderr, "%s: Lists boards\n"
" -V print version\n", name);
exit(1);
}
......@@ -24,6 +27,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
if (argc > 1) {
fprintf(stderr, "%s: too many arguments (none expected)\n",
argv[0]);
......
......@@ -13,9 +13,11 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "%s: Use \"%s [-i <index>] [-d <dev>] [<opts>]\n",
fprintf(stderr, "%s: Use \"%s [-V] [-i <index>] [-d <dev>] [<opts>]\n",
name, name);
fprintf(stderr, " options:\n"
" -o <output> ouput channel: 1..4 (default 1)\n"
......@@ -223,6 +225,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
nboards = fdelay_init();
if (nboards < 0) {
......
......@@ -8,11 +8,13 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "fmc-fdelay-status: reports channel programming\n");
fprintf(stderr, "Use: \"%s [-i <index>] [-d <dev>] [-r]\"\n", name);
fprintf(stderr, "Use: \"%s [-V] [-i <index>] [-d <dev>] [-r]\"\n", name);
fprintf(stderr, " -r: display raw hardware configuration");
exit(1);
}
......@@ -27,6 +29,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
nboards = fdelay_init();
if (nboards < 0) {
......
......@@ -8,9 +8,11 @@
#include "tools-common.h"
char git_version[] = "git version: " GIT_VERSION;
void help(char *name)
{
fprintf(stderr, "%s: Use \"%s [-i <index>] [-d <dev>] [on|off]\n",
fprintf(stderr, "%s: Use \"%s [-V] [-i <index>] [-d <dev>] [on|off]\n",
name, name);
exit(1);
}
......@@ -26,6 +28,9 @@ int main(int argc, char **argv)
if (tools_need_help(argc, argv))
help(argv[0]);
/* print versions if needed */
print_version(argc, argv);
nboards = fdelay_init();
if (nboards < 0) {
......
......@@ -14,3 +14,5 @@ extern void tools_report_time(char *name, struct fdelay_time *t, int umode);
extern void report_output_config(int channel, struct fdelay_pulse *p, int umode);
extern void help(char *name); /* This is mandatory in all tools */
extern void print_version(int argc, char **argv);
......@@ -8,6 +8,18 @@
#include "tools-common.h"
extern void help(char *name); /* This is mandatory in all tools */
extern char git_version[];
void print_version(int argc, char **argv)
{
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
printf("%s %s\n", argv[0], git_version);
printf("%s\n", libfdelay_version_s);
printf("%s\n", libfdelay_zio_version_s);
exit(0);
}
}
void tools_getopt_d_i(int argc, char **argv,
int *dev, int *index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment