diff options
author | Steve Bennett <steveb@workware.net.au> | 2024-09-23 09:23:33 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2025-03-13 10:26:16 +1000 |
commit | 858583c46deffd91cb36958339f9b401b53154b2 (patch) | |
tree | d6ee12220783a1a9e12f72a12013a3a828e72222 | |
parent | 70846641e4fc5494df1f4d10d93d73a31276b0f6 (diff) | |
download | jimtcl-858583c46deffd91cb36958339f9b401b53154b2.zip jimtcl-858583c46deffd91cb36958339f9b401b53154b2.tar.gz jimtcl-858583c46deffd91cb36958339f9b401b53154b2.tar.bz2 |
info patchlevel: now returns git version if available
e.g.
. info patchlevel
0.83-35-g8a438c3-dirty
Fixes #297
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | auto.def | 7 | ||||
-rw-r--r-- | jim.c | 15 |
2 files changed, 16 insertions, 6 deletions
@@ -499,6 +499,11 @@ if {[opt-bool shared with-jim-shared]} { define JIM_STATICLIB } define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]] +set githash [get-define VERSION] +catch { + set githash [exec git describe --dirty] +} +define JIM_GITVERSION $githash define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]] if {[get-define libdir] ni {/lib /usr/lib /usr/lib64}} { define SH_LINKRPATH_FLAGS [format [get-define SH_LINKRPATH] [get-define libdir]] @@ -669,7 +674,7 @@ foreach mod $extinfo(module-c) { } define BUILD_SHOBJS [join $lines \n] -make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8 JIM_TAINT SIZEOF_INT} -bare JIM_VERSION -none * +make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8 JIM_TAINT JIM_GITVERSION SIZEOF_INT} -bare JIM_VERSION -none * make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*} make-template Makefile.in make-template tests/Makefile.in @@ -16093,12 +16093,17 @@ static int Jim_InfoCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *arg return JIM_OK; } - case INFO_VERSION: - case INFO_PATCHLEVEL:{ - char buf[(JIM_INTEGER_SPACE * 2) + 1]; + case INFO_PATCHLEVEL: + /* bootstrap jimsh doesn't have this so fall through */ +#ifdef JIM_GITVERSION + Jim_SetResultString(interp, JIM_GITVERSION, -1); + return JIM_OK; +#endif - sprintf(buf, "%d.%d", JIM_VERSION / 100, JIM_VERSION % 100); - Jim_SetResultString(interp, buf, -1); + case INFO_VERSION:{ + char versionbuf[64]; + snprintf(versionbuf, sizeof(versionbuf), "%d.%d", JIM_VERSION / 100, JIM_VERSION % 100); + Jim_SetResultString(interp, versionbuf, -1); return JIM_OK; } |