Generate GitCommitHash.cpp during building.
This commit is contained in:
parent
954444e692
commit
6eb03bdc8b
@ -153,8 +153,10 @@ if (CLANG OR GCC)
|
||||
endif()
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
get_git_head_revision(TD_GIT_REFSPEC TD_GIT_COMMIT)
|
||||
message(STATUS "Git state: ${TD_GIT_COMMIT}")
|
||||
get_git_head_revision(TD_GIT_REFSPEC TD_GIT_COMMIT_HASH)
|
||||
message(STATUS "Git state: ${TD_GIT_COMMIT_HASH}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/td/telegram/GitCommitHash.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/td/telegram/GitCommitHash.cpp" @ONLY)
|
||||
|
||||
add_subdirectory(tdtl)
|
||||
|
||||
@ -566,6 +568,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/FullMessageId.h
|
||||
td/telegram/Game.h
|
||||
td/telegram/GameManager.h
|
||||
td/telegram/GitCommitHash.h
|
||||
td/telegram/Global.h
|
||||
td/telegram/GroupCallId.h
|
||||
td/telegram/GroupCallManager.h
|
||||
@ -736,6 +739,8 @@ set(TDLIB_SOURCE
|
||||
td/telegram/VoiceNotesManager.hpp
|
||||
|
||||
${TL_TD_SCHEME_SOURCE}
|
||||
|
||||
${CMAKE_CURRENT_BINARY_DIR}/td/telegram/GitCommitHash.cpp
|
||||
)
|
||||
|
||||
set(MEMPROF_SOURCE
|
||||
|
@ -4,24 +4,12 @@
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/utils/GitInfo.h"
|
||||
|
||||
#if !defined(GIT_COMMIT)
|
||||
#define GIT_COMMIT "unknown"
|
||||
#endif
|
||||
|
||||
#if !defined(GIT_DIRTY)
|
||||
#define GIT_DIRTY false
|
||||
#endif
|
||||
#include "td/telegram/GitCommitHash.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
const char *GitInfo::commit() {
|
||||
return GIT_COMMIT;
|
||||
}
|
||||
|
||||
bool GitInfo::is_dirty() {
|
||||
return GIT_DIRTY;
|
||||
const char *get_git_commit_hash() {
|
||||
return "@TD_GIT_COMMIT_HASH@";
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -8,10 +8,6 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class GitInfo {
|
||||
public:
|
||||
static const char *commit();
|
||||
static bool is_dirty();
|
||||
};
|
||||
const char *get_git_commit_hash();
|
||||
|
||||
} // namespace td
|
@ -100,7 +100,6 @@ set(TDUTILS_SOURCE
|
||||
td/utils/find_boundary.cpp
|
||||
td/utils/FlatHashTable.cpp
|
||||
td/utils/FloodControlGlobal.cpp
|
||||
td/utils/GitInfo.cpp
|
||||
td/utils/Gzip.cpp
|
||||
td/utils/GzipByteFlow.cpp
|
||||
td/utils/Hints.cpp
|
||||
@ -218,7 +217,6 @@ set(TDUTILS_SOURCE
|
||||
td/utils/FloodControlGlobal.h
|
||||
td/utils/FloodControlStrict.h
|
||||
td/utils/format.h
|
||||
td/utils/GitInfo.h
|
||||
td/utils/Gzip.h
|
||||
td/utils/GzipByteFlow.h
|
||||
td/utils/Hash.h
|
||||
@ -342,16 +340,6 @@ set(TDUTILS_TEST_SOURCE
|
||||
#LIBRARIES
|
||||
add_library(tdutils STATIC ${TDUTILS_SOURCE})
|
||||
|
||||
if (DEFINED TD_GIT_COMMIT)
|
||||
# this forces the whole tdutils to be recompiled after each commit with Makefile generator as explained at
|
||||
# https://cmake.org/pipermail/cmake-developers/2012-October/005411.html,
|
||||
# so this can't be improved for production-ready state
|
||||
set_property(SOURCE td/utils/GitInfo.cpp APPEND PROPERTY COMPILE_DEFINITIONS "GIT_COMMIT=\"${TD_GIT_COMMIT}\"")
|
||||
endif()
|
||||
if (DEFINED TD_GIT_DIRTY)
|
||||
set_property(SOURCE td/utils/GitInfo.cpp APPEND PROPERTY COMPILE_DEFINITIONS "GIT_DIRTY=true")
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CROSSCOMPILING AND TDUTILS_MIME_TYPE)
|
||||
add_dependencies(tdutils tdmime_auto)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user