Commit 44fd6b86 by xiongziliang

完善版本信息

parent 04e2952d
...@@ -97,11 +97,12 @@ set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR}) ...@@ -97,11 +97,12 @@ set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR})
set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR}) set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR})
# 添加 git 版本信息 # 添加 git 版本信息
set(COMMIT_HASH "Git_NotFound_Unkown_commit") set(COMMIT_HASH "Git_Unkown_commit")
set(BRANCH_NAME "Git_NotFound_Unkown_branch") set(COMMIT_TIME "Git_Unkown_time")
set(BRANCH_NAME "Git_Unkown_branch")
set(BUILD_TIME "") set(BUILD_TIME "")
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M:%S") string(TIMESTAMP BUILD_TIME "%Y-%m-%dT%H:%M:%S")
find_package(Git QUIET) find_package(Git QUIET)
if(GIT_FOUND) if(GIT_FOUND)
...@@ -117,6 +118,13 @@ if(GIT_FOUND) ...@@ -117,6 +118,13 @@ if(GIT_FOUND)
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(
COMMAND ${GIT_EXECUTABLE} log --format=format:%aI -1
OUTPUT_VARIABLE COMMIT_TIME
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif() endif()
configure_file( configure_file(
...@@ -124,7 +132,7 @@ configure_file( ...@@ -124,7 +132,7 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/version.h
@ONLY) @ONLY)
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}") message(STATUS "Git version is ${BRANCH_NAME} ${COMMIT_HASH}/${COMMIT_TIME} ${BUILD_TIME}")
############################################################################## ##############################################################################
......
...@@ -222,6 +222,9 @@ int start_main(int argc,char *argv[]) { ...@@ -222,6 +222,9 @@ int start_main(int argc,char *argv[]) {
//启动异步日志线程 //启动异步日志线程
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>()); Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
InfoL << kServerName;
//加载配置文件,如果配置文件不存在就创建一个 //加载配置文件,如果配置文件不存在就创建一个
loadIniConfig(g_ini_file.data()); loadIniConfig(g_ini_file.data());
......
...@@ -35,9 +35,9 @@ namespace mediakit { ...@@ -35,9 +35,9 @@ namespace mediakit {
//请遵循MIT协议,勿修改服务器声明 //请遵循MIT协议,勿修改服务器声明
#if !defined(ENABLE_VERSION) #if !defined(ENABLE_VERSION)
const char kServerName[] = "ZLMediaKit-6.0(build in " __DATE__ " " __TIME__ ")"; const char kServerName[] = "ZLMediaKit-7.0(build in " __DATE__ " " __TIME__ ")";
#else #else
const char kServerName[] = "ZLMediaKit(git hash:" COMMIT_HASH ",branch:" BRANCH_NAME ",build time:" __DATE__ " " __TIME__ ")"; const char kServerName[] = "ZLMediaKit(git hash:" COMMIT_HASH "/" COMMIT_TIME ",branch:" BRANCH_NAME ",build time:" BUILD_TIME ")";
#endif #endif
}//namespace mediakit }//namespace mediakit
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __GIT_VERSION_H__ #define __GIT_VERSION_H__
#define COMMIT_HASH "@COMMIT_HASH@" #define COMMIT_HASH "@COMMIT_HASH@"
#define COMMIT_TIME "@COMMIT_TIME@"
#define BRANCH_NAME "@BRANCH_NAME@" #define BRANCH_NAME "@BRANCH_NAME@"
#define BUILD_TIME "@BUILD_TIME@" #define BUILD_TIME "@BUILD_TIME@"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论