Remove get_version.sh (#344)

This commit is contained in:
An Tao 2020-02-06 22:13:50 +08:00 committed by GitHub
parent dd5e8f8159
commit 3d8c304a47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 44 deletions

View File

@ -13,7 +13,7 @@ set(DROGON_MINOR_VERSION 0)
set(DROGON_PATCH_VERSION 0)
set(DROGON_VERSION
${DROGON_MAJOR_VERSION}.${DROGON_MINOR_VERSION}.${DROGON_PATCH_VERSION})
set(PRE_RELEASE_STRING "beta13")
set(DROGON_VERSION_STRING "${DROGON_VERSION}.beta13")
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
@ -268,17 +268,12 @@ if(BUILD_ORM)
endif()
endif()
add_custom_target(makeVersion)
add_custom_command(TARGET makeVersion
COMMAND ${PROJECT_SOURCE_DIR}/get_version.sh
ARGS
${PROJECT_SOURCE_DIR}/lib/inc/drogon/version.h
${DROGON_MAJOR_VERSION}
${DROGON_MINOR_VERSION}
${DROGON_PATCH_VERSION}
${PRE_RELEASE_STRING}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
VERBATIM)
execute_process(COMMAND "git" rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/version.h.in"
"${PROJECT_SOURCE_DIR}/lib/inc/drogon/version.h" @ONLY)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
@ -316,8 +311,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME Drogon)
add_dependencies(${PROJECT_NAME} makeVersion)
if(PostgreSQL_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND)
if(PostgreSQL_FOUND)
option(USE_POSTGRESQL "Enable PostgreSQL" ON)

View File

@ -0,0 +1,5 @@
#define MAJOR @DROGON_MAJOR_VERSION@
#define MINOR @DROGON_MINOR_VERSION@
#define PATCH @DROGON_PATCH_VERSION@
#define DROGON_VERSION "@DROGON_VERSION_STRING@"
#define DROGON_VERSION_SHA1 "@GIT_SHA1@"

View File

@ -37,7 +37,6 @@ target_link_libraries(drogon_ctl PRIVATE ${PROJECT_NAME})
target_include_directories(drogon_ctl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(drogon_ctl
trantor
makeVersion
_drogon_ctl)
if(WIN32)
target_link_libraries(drogon_ctl PRIVATE ws2_32 Rpcrt4)

View File

@ -30,8 +30,8 @@ void version::handleCommand(std::vector<std::string> &parameters)
{
std::cout << banner << std::endl;
std::cout << "A utility for drogon" << std::endl;
std::cout << "Version:" << VERSION << std::endl;
std::cout << "Git commit:" << VERSION_MD5 << std::endl;
std::cout << "Compile config:" << COMPILATION_FLAGS << " " << INCLUDING_DIRS
std::cout << "Version: " << DROGON_VERSION << std::endl;
std::cout << "Git commit: " << DROGON_VERSION_SHA1 << std::endl;
std::cout << "Compile config: " << COMPILATION_FLAGS << " " << INCLUDING_DIRS
<< std::endl;
}

View File

@ -1,24 +0,0 @@
#!/bin/sh
GIT_VER=$(git log|grep ^commit|wc -l|sed -e "s/^ *//")
MD5=$(git log|head -1|awk '{printf $2}')
TMP_FILE=/tmp/version
echo "#define MAJOR $2" > ${TMP_FILE}
echo "#define MINOR $3" >> ${TMP_FILE}
echo "#define PATCH $4" >> ${TMP_FILE}
if [ $# -gt 4 ];then
echo "#define VERSION \"$2.$3.$4.$5.$GIT_VER\"" >> ${TMP_FILE}
else
echo "#define VERSION \"$2.$3.$4.$GIT_VER\"" >> ${TMP_FILE}
fi
echo "#define VERSION_MD5 \"$MD5\"" >> ${TMP_FILE}
if [ ! -f $1 ];then
mv -f ${TMP_FILE} $1
else
diff ${TMP_FILE} $1
if [ $? -eq 1 ];then
mv -f ${TMP_FILE} $1
else
rm -f ${TMP_FILE}
fi
fi

View File

@ -98,11 +98,11 @@ namespace drogon
{
std::string getVersion()
{
return VERSION;
return DROGON_VERSION;
}
std::string getGitCommit()
{
return VERSION_MD5;
return DROGON_VERSION_SHA1;
}
} // namespace drogon
static void godaemon(void)

View File

@ -20,6 +20,7 @@
#include "HttpAppFrameworkImpl.h"
#include "FiltersFunction.h"
#include <algorithm>
#include <cctype>
using namespace drogon;