fix: versioning

This commit is contained in:
Tobias Reisinger 2020-06-17 01:52:06 +02:00
parent 4d28033073
commit 486b45c680
3 changed files with 18 additions and 7 deletions

View file

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project(core
VERSION 0.1.0
VERSION 0.1.1
LANGUAGES C)
add_executable(core src/main.c)
@ -10,7 +10,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage")
add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC")
add_definitions("-DEMGAUWA_CORE_VERSION=${CMAKE_PROJECT_VERSION}")
aux_source_directory(src/ SRC_DIR)
aux_source_directory(src/models MODELS_SRC)
@ -21,10 +20,12 @@ aux_source_directory(src/endpoints ENDPOINTS_SRC)
add_dependencies(core migrations)
configure_file("core.ini" "core.ini" COPYONLY)
configure_file("version.h.in" "version.h" @ONLY)
target_sources(core PRIVATE ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC})
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
target_include_directories(core PRIVATE ${CMAKE_BINARY_DIR})
add_custom_target(migrations
COMMAND ./compile_migrations.sh
@ -34,17 +35,17 @@ add_custom_target(migrations
add_custom_target(run
COMMAND ./core start
DEPENDS core
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(debug
COMMAND valgrind ./core start
DEPENDS core
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(debug-full
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start
DEPENDS core
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(docs
COMMAND doxygen

View file

@ -6,6 +6,7 @@
#include <config.h>
#include <logger.h>
#include <helpers.h>
#include <version.h>
static const char *const usage[] = {
"core [options] [[--] args]",
@ -16,12 +17,13 @@ static const char *const usage[] = {
void
helper_parse_cli(int argc, const char **argv, config_t *config)
{
int version = 0;
struct argparse_option options[] =
{
OPT_HELP(),
OPT_GROUP("Basic options"),
OPT_STRING('c', "config", &config->file, "path to config file", NULL, 0, OPT_NONEG),
OPT_BOOLEAN('v', "version", &version, "print version", NULL, 0, OPT_NONEG),
OPT_END(),
};
@ -34,6 +36,12 @@ helper_parse_cli(int argc, const char **argv, config_t *config)
);
argc = argparse_parse(&argparse, argc, argv);
if(version)
{
printf("%s\n", EMGAUWA_CORE_VERSION);
exit(0);
}
if(argc == 1)
{
config->run_type = RUN_TYPE_INVALID;

2
version.h.in Normal file
View file

@ -0,0 +1,2 @@
#define EMGAUWA_CORE_VERSION "@CMAKE_PROJECT_VERSION@"