Navigation


Changeset 1159:05f74dc19c49 in freeDiameter


Ignore:
Timestamp:
May 31, 2013, 12:20:27 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Include source rev number in version information when available

Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • freeDiameterd/main.c

    r1134 r1159  
    111111static void main_version_core(void)
    112112{
    113         printf("%s, version %d.%d.%d"
    114 #ifdef HG_VERSION
    115                 " (r%s"
    116 # ifdef PACKAGE_HG_REVISION
    117                 "/%s"
    118 # endif /* PACKAGE_HG_VERSION */
    119                 ")"
    120 #endif /* HG_VERSION */
    121                 " (libfdcore: %s)\n",
    122                 FD_PROJECT_NAME, FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, FD_PROJECT_VERSION_REV
    123 #ifdef HG_VERSION
    124                 , HG_VERSION
    125 # ifdef PACKAGE_HG_REVISION
    126                 , PACKAGE_HG_REVISION
    127 # endif /* PACKAGE_HG_VERSION */
    128 #endif /* HG_VERSION */
    129                 , fd_core_version());
     113        printf("%s, version %s\n", FD_PROJECT_NAME, fd_core_version);
    130114}
    131115
  • include/freeDiameter/CMakeLists.txt

    r1136 r1159  
    187187##########################
    188188
     189# Additional hg version when relevant, stored in version.h
     190if (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
     191        # Search for hg binary to use
     192        FIND_PROGRAM(HGCOMMAND hg)
     193        if (HGCOMMAND)
     194                # Ok, add the custom target so that hg is executed at every build
     195                ADD_CUSTOM_TARGET(version_information
     196                                   COMMAND ${CMAKE_COMMAND} -D HGCOMMAND="${HGCOMMAND}" -D SRC="${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" -D DST="${CMAKE_CURRENT_BINARY_DIR}/version.h" -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GetVersionWithHg.cmake"
     197                                   DEPENDS "${CMAKE_SOURCE_DIR}/.hg/dirstate"
     198                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     199                                   COMMENT "Retrieving version of the hg repository"
     200                                   )
     201        else (HGCOMMAND)
     202                # Display at least "unknown" rev in this case
     203                SET(FD_PROJECT_VERSION_HG "unknown")
     204                CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
     205                ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
     206        endif(HGCOMMAND)
     207else (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
     208        # We use the pure version number without extension
     209        CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
     210        ADD_CUSTOM_TARGET(version_information DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
     211endif (EXISTS "${CMAKE_SOURCE_DIR}/.hg")
     212
     213
     214##########################
     215
    189216# LFDPROTO_LIBS = libraries required by the libfdproto.
    190217SET(LFDPROTO_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${IDNA_LIBRARIES} PARENT_SCOPE)
  • include/freeDiameter/libfdcore.h

    r1155 r1159  
    6161                CHECK_PRELUDE(__call__);                                                                \
    6262                if (__ret__ < 0) {                                                                      \
    63                         __ret__ = errno;                                                                \
    64                         LOG(faillevel, "ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__)); \
     63                        LOG(faillevel, "TLS ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__)); \
    6564                        __fallback__;                                                                   \
    6665                }                                                                                       \
     
    7675#ifndef EXCLUDE_DEPRECATED
    7776/* Macro for transition, replace with CHECK_GNUTLS_GEN */
    78 #define CHECK_GNUTLS_DO( __call__, __fallback__ ) {                                                     \
    79                 CHECK_PRELUDE(__call__);                                                                \
    80                 if (__ret__ < 0) {                                                                      \
    81                         __ret__ = errno;                                                                \
    82                         TRACE_ERROR("ERROR: in '%s' :\t%s",  #__call__ ,  gnutls_strerror(__ret__));    \
    83                         __fallback__;                                                                   \
    84                 }                                                                                       \
    85 }
     77#define CHECK_GNUTLS_DO( __call__, __fallback__ )       \
     78        CHECK_GNUTLS_GEN( FD_LOG_ERROR, __call__, __fallback__  )
    8679
    8780#endif /* EXCLUDE_DEPRECATED */
     
    9689int fd_core_initialize(void);
    9790
    98 /* Return a string describing the version of the library */
    99 const char *fd_core_version(void);
     91/* A string describing the version of the library */
     92extern const char fd_core_version[];
    10093
    10194/* Parse the freeDiameter.conf configuration file, load the extensions */
  • include/freeDiameter/libfdproto.h

    r1134 r1159  
    123123void fd_libproto_fini(void);
    124124
     125/* Retrieve the version of the binary */
     126extern const char fd_libproto_version[];
    125127
    126128/*============================================================*/
  • libfdcore/CMakeLists.txt

    r1077 r1159  
    3535        server.c
    3636        tcp.c
     37        version.c
    3738        )
    3839
     
    5354# Include path
    5455INCLUDE_DIRECTORIES(${LFDCORE_INCLUDES})
     56INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
    5557
    5658# Build the executable
    5759ADD_LIBRARY(libfdcore SHARED ${FDCORE_SRC} ${FDCORE_GEN_SRC})
     60ADD_DEPENDENCIES(libfdcore version_information)
    5861
    5962# Avoid the liblib name, and set the version
  • libfdcore/core.c

    r1142 r1159  
    166166/* Public interfaces */
    167167
    168 /* Return a string describing the version of the library */
    169 const char *fd_core_version(void)
    170 {
    171         return _stringize(FD_PROJECT_VERSION_MAJOR) "." _stringize(FD_PROJECT_VERSION_MINOR) "." _stringize(FD_PROJECT_VERSION_REV);
    172 }
    173 
    174168/* Initialize the libfdcore internals. This also initializes libfdproto */
    175169int fd_core_initialize(void)
     
    189183        }
    190184       
    191         LOG_N("libfdproto initialized.");
    192        
    193185        /* Name this thread */
    194186        fd_log_threadname("Main");
     187       
     188        LOG_N("libfdproto '%s' initialized.", fd_libproto_version);
    195189       
    196190        /* Initialize gcrypt and gnutls */
     
    227221        core_state_set(CORE_LIBS_INIT);
    228222       
     223        LOG_N("libfdcore '%s' initialized.", fd_core_version);
     224       
     225       
    229226        /* Next thing is to parse the config, leave this for a different function */
    230227        return 0;
  • libfdproto/CMakeLists.txt

    r1080 r1159  
    11# Name of the subproject
    22Project("libfdproto" C)
     3
    34
    45# List of source files for the library
     
    1819        sessions.c
    1920        utils.c
     21        version.c
    2022        )
     23
    2124
    2225# Save the list of files for testcases in the core's directory
     
    2831# Build as a shared library
    2932ADD_LIBRARY(libfdproto SHARED ${LFDPROTO_SRC})
     33
     34ADD_DEPENDENCIES(libfdproto version_information)
    3035
    3136# Avoid the liblib name, and set the version
Note: See TracChangeset for help on using the changeset viewer.