diff --git a/cmake/dbms_include.cmake b/cmake/dbms_include.cmake index a504fd22952..7b0bd1b85af 100644 --- a/cmake/dbms_include.cmake +++ b/cmake/dbms_include.cmake @@ -4,10 +4,8 @@ include_directories (${CMAKE_SOURCE_DIR}/dbms/include) # TODO: # move code with incldes from .h to .cpp and clean this list: include_directories (${CMAKE_SOURCE_DIR}/libs/libcommon/include) -if (APPLE) - # apple_rt.h -> generated apple_version.h - include_directories (${CMAKE_BINARY_DIR}/libs/libcommon/include) -endif () +# for generated config_version.h and config_common.h: +include_directories (${CMAKE_BINARY_DIR}/libs/libcommon/include) include_directories (${CMAKE_SOURCE_DIR}/libs/libpocoext/include) include_directories (${CMAKE_SOURCE_DIR}/libs/libzkutil/include) include_directories (${CMAKE_SOURCE_DIR}/libs/libmysqlxx/include) diff --git a/libs/libcommon/CMakeLists.txt b/libs/libcommon/CMakeLists.txt index b8cc9886162..524bda456db 100644 --- a/libs/libcommon/CMakeLists.txt +++ b/libs/libcommon/CMakeLists.txt @@ -1,17 +1,7 @@ -SET(REVISIONFILE ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h) - -ADD_CUSTOM_COMMAND( - OUTPUT ${REVISIONFILE} - COMMAND bash -f -v -x ${CMAKE_CURRENT_SOURCE_DIR}/src/create_revision.sh ${REVISIONFILE} ${USE_DBMS_TCP_PROTOCOL_VERSION_AS_CLICKHOUSE_REVISION} -) - -set_source_files_properties( - src/ClickHouseRevision.cpp PROPERTIES OBJECT_DEPENDS ${REVISIONFILE} -) +SET(CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_version.h) +SET(CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_common.h) include_directories (include) -# for generated revision.h: -include_directories (${CMAKE_CURRENT_BINARY_DIR}/src/) include(${CMAKE_SOURCE_DIR}/cmake/dbms_include.cmake) if (APPLE) @@ -20,7 +10,14 @@ if (APPLE) else () set (APPLE_SIERRA_OR_NEWER 0) endif () - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/apple_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/common/apple_version.h) +endif() + +include(cmake/version.cmake) +message(STATUS "Will build ${VERSION_FULL}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_common.h.in ${CONFIG_COMMON}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_version.h.in ${CONFIG_VERSION}) + +if (APPLE) add_library (apple_rt src/apple_rt.cpp include/common/apple_rt.h @@ -61,7 +58,8 @@ add_library (common include/ext/size.hpp include/ext/unlock_guard.hpp - ${REVISIONFILE} + ${CONFIG_VERSION} + ${CONFIG_COMMON} ) # When testing for memory leaks, disable libtcmalloc. diff --git a/libs/libcommon/cmake/version.cmake b/libs/libcommon/cmake/version.cmake new file mode 100644 index 00000000000..490a58e3ac9 --- /dev/null +++ b/libs/libcommon/cmake/version.cmake @@ -0,0 +1,19 @@ +#This strings autochanged from release_lib.sh : +set(VERSION_DESCRIBE v1.1.54134-testing) +set(VERSION_REVISION 54134) +#===end of autochange + +set(VERSION_MAJOR 1) +set(VERSION_MINOR 1) +set(VERSION_PATCH ${VERSION_REVISION}) +set(VERSION_EXTRA "") +set(VERSION_TWEAK "") +set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") +if (VERSION_TWEAK) + set(VERSION_STRING "${VERSION_STRING}.${VERSION_TWEAK}") +endif() +if (VERSION_EXTRA) + set(VERSION_STRING "${VERSION_STRING}${VERSION_EXTRA}") +endif() + +set(VERSION_FULL "${PROJECT_NAME} ${VERSION_STRING}") diff --git a/libs/libcommon/include/common/apple_rt.h b/libs/libcommon/include/common/apple_rt.h index c3e7dda9e1f..4d3da434265 100644 --- a/libs/libcommon/include/common/apple_rt.h +++ b/libs/libcommon/include/common/apple_rt.h @@ -6,7 +6,7 @@ * To use, include this file with -include compiler parameter. */ -#include +#include #if APPLE_SIERRA_OR_NEWER == 0 /** diff --git a/libs/libcommon/include/common/apple_version.h.in b/libs/libcommon/include/common/apple_version.h.in deleted file mode 100644 index cd96e872005..00000000000 --- a/libs/libcommon/include/common/apple_version.h.in +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define APPLE_SIERRA_OR_NEWER ${APPLE_SIERRA_OR_NEWER} diff --git a/libs/libcommon/include/common/config_common.h.in b/libs/libcommon/include/common/config_common.h.in new file mode 100644 index 00000000000..55edaf6e987 --- /dev/null +++ b/libs/libcommon/include/common/config_common.h.in @@ -0,0 +1,5 @@ +#pragma once + +// .h autogenerated by cmake ! + +#cmakedefine01 APPLE_SIERRA_OR_NEWER diff --git a/libs/libcommon/include/common/config_version.h.in b/libs/libcommon/include/common/config_version.h.in new file mode 100644 index 00000000000..85f9c644f32 --- /dev/null +++ b/libs/libcommon/include/common/config_version.h.in @@ -0,0 +1,18 @@ +#pragma once + +// .h autogenerated by cmake ! + +#cmakedefine01 USE_DBMS_TCP_PROTOCOL_VERSION + +#if USE_DBMS_TCP_PROTOCOL_VERSION + #include "DB/Core/Defines.h" + #ifndef VERSION_REVISION + #define VERSION_REVISION DBMS_TCP_PROTOCOL_VERSION + #endif +#else + #cmakedefine VERSION_REVISION @VERSION_REVISION@ +#endif + +#cmakedefine VERSION_STRING "@VERSION_STRING@" +#cmakedefine VERSION_FULL "@VERSION_FULL@" +#cmakedefine VERSION_DESCRIBE "@VERSION_DESCRIBE@" diff --git a/libs/libcommon/src/ClickHouseRevision.cpp b/libs/libcommon/src/ClickHouseRevision.cpp index 41e38de9e88..fd2abf8ae71 100644 --- a/libs/libcommon/src/ClickHouseRevision.cpp +++ b/libs/libcommon/src/ClickHouseRevision.cpp @@ -1,7 +1,7 @@ #include -#include "revision.h" +#include "common/config_version.h" namespace ClickHouseRevision { - unsigned get() { return REVISION; } + unsigned get() { return VERSION_REVISION; } } diff --git a/libs/libcommon/src/create_revision.sh b/libs/libcommon/src/create_revision.sh deleted file mode 100755 index 811b0270b7e..00000000000 --- a/libs/libcommon/src/create_revision.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/get_revision_lib.sh" - -if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then - echo "usage: create_revision.sh out_file_path [--use_dbms_tcp_protocol_version]" - exit 1 -fi - -out_file=$1 -dir=$(dirname $out_file) - -use_dbms_tcp_protocol_version="$2" - -mkdir -p $dir - -if [ "$use_dbms_tcp_protocol_version" == "--use_dbms_tcp_protocol_version" ]; -then - - echo " -#include \"DB/Core/Defines.h\" -#ifndef REVISION -#define REVISION DBMS_TCP_PROTOCOL_VERSION -#endif -" > $out_file - -else - # берем последний тэг из текущего коммита - revision=$(get_revision) - - if [[ "$revision" == "" ]]; then - # в крайнем случае выбирем любую версию как версию демона - # нужно для stash или неполноценной копии репозитория - revision="77777" - fi - - echo " -#ifndef REVISION -#define REVISION $revision -#endif -" > $out_file - -fi diff --git a/release_lib.sh b/release_lib.sh index d34cbe3a9ed..7f33f6bcd94 100644 --- a/release_lib.sh +++ b/release_lib.sh @@ -94,6 +94,17 @@ function gen_revision_author { echo "Fail to create tag" exit 1 fi + + auto_message="Auto version update to" + git_log_grep=`git log --oneline --max-count=1 | grep "$auto_message"` + if [ "$git_log_grep" == "" ]; then + git_describe=`git describe` + sed -i -- "s/VERSION_REVISION .*)/VERSION_REVISION $REVISION)/g" libs/libcommon/cmake/version.cmake + sed -i -- "s/VERSION_DESCRIBE .*)/VERSION_DESCRIBE $git_describe)/g" libs/libcommon/cmake/version.cmake + git commit -m "$auto_message [$REVISION]" libs/libcommon/cmake/version.cmake + git push + fi + fi AUTHOR=$(git config --get user.name)