diff options
author | Steve Bennett <steveb@workware.net.au> | 2024-09-23 09:23:33 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2025-07-16 09:34:08 +1000 |
commit | f4321af962050cfd3569f1cdf8df96424985604e (patch) | |
tree | aecda052a6e927d1cd0398f4aa581451ed5c131f | |
parent | 1eff7d23a8259d12495cf6a1480ef3f62c8b347d (diff) | |
download | jimtcl-f4321af962050cfd3569f1cdf8df96424985604e.zip jimtcl-f4321af962050cfd3569f1cdf8df96424985604e.tar.gz jimtcl-f4321af962050cfd3569f1cdf8df96424985604e.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 | 9 | ||||
-rw-r--r-- | jim.c | 15 | ||||
-rw-r--r-- | jim_tcl.txt | 4 |
3 files changed, 21 insertions, 7 deletions
@@ -31,7 +31,7 @@ options { taint=1 => "Disable taint support" extinfo => "Show information about available extensions" with-jim-shared shared => "Build a shared library instead of a static library" - jim-regexp=1 => "Prefer POSIX regex if over the the built-in (Tcl-compatible) regex" + jim-regexp=1 => "Prefer POSIX regex over the the built-in (Tcl-compatible) regex" docs=1 => "Don't build or install the documentation" docdir:path => "Path to install docs (if built)" random-hash => "Randomise hash tables. more secure but hash table results are not predicable" @@ -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 @@ -16120,12 +16120,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; } diff --git a/jim_tcl.txt b/jim_tcl.txt index 6975401..71dc35a 100644 --- a/jim_tcl.txt +++ b/jim_tcl.txt @@ -3034,6 +3034,10 @@ The legal +'option'+'s (which may be abbreviated) are: was invoked. A full path will be returned, unless the path can't be determined, in which case the empty string will be returned. ++*info patchlevel*+:: + Returns the build (git) version if available. Otherwise + returns the same as `info version`. + +*info procs ?-all?* ?'pattern'?+:: Returns a list containing the names of Tcl command procedures. See `info commands` for the meaning of +*-all*+ and +'pattern'+. |