This one is simpler and gives better info jullien@mobley:~/tinycc $ git diff diff --git a/Makefile b/Makefile index efe0885..7543962 100644 --- a/Makefile +++ b/Makefile @@ -241,9 +241,12 @@ $(TCC_FILES) : DEFINES += -DONE_SOURCE=0 $(X)tccpp.o : $(TCCDEFS_H) endif
-GITHASH := $(shell git rev-parse >/dev/null 2>&1 && git rev-parse --short HEAD || echo no) -ifneq ($(GITHASH),no) -DEF_GITHASH := -DTCC_GITHASH="\"$(shell git rev-parse --abbrev-ref HEAD):$(GITHASH)$(shell git diff --quiet || echo '-mod')\"" +FROM_GIT := $(shell git rev-parse >/dev/null 2>&1 && echo yes || echo no) + +ifeq ($(FROM_GIT),yes) +GITHASH:=$(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --short HEAD) $(shell git log -1 --pretty='format:%cI') +GITHASH+=$(shell git diff --quiet || echo locally modified) +DEF_GITHASH := -DTCC_GITHASH="\"$(GITHASH)\"" endif ifeq ($(CONFIG_debug),yes) For example, with this uncommitted patch, it gives: jullien@mobley:~/tinycc $ ./tcc -v tcc version 0.9.27 mob:ac0604a 2022-11-29T21:13:20+01:00 locally modified (AArch64 Darwin) C. -----Original Message----- From: tinycc-devel-bounces+eligis=orange...@nongnu.org [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of Christian Jullien Sent: Tuesday, November 29, 2022 12:10 To: tinycc-devel@nongnu.org Subject: [Tinycc-devel] tcc -v with mob date? Hi, Currently, tcc –v displays the (mob) githash which helps to identify which this version comes from. It is not however user friendly. I would like to add last commit date as: jullien@sims4:~/tinycc $ ./tcc -v tcc version 0.9.27 mob:afcdaf1 on 2022-11-29T00:56:26-06:00 (ARM eabihf Linux) Maintainers, can you please apply a patch similar to this one? jullien@sims4:~/tinycc $ git diff diff --git a/Makefile b/Makefile index efe0885..6377570 100644 --- a/Makefile +++ b/Makefile @@ -243,7 +243,12 @@ endif GITHASH := $(shell git rev-parse >/dev/null 2>&1 && git rev-parse --short HEAD || echo no) ifneq ($(GITHASH),no) -DEF_GITHASH := -DTCC_GITHASH="\"$(shell git rev-parse --abbrev-ref HEAD):$(GITHASH)$(shell git diff --quiet || echo '-mod')\"" +DEF_GITHASH := -DTCC_GITHASH="\"$(shell git rev-parse --abbrev-ref HEAD):$(GITHASH)$(shell git diff --quiet || echo '-modified')\"" +endif + +GITDATE := $(shell git log -1 >/dev/null 2>&1 && git log -1 --pretty='format:%cI' || echo no) +ifneq ($(GITDATE),no) +DEF_GITDATE := -DTCC_GITDATE="\"$(shell git log -1 --pretty='format:%cI')\"" endif ifeq ($(CONFIG_debug),yes) @@ -265,7 +270,7 @@ $(X)%.o : %.c $(LIBTCC_INC) # additional dependencies $(X)tcc.o : tcctools.c -$(X)tcc.o : DEFINES += $(DEF_GITHASH) +$(X)tcc.o : DEFINES += $(DEF_GITHASH) $(DEF_GITDATE) # Host Tiny C Compiler tcc$(EXESUF): tcc.o $(LIBTCC) diff --git a/tcc.c b/tcc.c index beef6fb..da460cf 100644 --- a/tcc.c +++ b/tcc.c @@ -155,6 +155,9 @@ static const char version[] = "tcc version "TCC_VERSION #ifdef TCC_GITHASH " "TCC_GITHASH +#endif +#ifdef TCC_GITDATE + " on "TCC_GITDATE #endif " (" #ifdef TCC_TARGET_I386 _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel