odissey: show version as a git commit

This commit is contained in:
Dmitry Simonenko 2017-01-27 15:35:41 +03:00
parent e3de9a7d9f
commit b19854148a
6 changed files with 25 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.o
core/odissey
core/od_build.h

View File

@ -5,7 +5,7 @@ project(odissey)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake)
execute_process(COMMAND git describe --always OUTPUT_VARIABLE GIT_VERSION
execute_process(COMMAND git describe --always OUTPUT_VARIABLE OD_GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -g")
@ -38,7 +38,7 @@ set(od_libraries ${od_libraries} ${SOPRANO_LIBRARIES})
include_directories(${SOPRANO_INCLUDE_DIRS})
message (STATUS "")
message (STATUS "ODISSEY (build: ${GIT_VERSION})")
message (STATUS "ODISSEY (build: ${OD_GIT_VERSION})")
message (STATUS "")
add_subdirectory(core)

View File

@ -25,6 +25,8 @@ set(od_src
od_be.c
odissey.c)
configure_file("od_build.h.cmake" "od_build.h")
include_directories("${PROJECT_SOURCE_DIR}/core")
include_directories("${PROJECT_BINARY_DIR}/core")
@ -37,3 +39,4 @@ if(THREADS_HAVE_PTHREAD_ARG)
endif()
target_link_libraries(${od_binary} ${od_libraries} ${CMAKE_THREAD_LIBS_INIT})

View File

@ -15,6 +15,7 @@
#include <soprano.h>
#include "od_macro.h"
#include "od_build.h"
#include "od_list.h"
#include "od_pid.h"
#include "od_syslog.h"
@ -55,7 +56,7 @@ void od_free(od_t *od)
static inline void
od_usage(od_t *od, char *path)
{
od_log(&od->log, NULL, "odissey.");
od_log(&od->log, NULL, "odissey (version: %s)", OD_GIT_VERSION);
od_log(&od->log, NULL, "usage: %s <config_file>", path);
}
@ -73,10 +74,6 @@ int od_main(od_t *od, int argc, char **argv)
od_usage(od, argv[0]);
return 0;
}
if (strcmp(argv[1], "-v") == 0 ||
strcmp(argv[1], "--version") == 0) {
return 0;
}
config_file = argv[1];
}
/* read config file */
@ -112,7 +109,7 @@ int od_main(od_t *od, int argc, char **argv)
od->scheme.syslog_ident,
od->scheme.syslog_facility);
}
od_log(&od->log, NULL, "odissey.");
od_log(&od->log, NULL, "odissey (version: %s)", OD_GIT_VERSION);
od_log(&od->log, NULL, "");
/* validate configuration scheme */
rc = od_schemevalidate(&od->scheme, &od->log);

12
core/od_build.h.cmake Normal file
View File

@ -0,0 +1,12 @@
#ifndef OD_BUILD_H_
#define OD_BUILD_H_
/*
* odissey.
*
* PostgreSQL connection pooler and request router.
*/
#cmakedefine OD_GIT_VERSION "@OD_GIT_VERSION@"
#endif

View File

@ -2,7 +2,7 @@
#
odissey {
log_verbosity 2
log_verbosity 5
# log_file "./odissey.log"
# pid_file "./odissey.pid"
# syslog no
@ -37,6 +37,7 @@ odissey {
# default {
# route "default"
# user "user"
# password "test"
# database "database"
# pool_min 0
# pool_max 100
@ -47,8 +48,8 @@ odissey {
users {
default {
authentication "md5"
password "test"
authentication "none"
#password "test"
}
}
}