1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2025-01-03 06:55:23 +01:00

Added version information

This commit is contained in:
Ralf Ramsauer 2015-09-23 15:47:52 +02:00
parent 201ffe1e44
commit 32ebec327d
3 changed files with 43 additions and 1 deletions

View File

@ -3,6 +3,32 @@ project(doorlockd)
option(USE_COLORIZED_LOGS "Colorized logging" ON) option(USE_COLORIZED_LOGS "Colorized logging" ON)
set(DOORLOCKD_VERSION_MAJOR 1)
set(DOORLOCKD_VERSION_MINOR 0)
set(DOORLOCKD_VERSION_PATCH 0)
set(DOORLOCKD_VERSION "${DOORLOCKD_VERSION_MAJOR}.${DOORLOCKD_VERSION_MINOR}.${DOORLOCKD_VERSION_PATCH}")
MESSAGE(STATUS "doorlockd version: ${DOORLOCKD_VERSION}")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(GIT_BRANCH "\"${GIT_BRANCH}\"")
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(GIT_COMMIT_HASH "\"${GIT_COMMIT_HASH}\"")
add_definitions(-std=c++11) add_definitions(-std=c++11)
configure_file ( configure_file (

View File

@ -3,6 +3,13 @@
#cmakedefine USE_COLORIZED_LOGS #cmakedefine USE_COLORIZED_LOGS
#define DOORLOCKD_VERSION_MAJOR "@DOORLOCKD_VERSION_MAJOR@"
#define DOORLOCKD_VERSION_MINOR "@DOORLOCKD_VERSION_MINOR@"
#define DOORLOCKD_VERSION_PATCH "@DOORLOCKD_VERSION_PATCH@"
#define DOORLOCKD_GIT_BRANCH @GIT_BRANCH@
#define DOORLOCKD_GIT_COMMIT_HASH @GIT_COMMIT_HASH@
#ifdef DEBUG #ifdef DEBUG
#define DEFAULT_LOG_LEVEL LogLevel::debug2 #define DEFAULT_LOG_LEVEL LogLevel::debug2
#else #else

View File

@ -18,6 +18,13 @@
namespace po = boost::program_options; namespace po = boost::program_options;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
// Info about doorlockd version
const static std::string version =
(std::string)"doorlockd-" + DOORLOCKD_VERSION_MAJOR + "."
+ DOORLOCKD_VERSION_MINOR + "-" + DOORLOCKD_VERSION_PATCH;
const static std::string gitversion =
DOORLOCKD_GIT_BRANCH "-" DOORLOCKD_GIT_COMMIT_HASH;
// The receive buffer length of the TCP socket // The receive buffer length of the TCP socket
const int constexpr SOCKET_BUFFERLENGTH = 2048; const int constexpr SOCKET_BUFFERLENGTH = 2048;
@ -139,11 +146,13 @@ int main(int argc, char** argv)
std::string serDev; std::string serDev;
unsigned int baudrate; unsigned int baudrate;
l((std::string)"Hello, this is " + version + " built on " + gitversion,
LogLevel::info);
l(LogLevel::notice, "Starting doorlockd"); l(LogLevel::notice, "Starting doorlockd");
try { try {
unsigned int timeout; unsigned int timeout;
po::options_description desc("usage: doorlockd"); po::options_description desc("doorlockd (" + version + " built on " + gitversion + ")");
desc.add_options() desc.add_options()
("help,h", ("help,h",
"print help") "print help")