diff --git a/CMakeLists.txt b/CMakeLists.txt index a6a9ea7a..94884e2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,11 +97,12 @@ set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR}) set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR}) # 添加 git 版本信息 -set(COMMIT_HASH "Git_NotFound_Unkown_commit") -set(BRANCH_NAME "Git_NotFound_Unkown_branch") +set(COMMIT_HASH "Git_Unkown_commit") +set(COMMIT_TIME "Git_Unkown_time") +set(BRANCH_NAME "Git_Unkown_branch") 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) if(GIT_FOUND) @@ -117,6 +118,13 @@ if(GIT_FOUND) OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET 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() configure_file( @@ -124,7 +132,7 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/version.h @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}") ############################################################################## diff --git a/server/main.cpp b/server/main.cpp index a83e4f13..7c96c5a1 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -222,6 +222,9 @@ int start_main(int argc,char *argv[]) { //启动异步日志线程 Logger::Instance().setWriter(std::make_shared()); + + InfoL << kServerName; + //加载配置文件,如果配置文件不存在就创建一个 loadIniConfig(g_ini_file.data()); diff --git a/src/Common/macros.cpp b/src/Common/macros.cpp index e6a43699..26c4ab80 100644 --- a/src/Common/macros.cpp +++ b/src/Common/macros.cpp @@ -35,9 +35,9 @@ namespace mediakit { //请遵循MIT协议,勿修改服务器声明 #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 -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 }//namespace mediakit \ No newline at end of file diff --git a/version.h.ini b/version.h.ini index c806f63d..cb685ec2 100644 --- a/version.h.ini +++ b/version.h.ini @@ -2,6 +2,7 @@ #define __GIT_VERSION_H__ #define COMMIT_HASH "@COMMIT_HASH@" +#define COMMIT_TIME "@COMMIT_TIME@" #define BRANCH_NAME "@BRANCH_NAME@" #define BUILD_TIME "@BUILD_TIME@"