diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-07-25 18:43:45 +0200 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-07-25 18:43:45 +0200 |
commit | b6894c24903483f1833dd155157552f54376a294 (patch) | |
tree | 81798d315ace988507c0f8ae0eacd51b3a1cad7c | |
parent | 4ca78530a221289e680ce24f02cc3e209820f3b5 (diff) | |
download | mbgtools-lx-b6894c24903483f1833dd155157552f54376a294.tar.gz mbgtools-lx-b6894c24903483f1833dd155157552f54376a294.zip |
Support getting full version string from git
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | mbgclock/mbgclock_main.c | 13 | ||||
-rw-r--r-- | mbglib/common/toolutil.c | 9 | ||||
-rw-r--r-- | mbgversion.h | 18 |
4 files changed, 37 insertions, 17 deletions
@@ -1,12 +1,14 @@ ######################################################################### # -# $Id: Makefile 1.37 2022/03/23 15:38:20 martin.burnicki REL_M $ +# $Id: Makefile 1.38 2022/07/25 16:42:04 martin.burnicki REL_M $ # # Makefile for mbgtools-lx which recurses into the subdirectories. # # ----------------------------------------------------------------------- # $Log: Makefile $ +# Revision 1.38 2022/07/25 16:42:04 martin.burnicki +# Support getting full version string from git. # Revision 1.37 2022/03/23 15:38:20 martin.burnicki # Fixed a build error that occurred when building a package in a sandbox. # Revision 1.36 2022/02/18 16:40:10 martin.burnicki @@ -509,6 +511,8 @@ $(call debug_msg,$(INFO) MAKECMDGOALS: $(MAKECMDGOALS)) MBGLIB_DIRS += common MBGLIB_DIRS += $(TGT_SYSTEM) +MBG_VERSION_FROM_GIT = $(shell git describe --tag --dirty 2>/dev/null) + ifndef MODULE #=========================================================== @@ -524,6 +528,10 @@ ifndef MODULE #=========================================================== $(Q)$(CC) $(CPPFLAGS) $(CXXLAGS) -c -o $@ $< +ifneq ($(MBG_VERSION_FROM_GIT),) + CPPFLAGS += -DMBG_VERSION_FROM_GIT=$(MBG_VERSION_FROM_GIT) +endif + CPPFLAGS += -Wall ## CPPFLAGS += -Wextra ## CPPFLAGS += -Winline @@ -829,6 +837,10 @@ all: modules PWD := $(shell pwd) +ifneq ($(MBG_VERSION_FROM_GIT),) + EXTRA_CFLAGS += -DMBG_VERSION_FROM_GIT=$(MBG_VERSION_FROM_GIT) +endif + EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += -I. EXTRA_CFLAGS += -I$(BASEDIR) diff --git a/mbgclock/mbgclock_main.c b/mbgclock/mbgclock_main.c index 21946b9..c2977b4 100644 --- a/mbgclock/mbgclock_main.c +++ b/mbgclock/mbgclock_main.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgclock_main.c 1.41 2022/01/21 18:09:36 martin.burnicki REL_M $ + * $Id: mbgclock_main.c 1.42 2022/07/25 16:41:59 martin.burnicki REL_M $ * * Description: * Main file for the mbgclock driver for Linux which allows access to @@ -12,6 +12,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgclock_main.c $ + * Revision 1.42 2022/07/25 16:41:59 martin.burnicki + * Support getting full version string from git. * Revision 1.41 2022/01/21 18:09:36 martin.burnicki * Support printing real pointer addresses in debug output * with Linux kernels 4.15 and newer. @@ -271,8 +273,8 @@ -PCPS_DRVR_INFO drvr_info = { MBG_MAIN_VERSION_CODE, - 0, MBG_DRVR_NAME " v" MBG_FULL_VERSION_STR }; +PCPS_DRVR_INFO drvr_info = { MBG_SHORT_VERSION_CODE, + 0, MBG_DRVR_NAME " v" MBG_NUMERIC_VERSION_STR }; int pretend_sync; // NOTE: int debug is defined in a library module @@ -2598,9 +2600,8 @@ int __init mbgclock_init_module( void ) _mbgddmsg_fnc_entry(); - mbg_kdd_msg( MBG_LOG_INFO, "Meinberg clock driver v%u.%u.%u%s loading.", - MBG_MAJOR_VERSION_CODE, MBG_MINOR_VERSION_CODE, - MBG_MICRO_VERSION_CODE, info ); + mbg_kdd_msg( MBG_LOG_INFO, "Meinberg clock driver %s%s loading.", + MBG_FULL_VERSION_STR, info ); mbg_kdd_msg( MBG_LOG_INFO, "%s", MBG_COPYRIGHT ); diff --git a/mbglib/common/toolutil.c b/mbglib/common/toolutil.c index 820d818..b08c79e 100644 --- a/mbglib/common/toolutil.c +++ b/mbglib/common/toolutil.c @@ -1,13 +1,15 @@ /************************************************************************** * - * $Id: toolutil.c 1.24 2022/04/01 15:00:12 martin.burnicki REL_M $ + * $Id: toolutil.c 1.25 2022/07/25 16:41:55 martin.burnicki REL_M $ * * Common functions that can be used with Meinberg command line * utility programs. * * ----------------------------------------------------------------------- * $Log: toolutil.c $ + * Revision 1.25 2022/07/25 16:41:55 martin.burnicki + * Support getting full version string from git. * Revision 1.24 2022/04/01 15:00:12 martin.burnicki * Print the RECEIVER_INFO's model_name as device name * in mbg_get_show_dev_info(). @@ -164,10 +166,7 @@ */ int mbg_program_version_str( char *s, size_t max_len ) { - int n; - - n = snprintf_safe( s, max_len, "%i.%i.%i", MBG_MAJOR_VERSION_CODE, - MBG_MINOR_VERSION_CODE, MBG_MICRO_VERSION_CODE ); + int n = snprintf_safe( s, max_len, "%s", MBG_FULL_VERSION_STR ); return n; diff --git a/mbgversion.h b/mbgversion.h index 931fd9b..a8409b4 100644 --- a/mbgversion.h +++ b/mbgversion.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgversion.h 1.22 2022/07/18 14:58:21 martin.burnicki REL_M $ + * $Id: mbgversion.h 1.23 2022/07/25 16:42:07 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgversion.h $ + * Revision 1.23 2022/07/25 16:42:07 martin.burnicki + * Support getting full version string from git. * Revision 1.22 2022/07/18 14:58:21 martin.burnicki * Changed version code to 4.2.21 for the develoment branch. * Revision 1.21 2022/07/08 12:21:48 martin.burnicki @@ -93,12 +95,18 @@ #endif -#define MBG_MAIN_VERSION_CODE ( ( MBG_MAJOR_VERSION_CODE << 8 ) | MBG_MINOR_VERSION_CODE ) -#define MBG_MAIN_VERSION_STR MBG_MAJOR_VERSION_STR "." MBG_MINOR_VERSION_STR +#define MBG_SHORT_VERSION_CODE ( ( MBG_MAJOR_VERSION_CODE << 8 ) | MBG_MINOR_VERSION_CODE ) +#define MBG_SHORT_VERSION_STR MBG_MAJOR_VERSION_STR "." MBG_MINOR_VERSION_STR #if defined( MBG_BUILD_VERSION_STR ) - #define MBG_FULL_VERSION_STR MBG_MAIN_VERSION_STR "." MBG_MICRO_VERSION_STR "." MBG_BUILD_VERSION_STR + #define MBG_NUMERIC_VERSION_STR MBG_SHORT_VERSION_STR "." MBG_MICRO_VERSION_STR "." MBG_BUILD_VERSION_STR #else - #define MBG_FULL_VERSION_STR MBG_MAIN_VERSION_STR "." MBG_MICRO_VERSION_STR + #define MBG_NUMERIC_VERSION_STR MBG_SHORT_VERSION_STR "." MBG_MICRO_VERSION_STR +#endif + +#if defined( MBG_VERSION_FROM_GIT ) + #define MBG_FULL_VERSION_STR STRINGIFY( MBG_VERSION_FROM_GIT ) +#else + #define MBG_FULL_VERSION_STR MBG_NUMERIC_VERSION_STR #endif |