From 5914e5c6e26b81c717bbc6bcaa8449645618c542 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 18 Dec 2015 14:24:01 +0000 Subject: [PATCH] Support GIT_ID variable --- CMakeLists.txt | 38 +++++--------------------------------- config.h.in | 12 ++++++++++-- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index add82c152..263249f38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ SET(RSPAMD_VERSION_MAJOR 1) SET(RSPAMD_VERSION_MINOR 1) SET(RSPAMD_VERSION_PATCH 0) +IF(GIT_ID) + SET(GIT_VERSION 1) + SET(RSPAMD_ID "${GIT_ID}") +ENDIF() + SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}") SET(RSPAMD_MASTER_SITE_URL "https://rspamd.com") @@ -984,39 +989,6 @@ IF(NOT DESTDIR) SET(DESTDIR $ENV{DESTDIR}) ENDIF(NOT DESTDIR) -# Try to detect tip version from hg -SET(ID "unknown") -FIND_PROGRAM(HG "git") - -IF(HG) - EXECUTE_PROCESS(COMMAND "${HG}" rev-parse --verify HEAD - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE HG_ID ERROR_QUIET) - IF(HG_ID) - STRING(SUBSTRING "${HG_ID}" 0 10 RSPAMD_ID) - MESSAGE(STATUS "Git revision: ${RSPAMD_ID}") - ELSE(HG_ID) - FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") - IF(HG_ARCH) - FILE(READ ${HG_ARCH} HG_ID) - IF(HG_ID) - STRING(REGEX MATCH "node: [0-9a-z]+" _tmp "${HG_ID}") - STRING(SUBSTRING "${_tmp}" 6 12 RSPAMD_ID) - ENDIF(HG_ID) - ENDIF(HG_ARCH) - ENDIF(HG_ID) -ELSE(HG) -# Now check .hg_archival.txt - FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") - IF(HG_ARCH) - FILE(READ ${HG_ARCH} HG_ID) - IF(HG_ID) - STRING(REGEX MATCH "node: [0-9a-z]+" _tmp "${HG_ID}") - STRING(SUBSTRING "${_tmp}" 6 12 RSPAMD_ID) - ENDIF(HG_ID) - ENDIF(HG_ARCH) -ENDIF(HG) - ################################ SUBDIRS SECTION ########################### diff --git a/config.h.in b/config.h.in index 908278013..daa84f723 100644 --- a/config.h.in +++ b/config.h.in @@ -4,6 +4,7 @@ #cmakedefine BUILD_STATIC 1 #cmakedefine CURL_FOUND 1 #cmakedefine DEBUG_MODE 1 +#cmakedefine GIT_VERSION 1 #cmakedefine GLIB_COMPAT 1 #cmakedefine GLIB_HASH_COMPAT 1 #cmakedefine GLIB_RE_COMPAT 1 @@ -179,8 +180,15 @@ #define RSPAMD_WWWDIR "${WWWDIR}" #define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}" -#define RVERSION "${RSPAMD_VERSION}" -#define RID "${RSPAMD_ID}" + +#ifdef GIT_VERSION +# define RVERSION "${RSPAMD_VERSION}" +# define RID "${RSPAMD_ID}" +#else +# define RVERSION "${RSPAMD_VERSION}" +# define RID "release" +#endif + #define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}" #define MODULES_NUM ${RSPAMD_MODULES_NUM} -- 2.39.5