version command: make it scriptable
you can now set a variable in a script like set version [version]. Also version takes an optional argument "git" to show git version of source. If git is not installed during the build, then this will yield an error that is ignored during the build and "version git" returns an empty string. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
This commit is contained in:
parent
ac86f4ccba
commit
505d4633cd
|
@ -44,6 +44,7 @@ libopenocd_la_CPPFLAGS += -DRELSTR=\"\"
|
||||||
else
|
else
|
||||||
libopenocd_la_CPPFLAGS += -DRELSTR=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
|
libopenocd_la_CPPFLAGS += -DRELSTR=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
|
||||||
endif
|
endif
|
||||||
|
libopenocd_la_CPPFLAGS += -DGITVERSION=\"`cd $(top_srcdir) && git describe`\"
|
||||||
|
|
||||||
# add default CPPFLAGS
|
# add default CPPFLAGS
|
||||||
libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
|
libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) 2005 by Dominic Rath *
|
* Copyright (C) 2005 by Dominic Rath *
|
||||||
* Dominic.Rath@gmx.de *
|
* Dominic.Rath@gmx.de *
|
||||||
* *
|
* *
|
||||||
* Copyright (C) 2007,2008 Øyvind Harboe *
|
* Copyright (C) 2007-2010 Øyvind Harboe *
|
||||||
* oyvind.harboe@zylin.com *
|
* oyvind.harboe@zylin.com *
|
||||||
* *
|
* *
|
||||||
* Copyright (C) 2008 Richard Missenden *
|
* Copyright (C) 2008 Richard Missenden *
|
||||||
|
@ -52,15 +52,29 @@
|
||||||
#define OPENOCD_VERSION \
|
#define OPENOCD_VERSION \
|
||||||
"Open On-Chip Debugger " VERSION RELSTR " (" PKGBLDDATE ")"
|
"Open On-Chip Debugger " VERSION RELSTR " (" PKGBLDDATE ")"
|
||||||
|
|
||||||
/* Give TELNET a way to find out what version this is */
|
/* Give scripts and TELNET a way to find out what version this is */
|
||||||
COMMAND_HANDLER(handle_version_command)
|
static int jim_version_command(Jim_Interp *interp, int argc,
|
||||||
|
Jim_Obj * const *argv)
|
||||||
{
|
{
|
||||||
if (CMD_ARGC != 0)
|
if (argc > 2)
|
||||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
{
|
||||||
|
return JIM_ERR;
|
||||||
|
}
|
||||||
|
const char *str = "";
|
||||||
|
char * version_str;
|
||||||
|
version_str = OPENOCD_VERSION;
|
||||||
|
|
||||||
command_print(CMD_CTX, OPENOCD_VERSION);
|
if (argc == 2)
|
||||||
|
str = Jim_GetString(argv[1], NULL);
|
||||||
|
|
||||||
return ERROR_OK;
|
if (strcmp("git", str) == 0)
|
||||||
|
{
|
||||||
|
version_str = GITVERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
Jim_SetResult(interp, Jim_NewStringObj(interp, version_str, -1));
|
||||||
|
|
||||||
|
return JIM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int log_target_callback_event_handler(struct target *target, enum target_event event, void *priv)
|
static int log_target_callback_event_handler(struct target *target, enum target_event event, void *priv)
|
||||||
|
@ -174,7 +188,7 @@ COMMAND_HANDLER(handle_add_script_search_dir_command)
|
||||||
static const struct command_registration openocd_command_handlers[] = {
|
static const struct command_registration openocd_command_handlers[] = {
|
||||||
{
|
{
|
||||||
.name = "version",
|
.name = "version",
|
||||||
.handler = &handle_version_command,
|
.jim_handler = jim_version_command,
|
||||||
.mode = COMMAND_ANY,
|
.mode = COMMAND_ANY,
|
||||||
.help = "show program version",
|
.help = "show program version",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue