mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Move generate version from git tool to source (#351)
* wip * fix * wip * Auto version update to [54146] * Auto version update to [54147] * Auto version update to [54148] * teeeeest * Auto version update to [54149] * wip * Auto version update to [54154] * wip * wip * wip
This commit is contained in:
parent
a2e87911ce
commit
22797da2a6
@ -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)
|
||||
|
@ -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.
|
||||
|
19
libs/libcommon/cmake/version.cmake
Normal file
19
libs/libcommon/cmake/version.cmake
Normal file
@ -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}")
|
@ -6,7 +6,7 @@
|
||||
* To use, include this file with -include compiler parameter.
|
||||
*/
|
||||
|
||||
#include <common/apple_version.h>
|
||||
#include <common/config_common.h>
|
||||
|
||||
#if APPLE_SIERRA_OR_NEWER == 0
|
||||
/**
|
||||
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define APPLE_SIERRA_OR_NEWER ${APPLE_SIERRA_OR_NEWER}
|
5
libs/libcommon/include/common/config_common.h.in
Normal file
5
libs/libcommon/include/common/config_common.h.in
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// .h autogenerated by cmake !
|
||||
|
||||
#cmakedefine01 APPLE_SIERRA_OR_NEWER
|
18
libs/libcommon/include/common/config_version.h.in
Normal file
18
libs/libcommon/include/common/config_version.h.in
Normal file
@ -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@"
|
@ -1,7 +1,7 @@
|
||||
#include <common/ClickHouseRevision.h>
|
||||
#include "revision.h"
|
||||
#include "common/config_version.h"
|
||||
|
||||
namespace ClickHouseRevision
|
||||
{
|
||||
unsigned get() { return REVISION; }
|
||||
unsigned get() { return VERSION_REVISION; }
|
||||
}
|
||||
|
@ -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
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user