add: version.h
fix: refactor
This commit is contained in:
parent
532750da74
commit
f5f9be803c
36 changed files with 27 additions and 34 deletions
|
@ -1,11 +1,13 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project(controller)
|
||||
project(controller
|
||||
VERSION 0.1.0
|
||||
LANGUAGES C)
|
||||
|
||||
add_executable(controller main.c)
|
||||
add_executable(controller src/main.c)
|
||||
|
||||
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -lwiringPi -lwiringPiDev -luuid -llmdb -ffile-prefix-map=${CMAKE_SOURCE_DIR}/=/")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -lwiringPi -lwiringPiDev -luuid -llmdb -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=")
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage")
|
||||
|
||||
|
@ -14,34 +16,34 @@ if(WIRING_PI_DEBUG)
|
|||
add_definitions("-DWIRING_PI_DEBUG")
|
||||
endif(WIRING_PI_DEBUG)
|
||||
|
||||
aux_source_directory(vendor VENDOR_SRC) # vendor first to put their warnings on top
|
||||
aux_source_directory(. SRC_DIR)
|
||||
aux_source_directory(models MODELS_SRC)
|
||||
aux_source_directory(helpers HELPERS_SRC)
|
||||
aux_source_directory(handlers HANDLERS_SRC)
|
||||
aux_source_directory(drivers DRIVERS_SRC)
|
||||
aux_source_directory(runners RUNNERS_SRC)
|
||||
aux_source_directory(src/ SRC_DIR)
|
||||
aux_source_directory(src/models MODELS_SRC)
|
||||
aux_source_directory(src/helpers HELPERS_SRC)
|
||||
aux_source_directory(src/handlers HANDLERS_SRC)
|
||||
aux_source_directory(src/drivers DRIVERS_SRC)
|
||||
aux_source_directory(src/runners RUNNERS_SRC)
|
||||
|
||||
configure_file("controller.ini" "controller.ini" COPYONLY)
|
||||
configure_file("version.h.in" "version.h" @ONLY)
|
||||
|
||||
target_sources(controller PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${MODELS_SRC} ${HELPERS_SRC} ${HANDLERS_SRC} ${DRIVERS_SRC} ${RUNNERS_SRC})
|
||||
target_sources(controller PRIVATE ${SRC_DIR} ${MODELS_SRC} ${HELPERS_SRC} ${HANDLERS_SRC} ${DRIVERS_SRC} ${RUNNERS_SRC})
|
||||
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
|
||||
target_include_directories(controller PRIVATE ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_custom_target(run
|
||||
COMMAND ./controller start
|
||||
DEPENDS controller
|
||||
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(debug
|
||||
COMMAND valgrind ./controller start
|
||||
DEPENDS controller
|
||||
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(debug-full
|
||||
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./controller start
|
||||
DEPENDS controller
|
||||
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(docs
|
||||
COMMAND doxygen
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <config.h>
|
||||
#include <logger.h>
|
||||
#include <helpers.h>
|
||||
#include <version.h>
|
||||
|
||||
static const char *const usage[] = {
|
||||
"controller [options] [[--] args]",
|
||||
|
@ -20,12 +21,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(),
|
||||
};
|
||||
|
||||
|
@ -38,6 +40,12 @@ helper_parse_cli(int argc, const char **argv, config_t *config)
|
|||
);
|
||||
argc = argparse_parse(&argparse, argc, argv);
|
||||
|
||||
if(version)
|
||||
{
|
||||
printf("%s\n", EMGAUWA_CONTROLLER_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(argc == 1)
|
||||
{
|
||||
if(strcmp(argv[0], "start") == 0)
|
|
@ -1,18 +0,0 @@
|
|||
set(CMAKE_C_COMPILER /usr/bin/arm-none-eabi-gcc)
|
||||
set(CMAKE_C_COMPILER_WORKS 1)
|
||||
|
||||
set(ARM-SYSROOT /usr/arm-none-eabi)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk+fp")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=arm1176jzf-s")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=arm1176jzf-s")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${ARM-SYSROOT}" CACHE INTERNAL "" FORCE)
|
||||
|
||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${ARM-SYSROOT}" CACHE INTERNAL "" FORCE)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${ARM-SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
1
version.h.in
Normal file
1
version.h.in
Normal file
|
@ -0,0 +1 @@
|
|||
#define EMGAUWA_CONTROLLER_VERSION "@CMAKE_PROJECT_VERSION@"
|
Loading…
Reference in a new issue