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

tools: add printing version of the repo

with -V switch
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent bc0e12b9
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
REPO_PARENT=../.. REPO_PARENT=../..
-include $(REPO_PARENT)/parent_common.mk -include $(REPO_PARENT)/parent_common.mk
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -ggdb -Wall -fPIC -I../kernel $(EXTRACFLAGS) CFLAGS += -ggdb -Wall -fPIC -I../kernel $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
LIB = libspec.a LIB = libspec.a
LIBOBJ = speclib.o loader-ll.o LIBOBJ = speclib.o loader-ll.o
......
...@@ -9,6 +9,14 @@ ...@@ -9,6 +9,14 @@
#include "speclib.h" #include "speclib.h"
static char git_version[] = "version: " GIT_VERSION;
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libspec_version_s);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int bus = -1, dev_fn = -1, c; int bus = -1, dev_fn = -1, c;
...@@ -16,7 +24,7 @@ int main(int argc, char **argv) ...@@ -16,7 +24,7 @@ int main(int argc, char **argv)
void *card; void *card;
while ((c = getopt (argc, argv, "b:d:c:")) != -1) while ((c = getopt (argc, argv, "b:d:c:V")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -29,9 +37,12 @@ int main(int argc, char **argv) ...@@ -29,9 +37,12 @@ int main(int argc, char **argv)
case 'c': case 'c':
sscanf(optarg, "%i", &lm32_base); sscanf(optarg, "%i", &lm32_base);
break; break;
case 'V':
print_version(argv[0]);
exit(0);
default: default:
fprintf(stderr, fprintf(stderr,
"Use: \"%s [-b bus] [-d devfn] " "Use: \"%s [-V] [-b bus] [-d devfn] "
"[-c lm32 base address] <lm32_program.bin>\"\n", "[-c lm32 base address] <lm32_program.bin>\"\n",
argv[0]); argv[0]);
fprintf(stderr, fprintf(stderr,
......
...@@ -9,12 +9,20 @@ ...@@ -9,12 +9,20 @@
#include "speclib.h" #include "speclib.h"
static char git_version[] = "version: " GIT_VERSION;
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libspec_version_s);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int bus = -1, dev_fn = -1, c; int bus = -1, dev_fn = -1, c;
void *card; void *card;
while ((c = getopt (argc, argv, "b:d:")) != -1) while ((c = getopt (argc, argv, "b:d:V")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -24,9 +32,12 @@ int main(int argc, char **argv) ...@@ -24,9 +32,12 @@ int main(int argc, char **argv)
case 'd': case 'd':
sscanf(optarg, "%i", &dev_fn); sscanf(optarg, "%i", &dev_fn);
break; break;
case 'V':
print_version(argv[0]);
exit(0);
default: default:
fprintf(stderr, fprintf(stderr,
"Use: \"%s [-b bus] [-d devfn] " "Use: \"%s [-V] [-b bus] [-d devfn] "
"<fpga_bitstream.bin>\"\n", argv[0]); "<fpga_bitstream.bin>\"\n", argv[0]);
fprintf(stderr, "By default, the first available SPEC " fprintf(stderr, "By default, the first available SPEC "
"is used.\n"); "is used.\n");
......
...@@ -14,6 +14,14 @@ ...@@ -14,6 +14,14 @@
#include "speclib.h" #include "speclib.h"
static char git_version[] = "version: " GIT_VERSION;
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libspec_version_s);
}
static void *card; static void *card;
static int transfer_byte(int from, int is_control) { static int transfer_byte(int from, int is_control) {
...@@ -89,7 +97,7 @@ int main(int argc, char **argv) ...@@ -89,7 +97,7 @@ int main(int argc, char **argv)
uint32_t vuart_base = 0x20500; uint32_t vuart_base = 0x20500;
int keep_term = 0; int keep_term = 0;
while ((c = getopt (argc, argv, "b:d:u:k")) != -1) while ((c = getopt (argc, argv, "b:d:u:kV")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -105,9 +113,12 @@ int main(int argc, char **argv) ...@@ -105,9 +113,12 @@ int main(int argc, char **argv)
case 'k': case 'k':
keep_term = 1; keep_term = 1;
break; break;
case 'V':
print_version(argv[0]);
exit(0);
default: default:
fprintf(stderr, fprintf(stderr,
"Use: \"%s [-b bus] [-d devfn] " "Use: \"%s [-V] [-b bus] [-d devfn] "
"[-u VUART base] [-k]\"\n", argv[0]); "[-u VUART base] [-k]\"\n", argv[0]);
fprintf(stderr, fprintf(stderr,
"By default, the first available SPEC " "By default, the first available SPEC "
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "loader-ll.h" #include "loader-ll.h"
#include "wb_uart.h" #include "wb_uart.h"
const char * const libspec_version_s = "libspec version: " GIT_VERSION;
struct spec_private { struct spec_private {
/* BAR0 maps the local bus (i.e. we can access FGPA register) */ /* BAR0 maps the local bus (i.e. we can access FGPA register) */
void *bar0; void *bar0;
......
...@@ -49,4 +49,6 @@ enum { ...@@ -49,4 +49,6 @@ enum {
BASE_BAR4 = 4 /* for gennum-internal registers */ BASE_BAR4 = 4 /* for gennum-internal registers */
}; };
/* libspec version string */
extern const char * const libspec_version_s;
#endif #endif
...@@ -15,15 +15,23 @@ ...@@ -15,15 +15,23 @@
#include "speclib.h" #include "speclib.h"
static char git_version[] = "version: " GIT_VERSION;
void help(char *name) void help(char *name)
{ {
fprintf(stderr, fprintf(stderr,
"Use: \"%s [-b bus] [-d devfn] [-g] <offset> [<value>]\"\n", "Use: \"%s [-V] [-b bus] [-d devfn] [-g] <offset> [<value>]\"\n",
name); name);
fprintf(stderr, "By default, the first available SPEC is used.\n"); fprintf(stderr, "By default, the first available SPEC is used.\n");
exit(1); exit(1);
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libspec_version_s);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i, bar = BASE_BAR0; int i, bar = BASE_BAR0;
...@@ -35,7 +43,7 @@ int main(int argc, char **argv) ...@@ -35,7 +43,7 @@ int main(int argc, char **argv)
void *map_base; void *map_base;
char *end; char *end;
while ((c = getopt (argc, argv, "b:d:g")) != -1) while ((c = getopt (argc, argv, "b:d:gV")) != -1)
{ {
switch(c) switch(c)
{ {
...@@ -48,6 +56,9 @@ int main(int argc, char **argv) ...@@ -48,6 +56,9 @@ int main(int argc, char **argv)
case 'g': case 'g':
bar = BASE_BAR4; bar = BASE_BAR4;
break; break;
case 'V':
print_version(argv[0]);
exit(0);
default: default:
help(argv[0]); help(argv[0]);
} }
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
# define ETH_P_1588 0x88F7 # define ETH_P_1588 0x88F7
#endif #endif
static char git_version[] = "version: " GIT_VERSION;
/* This structure is used to collect stamping information */ /* This structure is used to collect stamping information */
struct ts_data { struct ts_data {
struct timespec ns; struct timespec ns;
...@@ -400,6 +402,11 @@ void recv_one_with_followup(int sock, struct frame *f, unsigned char *mac, ...@@ -400,6 +402,11 @@ void recv_one_with_followup(int sock, struct frame *f, unsigned char *mac,
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
static struct frame f; static struct frame f;
...@@ -408,6 +415,11 @@ int main(int argc, char **argv) ...@@ -408,6 +415,11 @@ int main(int argc, char **argv)
int listenmode = 0; int listenmode = 0;
int howto = SOF_TIMESTAMPING_MASK; /* everything */ int howto = SOF_TIMESTAMPING_MASK; /* everything */
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
/* From ./net_tstamp.h, these are the "howto" values /* From ./net_tstamp.h, these are the "howto" values
* *
* SOF_TIMESTAMPING_TX_HARDWARE = 1, * SOF_TIMESTAMPING_TX_HARDWARE = 1,
...@@ -424,7 +436,7 @@ int main(int argc, char **argv) ...@@ -424,7 +436,7 @@ int main(int argc, char **argv)
argc--; argc--;
} }
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "%s: Use \"%s <ifname> [listen]\n", argv[0], fprintf(stderr, "%s: Use \"%s [-V] <ifname> [listen]\n", argv[0],
argv[0]); argv[0]);
exit(1); exit(1);
} }
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "wr_nic/wr-nic.h" #include "wr_nic/wr-nic.h"
#include "wr-dio.h" #include "wr-dio.h"
static char git_version[] = "version: " GIT_VERSION;
#define RULER_PROTO 0x5752 /* WR */ #define RULER_PROTO 0x5752 /* WR */
/* /*
...@@ -90,6 +92,11 @@ static int agent_open_wr_sock(char *name) ...@@ -90,6 +92,11 @@ static int agent_open_wr_sock(char *name)
return 0; return 0;
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
/* And a simple main with the loop inside */ /* And a simple main with the loop inside */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -101,8 +108,13 @@ int main(int argc, char **argv) ...@@ -101,8 +108,13 @@ int main(int argc, char **argv)
struct wr_dio_cmd cmd; struct wr_dio_cmd cmd;
} f; } f;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "%s: Use \"%s <wr-if>\"\n", fprintf(stderr, "%s: Use \"%s [-V] <wr-if>\"\n",
argv[0], argv[0]); argv[0], argv[0]);
exit(1); exit(1);
} }
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "wr_nic/wr-nic.h" #include "wr_nic/wr-nic.h"
#include "wr-dio.h" #include "wr-dio.h"
static char git_version[] = "version: " GIT_VERSION;
char *prgname; char *prgname;
char c; char c;
int sock; int sock;
...@@ -306,17 +308,28 @@ static int scan_inout(int argc, char **argv) ...@@ -306,17 +308,28 @@ static int scan_inout(int argc, char **argv)
return 0; return 0;
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
prgname = argv[0]; prgname = argv[0];
argv++, argc--; argv++, argc--;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "%s: use \"%s <netdev> <cmd> [...]\"\n", fprintf(stderr, "%s: use \"%s [-V] <netdev> <cmd> [...]\"\n",
prgname, prgname); prgname, prgname);
exit(1); exit(1);
} }
ifname = argv[0]; ifname = argv[0];
argv++, argc--; argv++, argc--;
......
...@@ -31,6 +31,13 @@ ...@@ -31,6 +31,13 @@
* that gives a more accurate precision. * that gives a more accurate precision.
**/ **/
static char git_version[] = "version: " GIT_VERSION;
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct wr_dio_cmd _cmd; struct wr_dio_cmd _cmd;
...@@ -41,6 +48,11 @@ int main(int argc, char **argv) ...@@ -41,6 +48,11 @@ int main(int argc, char **argv)
int sock, ch, charg = 1; int sock, ch, charg = 1;
char c; char c;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 2 || argc > 3) { if (argc < 2 || argc > 3) {
fprintf(stderr, "%s: Use \"%s [<ifname>] <channel>\"\n", fprintf(stderr, "%s: Use \"%s [<ifname>] <channel>\"\n",
prgname, prgname); prgname, prgname);
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "wr_nic/wr-nic.h" #include "wr_nic/wr-nic.h"
#include "wr-dio.h" #include "wr-dio.h"
static char git_version[] = "version: " GIT_VERSION;
#define RULER_PROTO 0x5752 /* WR */ #define RULER_PROTO 0x5752 /* WR */
/* /*
* Lazily, use global variables, so the code has less parameter passing. * Lazily, use global variables, so the code has less parameter passing.
...@@ -291,6 +293,11 @@ static int ruler_run_actions(int nact, struct timespec *ts, ...@@ -291,6 +293,11 @@ static int ruler_run_actions(int nact, struct timespec *ts,
return 0; return 0;
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
/* Finally, a main function to wrap it all */ /* Finally, a main function to wrap it all */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -298,8 +305,13 @@ int main(int argc, char **argv) ...@@ -298,8 +305,13 @@ int main(int argc, char **argv)
struct timespec ts; struct timespec ts;
int inch; int inch;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 4) { if (argc < 4) {
fprintf(stderr, "%s: Use \"%s <wr-if> IN<ch> " fprintf(stderr, "%s: Use \"%s [-V] <wr-if> IN<ch> "
"{L,R}<ch>+<delay-as-decimal> [...]\n", "{L,R}<ch>+<delay-as-decimal> [...]\n",
argv[0], argv[0]); argv[0], argv[0]);
exit(1); 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