Skip to content
Snippets Groups Projects
Commit 103af00b authored by Adam Knapp's avatar Adam Knapp
Browse files

Add the commit id to the version printout (issue #561, epic &29)

parent 2df52d71
No related branches found
No related tags found
1 merge request!191Add the commit id to the version printout (issue #561, epic &29)
...@@ -45,6 +45,9 @@ endif ...@@ -45,6 +45,9 @@ endif
# Set these variables to fit your system: # Set these variables to fit your system:
# Set it to 'yes' to display git commit id beside the version
GIT_COMMIT_ID := yes
# The target directory where the Test Executor will be installed to: # The target directory where the Test Executor will be installed to:
TTCN3_DIR := ${TOP}/Install TTCN3_DIR := ${TOP}/Install
......
...@@ -14,3 +14,4 @@ pattern_uni.output ...@@ -14,3 +14,4 @@ pattern_uni.output
config_preproc_p.output config_preproc_p.output
config_preproc_p.tab.cc config_preproc_p.tab.cc
config_preproc_p.tab.hh config_preproc_p.tab.hh
git_version.c
...@@ -26,6 +26,26 @@ ...@@ -26,6 +26,26 @@
TOP := .. TOP := ..
include $(TOP)/Makefile.cfg include $(TOP)/Makefile.cfg
# Generating git_version.c according to GIT_COMMIT_ID
ifeq ($(GIT_COMMIT_ID), yes)
$(shell echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"$$(git describe --always --dirty --match 'NOT A TAG')\";" > git_version.c.tmp; \
if [ ! -f git_version.c.tmp ]; then \
echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"\";" > git_version.c.tmp; \
fi; \
if diff -q git_version.c.tmp git_version.c >/dev/null 2>&1; then \
rm git_version.c.tmp; \
else \
mv git_version.c.tmp git_version.c; \
fi)
else
$(shell echo -e "// this file was generated by make\n#include \"version_internal.h\"\n\nchar const *const GIT_COMMIT_ID = \"\";" > git_version.c.tmp; \
if diff -q git_version.c.tmp git_version.c >/dev/null 2>&1; then \
rm git_version.c.tmp; \
else \
mv git_version.c.tmp git_version.c; \
fi)
endif
TARGETS := TARGETS :=
# The origin of GENERATED_SOURCES # The origin of GENERATED_SOURCES
...@@ -35,7 +55,7 @@ GENERATED_SOURCES := pattern_la.cc pattern_p.cc pattern_uni.cc config_preproc_la ...@@ -35,7 +55,7 @@ GENERATED_SOURCES := pattern_la.cc pattern_p.cc pattern_uni.cc config_preproc_la
# Sources in the CVS # Sources in the CVS
STATIC_SOURCES := memory.c new.cc userinfo.c path.c config_preproc.cc Quadruple.cc \ STATIC_SOURCES := git_version.c memory.c new.cc userinfo.c path.c config_preproc.cc Quadruple.cc \
Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc openssl_version.c Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc openssl_version.c
ifndef MINGW ifndef MINGW
......
...@@ -286,4 +286,7 @@ ...@@ -286,4 +286,7 @@
/* For prefixing the above messages. Default value: empty string. */ /* For prefixing the above messages. Default value: empty string. */
#define COMMENT_PREFIX #define COMMENT_PREFIX
/ * For include git commit id in version printouts */
extern char const *const GIT_COMMIT_ID;
#endif #endif
...@@ -121,7 +121,7 @@ ifdef REGEX_DIR ...@@ -121,7 +121,7 @@ ifdef REGEX_DIR
endif endif
COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \ COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \
$(addprefix ../common/, new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o \ $(addprefix ../common/, git_version.o new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o \
ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o openssl_version.o) ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o openssl_version.o)
ifeq ($(USAGE_STATS), yes) ifeq ($(USAGE_STATS), yes)
......
...@@ -977,6 +977,10 @@ int main(int argc, char *argv[]) ...@@ -977,6 +977,10 @@ int main(int argc, char *argv[])
"Compiled with: " C_COMPILER_VERSION "\n", stderr); "Compiled with: " C_COMPILER_VERSION "\n", stderr);
fputs("Using ", stderr); fputs("Using ", stderr);
fputs(openssl_version_str(), stderr); fputs(openssl_version_str(), stderr);
if (strlen(GIT_COMMIT_ID)) {
fputs("\nCommit id: ", stderr);
fputs(GIT_COMMIT_ID, stderr);
}
fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr); fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr);
#ifdef LICENSE #ifdef LICENSE
print_license_info(); print_license_info();
......
...@@ -160,7 +160,7 @@ PROFMERGE_OBJECTS := ProfMerge_main.o ProfilerTools.profmerge.o \ ...@@ -160,7 +160,7 @@ PROFMERGE_OBJECTS := ProfMerge_main.o ProfilerTools.profmerge.o \
COMMON_OBJECTS := $(addprefix ../common/, memory.o pattern_la.o pattern_p.o \ COMMON_OBJECTS := $(addprefix ../common/, memory.o pattern_la.o pattern_p.o \
config_preproc.o config_preproc_la.o config_preproc_p.tab.o \ config_preproc.o config_preproc_la.o config_preproc_p.tab.o \
path.o pattern_uni.o Quadruple.o NetworkHandler.o Path2.o \ path.o pattern_uni.o Quadruple.o NetworkHandler.o Path2.o \
ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o) ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o git_version.o)
ifeq ($(DEBUG), yes) ifeq ($(DEBUG), yes)
COMMON_OBJECTS += ../common/new.o COMMON_OBJECTS += ../common/new.o
......
...@@ -175,8 +175,12 @@ static boolean process_options(int argc, char *argv[], int& ret_val, ...@@ -175,8 +175,12 @@ static boolean process_options(int argc, char *argv[], int& ret_val,
fputs("TTCN-3 Host Controller (parallel mode)\n" fputs("TTCN-3 Host Controller (parallel mode)\n"
"Version: " VERSION_STRING "\n" "Version: " VERSION_STRING "\n"
"Build date (Base Library): " __DATE__ " " __TIME__ "\n" "Build date (Base Library): " __DATE__ " " __TIME__ "\n"
"Base Library was compiled with: " C_COMPILER_VERSION "\n\n" "Base Library was compiled with: " C_COMPILER_VERSION, stderr);
COPYRIGHT_STRING "\n\n", stderr); if (strlen(GIT_COMMIT_ID)) {
fputs("\nCommit id: ", stderr);
fputs(GIT_COMMIT_ID, stderr);
}
fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr);
#ifdef LICENSE #ifdef LICENSE
print_license_info(); print_license_info();
putc('\n', stderr); putc('\n', stderr);
......
...@@ -185,8 +185,12 @@ int main(int argc, char *argv[]) ...@@ -185,8 +185,12 @@ int main(int argc, char *argv[])
fputs("TTCN-3 Test Executor (single mode)\n" fputs("TTCN-3 Test Executor (single mode)\n"
"Version: " VERSION_STRING "\n" "Version: " VERSION_STRING "\n"
"Build date (Base Library): " __DATE__ " " __TIME__ "\n" "Build date (Base Library): " __DATE__ " " __TIME__ "\n"
"Base Library was compiled with: " C_COMPILER_VERSION "\n\n" "Base Library was compiled with: " C_COMPILER_VERSION, stderr);
COPYRIGHT_STRING "\n\n", stderr); if (strlen(GIT_COMMIT_ID)) {
fputs("\nCommit id: ", stderr);
fputs(GIT_COMMIT_ID, stderr);
}
fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr);
#ifdef LICENSE #ifdef LICENSE
print_license_info(); print_license_info();
putc('\n', stderr); putc('\n', stderr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment