Commit 5c9176a9 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 fbb8a511
......@@ -8,7 +8,9 @@
REPO_PARENT=../..
-include $(REPO_PARENT)/parent_common.mk
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS = -Wall -ggdb -O2 -I../kernel/include $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
PROGS = fru-dump fmc-mem
all: $(PROGS)
......
......@@ -17,12 +17,15 @@
#include <sys/types.h>
#include <sys/stat.h>
static char git_version[] = "git version: " GIT_VERSION;
static void help(char *prgname)
{
fprintf(stderr, "%s: use "
"\"%s <device> <addr> [<value>] [+<nbytes>]\"\n"
"\"%s -V <device> <addr> [<value>] [+<nbytes>]\"\n"
" <device> is a file name, all others are hex numbers\n"
" bursts of \"nbytes\" use stdin/stdout (value ignored)\n",
" bursts of \"nbytes\" use stdin/stdout (value ignored)\n"
" -V version\n",
prgname, prgname);
exit(1);
}
......@@ -67,6 +70,11 @@ static void r_loop(int fd, char **argv, int nbytes)
exit(0);
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv)
{
int fd;
......@@ -75,6 +83,11 @@ int main(int argc, char **argv)
int dowrite = 0, doloop = 0;
char c;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 3 || argv[1][0] == '-') /* -h, --help, whatever */
help(argv[0]);
......
......@@ -18,11 +18,18 @@
#include "../kernel/fru-parse.c" /* Aaaargh!!!!! horrible hack... */
static char git_version[] = "git version: " GIT_VERSION;
void *fru_alloc(size_t size)
{
return malloc(size);
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
#define EEPROM_SIZE 8192
int main(int argc, char **argv)
......@@ -35,8 +42,13 @@ int main(int argc, char **argv)
FILE *f = NULL;
int i, err = 0;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 2) {
fprintf(stderr, "%s: Use \"%s <fru-image> [...]\"\n",
fprintf(stderr, "%s: Use \"%s [-V] <fru-image> [...]\"\n",
argv[0], argv[0]);
exit(1);
}
......
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