add version
This commit is contained in:
parent
324c7e5857
commit
3578674fa5
|
@ -34,3 +34,4 @@
|
|||
build
|
||||
cmake-build-debug
|
||||
.idea
|
||||
version.h
|
||||
|
|
|
@ -43,11 +43,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${CMAKE_CXX_STD_FLAGS} -g -ggdb -Wa
|
|||
|
||||
MESSAGE(STATUS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
add_subdirectory(trantor)
|
||||
|
||||
|
||||
add_subdirectory(trantor)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/trantor ${PROJECT_SOURCE_DIR}/lib/inc)
|
||||
|
||||
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
|
||||
VERBATIM )
|
||||
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory(drogon_ctl)
|
||||
|
||||
aux_source_directory(${PROJECT_SOURCE_DIR}/lib/src DIR_SRCS)
|
||||
|
||||
|
@ -61,6 +69,7 @@ file(GLOB trantor_net_headers "${CMAKE_CURRENT_SOURCE_DIR}/lib/inc/drogon/*.h")
|
|||
install(FILES ${trantor_net_headers} DESTINATION include/drogon)
|
||||
|
||||
add_dependencies(drogon trantor)
|
||||
add_dependencies(drogon makeVersion)
|
||||
|
||||
if (MAKETEST STREQUAL YES)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#link_libraries(drogon trantor uuid pthread jsoncpp)
|
||||
AUX_SOURCE_DIRECTORY(. SRC_DIR)
|
||||
add_executable(drogon_ctl ${SRC_DIR})
|
||||
install(TARGETS drogon_ctl DESTINATION bin)
|
|
@ -0,0 +1,28 @@
|
|||
#include <drogon/version.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
static const char banner[]=" _ \n"
|
||||
" __| |_ __ ___ __ _ ___ _ __ \n"
|
||||
" / _` | '__/ _ \\ / _` |/ _ \\| '_ \\ \n"
|
||||
"| (_| | | | (_) | (_| | (_) | | | |\n"
|
||||
" \\__,_|_| \\___/ \\__, |\\___/|_| |_|\n"
|
||||
" |___/ \n";
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
{
|
||||
std::cout<<"usage:"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::string command=argv[1];
|
||||
if(command=="version")
|
||||
{
|
||||
std::cout<<banner<<std::endl;
|
||||
std::cout<<"drogon ctl tools"<<std::endl;
|
||||
std::cout<<"version:"<<VERSION<<std::endl;
|
||||
std::cout<<"git commit:"<<VERSION_MD5<<std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
GIT_VER=`git log|grep commit|wc -l`
|
||||
MD5=`git log|head -1|awk '{printf $2}'`
|
||||
TMP_FILE=/tmp/version
|
||||
echo "#define VERSION \"0.1.0.$GIT_VER\"" > $TMP_FILE
|
||||
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
|
||||
fi
|
||||
fi
|
|
@ -26,7 +26,8 @@
|
|||
namespace drogon
|
||||
{
|
||||
|
||||
|
||||
inline std::string getVersion();
|
||||
inline std::string getGitCommit();
|
||||
class HttpAppFramework:public trantor::NonCopyable
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <drogon/HttpSimpleController.h>
|
||||
|
||||
#include <drogon/version.h>
|
||||
namespace drogon
|
||||
{
|
||||
|
||||
|
@ -351,5 +351,13 @@ HttpAppFramework::~HttpAppFramework()
|
|||
|
||||
}
|
||||
|
||||
inline std::string getVersion()
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
inline std::string getGitCommit()
|
||||
{
|
||||
return VERSION_MD5;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue