tcc -v displays short hash to ease detection of source version used to compile tcc

This commit is contained in:
Christian Jullien 2021-03-31 22:24:29 +02:00
parent 47da8e450e
commit 65d00b13d5
2 changed files with 13 additions and 1 deletions

View file

@ -24,6 +24,12 @@ CFLAGS += -I$(TOP)
CFLAGS += $(CPPFLAGS)
VPATH = $(TOPSRC)
TCC_GIT_HASH=$(shell git rev-parse > /dev/null 2>&1 && git rev-parse --short HEAD || echo no)
ifneq ($(TCC_GIT_HASH),no)
CFLAGS += -DTCC_GIT_HASH=\"$(TCC_GIT_HASH)\"
endif
ifdef CONFIG_WIN32
CFG = -win
ifneq ($(CONFIG_static),yes)

8
tcc.c
View file

@ -149,7 +149,13 @@ static const char help2[] =
;
static const char version[] =
"tcc version "TCC_VERSION" ("
"tcc version "TCC_VERSION
#ifdef TCC_GIT_HASH
" - " TCC_GIT_HASH
#else
" - unknown hash"
#endif
" ("
#ifdef TCC_TARGET_I386
"i386"
#elif defined TCC_TARGET_X86_64