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