From a548fcd709d685fad65d3fc07d336a19d1a0f2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Thu, 30 Sep 2021 11:27:42 +0800 Subject: [PATCH] Feature/dev (#1143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 防止每次cmake后导致重复编译 --- server/main.cpp | 2 +- src/Common/config.cpp | 20 ++++++++++---------- src/Common/macros.cpp | 23 +++++++++++++++++++++++ src/Common/macros.h | 13 ++----------- version.h.ini | 2 +- 5 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 src/Common/macros.cpp diff --git a/server/main.cpp b/server/main.cpp index 0c06a44b..0a1110ea 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -159,7 +159,7 @@ public: [](const std::shared_ptr &stream, const string &arg) -> bool { //版本信息 *stream << "编译日期: " << BUILD_TIME << std::endl; - *stream << "当前git分支: " << BRANCH_TIME << std::endl; + *stream << "当前git分支: " << BRANCH_NAME << std::endl; *stream << "当前git hash值: " << COMMIT_HASH << std::endl; throw ExitException(); }); diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 2b3db74a..825b1702 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -133,16 +133,16 @@ onceToken token([](){ #endif mINI::Instance()[kRootPath] = "./www"; - mINI::Instance()[kNotFound] = - "" - "404 Not Found" - "" - "

您访问的资源不存在!

" - "
" - SERVER_NAME - "
" - "" - ""; + mINI::Instance()[kNotFound] = StrPrinter << "" + "404 Not Found" + "" + "

您访问的资源不存在!

" + "
" + << SERVER_NAME + << "
" + "" + "" + << endl; },nullptr); }//namespace Http diff --git a/src/Common/macros.cpp b/src/Common/macros.cpp new file mode 100644 index 00000000..76a83899 --- /dev/null +++ b/src/Common/macros.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. + * + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). + * + * Use of this source code is governed by MIT license that can be found in the + * LICENSE file in the root of the source tree. All contributing project authors + * may be found in the AUTHORS file in the root of the source tree. + */ + +#include "macros.h" + +#if defined(ENABLE_VERSION) +#include "Version.h" +#endif + +//请遵循MIT协议,勿修改服务器声明 +#if !defined(ENABLE_VERSION) +const char SERVER_NAME[] = "ZLMediaKit-6.0(build in " __DATE__ " " __TIME__ ")"; +#else +const char SERVER_NAME[] = "ZLMediaKit(git hash:" COMMIT_HASH ",branch:" BRANCH_NAME ",build time:" __DATE__ " " __TIME__ ")"; +#endif + diff --git a/src/Common/macros.h b/src/Common/macros.h index 183495a3..472d4f7b 100644 --- a/src/Common/macros.h +++ b/src/Common/macros.h @@ -11,10 +11,6 @@ #ifndef ZLMEDIAKIT_MACROS_H #define ZLMEDIAKIT_MACROS_H -#if defined(ENABLE_VERSION) -#include "Version.h" -#endif - #if defined(__MACH__) #include #include @@ -57,13 +53,6 @@ #define CLEAR_ARR(arr) for(auto &item : arr){ item = 0;} #endif //CLEAR_ARR -//请遵循MIT协议,勿修改服务器声明 -#if !defined(ENABLE_VERSION) -#define SERVER_NAME "ZLMediaKit-6.0(build in " __DATE__ " " __TIME__ ")" -#else -#define SERVER_NAME "ZLMediaKit(git hash:" COMMIT_HASH ",branch:" BRANCH_TIME ",build time:" __DATE__ " " __TIME__ ")" -#endif - #define VHOST_KEY "vhost" #define HTTP_SCHEMA "http" #define RTSP_SCHEMA "rtsp" @@ -73,6 +62,8 @@ #define FMP4_SCHEMA "fmp4" #define DEFAULT_VHOST "__defaultVhost__" +extern const char SERVER_NAME[]; + #ifdef __cplusplus extern "C" { #endif diff --git a/version.h.ini b/version.h.ini index debf0207..c806f63d 100644 --- a/version.h.ini +++ b/version.h.ini @@ -2,7 +2,7 @@ #define __GIT_VERSION_H__ #define COMMIT_HASH "@COMMIT_HASH@" -#define BRANCH_TIME "@BRANCH_NAME@" +#define BRANCH_NAME "@BRANCH_NAME@" #define BUILD_TIME "@BUILD_TIME@" #endif //__GIT_VERSION_H__