From 179aa2d5535d3098d0a3a0e49c773e1212917d10 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 21 Jun 2018 09:36:49 +0200 Subject: [PATCH 01/40] cmake: add new CMakeLists.txt --- CMakeLists.txt | 104 ++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 128 +++++++++++++++++++++++++++++++++++++ lib/api/CMakeLists.txt | 42 ++++++++++++ lib/formats/CMakeLists.txt | 82 ++++++++++++++++++++++++ lib/hooks/CMakeLists.txt | 57 +++++++++++++++++ lib/nodes/CMakeLists.txt | 48 ++++++++++++++ src/CMakeLists.txt | 16 +++++ tools/CMakeLists.txt | 42 ++++++++++++ 8 files changed, 519 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 lib/CMakeLists.txt create mode 100644 lib/api/CMakeLists.txt create mode 100644 lib/formats/CMakeLists.txt create mode 100644 lib/hooks/CMakeLists.txt create mode 100644 lib/nodes/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 tools/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..819dded48 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,104 @@ +# Main CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +cmake_minimum_required(VERSION 3.0) + +project(VILLASnode) + +set(CMAKE_C_STANDARD 11) + +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) + +find_package(PkgConfig) +include(CheckIncludeFile) + +# Check OS +check_include_file("sys/eventfd.h" HAS_EVENTFD) + +# Build options +option(WITH_HOOKS "Build with support for processing hook plugins" ON) +option(WITH_IO "Build with support format plugins" ON) +option(WITH_WEB "Build with internal webserver" ON) +option(WITH_API "Build with remote control API" ON) +option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON) + +set(V 2) +set(PREFIX ${CMAKE_INSTALL_PREFIX}) + +set(VARIANT "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + +# Add git revision and build variant defines +execute_process( + COMMAND git describe --tags --abbrev=0 --match "v*" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(SUBSTRING ${VERSION} 2 -1 VERSION_NUM) + +string(TIMESTAMP BUILD_DATE "%Y%m%d") + +if(DEFINED ENV{CI}) + string(APPEND VARIANT "-ci") + string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 GIT_REV) + set(GIT_BRANCH ${CI_COMMIT_REF_NAME}) +else() + execute_process( + COMMAND git rev-parse --short=7 HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REV + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +if(DEFINED ENV{CI_COMMIT_TAG}) + set(RELEASE 1) +else() + string(REPLACE "-" "_" GIT_BRANCH_NORM ${GIT_BRANCH}) + string(REPLACE "-" "_" VARIANT_NORM ${VARIANT}) + + set(RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}") +endif() + +set(BUILDID "${VERSION}-${GIT_REV}-${VARIANT}") + +configure_file( + ${CMAKE_SOURCE_DIR}/include/villas/config.h.in + ${CMAKE_BINARY_DIR}/include/villas/config.h +) + +include_directories( + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR}/include +) + +add_subdirectory(lib) +add_subdirectory(src) +add_subdirectory(tools) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 000000000..86f50325a --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,128 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +find_package(OpenSSL REQUIRED) +find_package(curl REQUIRED) + +pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) + +set(INCLUDE_DIRS + ${JANSSON_INCLUDE_DIRS} + ${OPENSSL_INCLUDE_DIR} + ${CURL_INCLUDE_DIRS} +) + +set(LIBRARIES + PkgConfig::JANSSON + ${OPENSSL_LIBRARIES} + ${CURL_LIBRARIES} +) + +set(LIB_SRC + kernel/kernel.c + kernel/rt.c + sample.c + path.c + node.c + log.c + log_config.c + utils.c + super_node.c + hist.c + timing.c + pool.c + list.c + queue.c + queue_signalled.c + memory.c + advio.c + plugin.c + node_type.c + stats.c + mapping.c + shmem.c + config_helper.c + crypt.c + compat.c + log_helper.c + task.c + buffer.c + table.c + bitset.c + signal.c +) + +add_subdirectory(nodes) + +if(WITH_CONFIG) + pkg_check_modules(CONFIG IMPORTED_TARGET REQUIRED libconfig) + + list(APPEND INCLUDE_DIRS ${CONFIG_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::CONFIG) +endif() + +if(WITH_IO) + list(APPEND LIB_SRC + io.c + format_type.c + ) + + add_subdirectory(formats) + list(APPEND LIBRARIES villas-formats) +endif() + +if(WITH_HOOKS) + list(APPEND LIB_SRC + hook.c + hook_type.c + ) + + add_subdirectory(hooks) + list(APPEND LIBRARIES villas-hooks) +endif() + +if(WITH_WEB) + list(APPEND LIB_SRC + web.c + ) + + find_package(libwebsockets REQUIRED) + + message("LWS: ${LIBWEBSOCKETS_LIBRARIES}") + + list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS}) + list(APPEND LIBRARIES websockets_shared) +endif() + +if(WITH_API AND WITH_WEB) + list(APPEND LIB_SRC + api.c + ) + + add_subdirectory(api) + list(APPEND LIBRARIES villas-api) +endif() + +add_library(villas SHARED ${LIB_SRC}) + +target_include_directories(villas PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(villas PUBLIC ${LIBRARIES}) diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt new file mode 100644 index 000000000..97cc687d8 --- /dev/null +++ b/lib/api/CMakeLists.txt @@ -0,0 +1,42 @@ + +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +find_package(openssl REQUIRED) + +set(INCLUDE_DIRS + ${OPENSSL_INCLUDE_DIR} +) + +set(LIBRARIES + ${OPENSSL_LIBRARIES} +) + +file(GLOB ACTION_SRC actions/*.c) + +add_library(villas-api STATIC + ${ACTION_SRC} + session.c +) + +target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(villas-api PUBLIC ${LIBRARIES}) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt new file mode 100644 index 000000000..33670bbd1 --- /dev/null +++ b/lib/formats/CMakeLists.txt @@ -0,0 +1,82 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(FORMAT_SRC + json.c + json_reserve.c + villas_binary.c + villas_human.c + csv.c + raw.c +) + +find_package(openssl REQUIRED) + +set(INCLUDE_DIRS + ${OPENSSL_INCLUDE_DIR} +) + +set(LIBRARIES + ${OPENSSL_LIBRARIES} +) + +# Enable Google Protobuf format +find_package(Protobuf) +if(Protobuf_FOUND) + list(APPEND FORMAT_SRC + protobuf.c + ${CMAKE_CURRENT_BINARY_DIR}/villas.pb-c.c + ) + + list(APPEND INCLUDE_DIRS + ${Protobuf_INCLUDE_DIRS} + ${Protobuf_PROTOC_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ) + + list(APPEND LIBRARIES + ${Protobuf_LIBRARY} + ${Protobuf_PROTOC_LIBRARIES} + ) + + set_source_files_properties(villas.pb-c.h villas.pb-c.c + PROPERTIES + GENERATED TRUE + ) + + add_custom_command( + COMMAND ${Protobuf_PROTOC_EXECUTABLE} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto + OUTPUT + villas.pb-c.c + villas.pb-c.h + MAIN_DEPENDENCY villas.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif() + +add_library(villas-formats STATIC ${FORMAT_SRC}) +target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(villas-formats PUBLIC ${LIBRARIES}) + +if(Protobuf_FOUND) +# add_dependencies(villas-formats villas.pb-c.c villas.pb-c.h) +endif() diff --git a/lib/hooks/CMakeLists.txt b/lib/hooks/CMakeLists.txt new file mode 100644 index 000000000..e49483d99 --- /dev/null +++ b/lib/hooks/CMakeLists.txt @@ -0,0 +1,57 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) + +set(INCLUDE_DIRS + ${JANSSON_INCLUDE_DIRS} +) + +set(LIBRARIES + PkgConfig::JANSSON +) + +set(HOOK_SRC + convert.c + decimate.c + drop.c + jitter_calc.c + map.c + restart.c + shift_seq.c + shift_ts.c + skip_first.c + stats.c + ts.c + limit_rate.c + scale.c +) + +if(WITH_IO) + list(APPEND HOOK_SRC + print.c + ) +endif() + +add_library(villas-hooks STATIC ${HOOK_SRC}) +target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(villas-hooks PUBLIC ${LIBRARIES}) diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt new file mode 100644 index 000000000..ce7ab8a36 --- /dev/null +++ b/lib/nodes/CMakeLists.txt @@ -0,0 +1,48 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) + +set(INCLUDE_DIRS + ${JANSSON_INCLUDE_DIRS} +) + +set(LIBRARIES + PkgConfig::JANSSON +) + +set(NODE_SRC + influxdb.c + stats.c + file.c +) + +if(HAS_EVENTFD) + list(APPEND NODE_SRC + loopback.c + cbuilder.c + ) +endif() + +add_library(villas-nodes STATIC ${NODE_SRC}) +target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(villas-nodes PUBLIC ${LIBRARIES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..ab489b07b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,16 @@ +link_libraries(villas) + +add_executable(villas-node node.c) +add_executable(villas-test-rtt test-rtt.c) +add_executable(villas-test-shmem test-shmem.c) + +if(WITH_IO) + add_executable(villas-test-cmp test-cmp.c) + add_executable(villas-convert convert.c) + add_executable(villas-pipe pipe.c) + add_executable(villas-signal signal.c) +endif() + +if(WITH_IO AND WITH_HOOKS) + add_executable(villas-hook hook.c) +endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 000000000..c04a4545d --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,42 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +if(WITH_CONFIG) + add_executable(conf2json conf2json.c) + + target_link_libraries(conf2json PUBLIC villas) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_executable(rmshm rmshm.c) + target_link_libraries(rmshm PUBLIC pthread rt) + + add_executable(rmsem rmsem.c) + target_link_libraries(rmsem PUBLIC pthread rt) +endif() + +pkg_check_modules(ZMQ IMPORTED_TARGET REQUIRED libzmq) +if(ZMQ_FOUND) + add_executable(zmq-keygen zmq-keygen.c) + target_include_directories(zmq-keygen PUBLIC ${ZMQ_INCLUDE_DIRS}) + target_link_libraries(zmq-keygen PUBLIC PkgConfig::ZMQ) +endif() From 58e4d7e394debbb4fbdfb0d946063d28dcfaac56 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 21 Jun 2018 09:37:01 +0200 Subject: [PATCH 02/40] cmake: add new defines to config.h.in --- include/villas/config.h.in | 14 ++++++++++++++ lib/path.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/villas/config.h.in b/include/villas/config.h.in index 419f0fa61..cf552bb6f 100644 --- a/include/villas/config.h.in +++ b/include/villas/config.h.in @@ -61,6 +61,20 @@ extern "C"{ #define KERNEL_VERSION_MAJ 3 #define KERNEL_VERSION_MIN 6 +#cmakedefine BUILDID "@BUILDID@" +#cmakedefine V @V@ +#cmakedefine PREFIX "@PREFIX@" + +/* Available Features */ +#cmakedefine WITH_WEB +#cmakedefine WITH_API +#cmakedefine WITH_HOOKS +#cmakedefine WITH_IO +#cmakedefine WITH_CONFIG + +/* OS Headers */ +#cmakedefine HAS_EVENTFD + #ifdef __cplusplus } #endif diff --git a/lib/path.c b/lib/path.c index 7763e1aa5..27e66861a 100644 --- a/lib/path.c +++ b/lib/path.c @@ -589,7 +589,7 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes) } } -#if WITH_HOOKS +#ifdef WITH_HOOKS if (json_hooks) { ret = hook_parse_list(&p->hooks, json_hooks, p, NULL); if (ret) From 4fa5914bc66340b23b0df88ceb96cb9688d16e8d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 21 Jun 2018 09:37:30 +0200 Subject: [PATCH 03/40] cmake: make use of HAS_EVENTFD --- include/villas/queue_signalled.h | 2 +- lib/queue_signalled.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/villas/queue_signalled.h b/include/villas/queue_signalled.h index 2d2a44fb3..9ad916b82 100644 --- a/include/villas/queue_signalled.h +++ b/include/villas/queue_signalled.h @@ -36,7 +36,7 @@ enum queue_signalled_flags { QUEUE_SIGNALLED_AUTO = (0 << 0), /**< We will choose the best method available on the platform */ QUEUE_SIGNALLED_PTHREAD = (1 << 0), QUEUE_SIGNALLED_POLLING = (2 << 0), -#ifdef __linux__ +#ifdef HAS_EVENTFD QUEUE_SIGNALLED_EVENTFD = (3 << 0), #elif defined(__APPLE__) QUEUE_SIGNALLED_PIPE = (3 << 0), diff --git a/lib/queue_signalled.c b/lib/queue_signalled.c index a37caa316..dc6d6f9f6 100644 --- a/lib/queue_signalled.c +++ b/lib/queue_signalled.c @@ -21,10 +21,11 @@ * along with this program. If not, see . *********************************************************************************/ +#include #include #include -#ifdef __linux__ +#ifdef HAS_EVENTFD #include #endif @@ -83,7 +84,7 @@ int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memtype else if (qs->mode == QUEUE_SIGNALLED_POLLING) { /* Nothing todo */ } -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { qs->eventfd = eventfd(0, 0); if (qs->eventfd < 0) @@ -117,7 +118,7 @@ int queue_signalled_destroy(struct queue_signalled *qs) else if (qs->mode == QUEUE_SIGNALLED_POLLING) { /* Nothing todo */ } -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { ret = close(qs->eventfd); if (ret) @@ -152,7 +153,7 @@ int queue_signalled_push(struct queue_signalled *qs, void *ptr) else if (qs->mode == QUEUE_SIGNALLED_POLLING) { /* Nothing todo */ } -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { int ret; uint64_t incr = 1; @@ -191,7 +192,7 @@ int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cn else if (qs->mode == QUEUE_SIGNALLED_POLLING) { /* Nothing todo */ } -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { int ret; uint64_t incr = 1; @@ -233,7 +234,7 @@ int queue_signalled_pull(struct queue_signalled *qs, void **ptr) pthread_cond_wait(&qs->pthread.ready, &qs->pthread.mutex); else if (qs->mode == QUEUE_SIGNALLED_POLLING) continue; /* Try again */ -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { int ret; uint64_t cntr; @@ -282,7 +283,7 @@ int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cn pthread_cond_wait(&qs->pthread.ready, &qs->pthread.mutex); else if (qs->mode == QUEUE_SIGNALLED_POLLING) continue; /* Try again */ -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { int ret; uint64_t cntr; @@ -328,7 +329,7 @@ int queue_signalled_close(struct queue_signalled *qs) else if (qs->mode == QUEUE_SIGNALLED_POLLING) { /* Nothing todo */ } -#ifdef __linux__ +#ifdef HAS_EVENTFD else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) { int ret; uint64_t incr = 1; @@ -356,7 +357,7 @@ int queue_signalled_close(struct queue_signalled *qs) int queue_signalled_fd(struct queue_signalled *qs) { switch (qs->mode) { -#ifdef __linux__ +#ifdef HAS_EVENTFD case QUEUE_SIGNALLED_EVENTFD: return qs->eventfd; #elif defined(__APPLE__) From 7dc1d0cb50bc1a23565943e59afad32a066130b7 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 23 Jun 2018 19:57:59 +0200 Subject: [PATCH 04/40] cmake: add feature summary --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 819dded48..11d0514e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) find_package(PkgConfig) include(CheckIncludeFile) +include(FeatureSummary) # Check OS check_include_file("sys/eventfd.h" HAS_EVENTFD) @@ -102,3 +103,15 @@ include_directories( add_subdirectory(lib) add_subdirectory(src) add_subdirectory(tools) + +# Show feature summary +add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") +add_feature_info(IO WITH_IO "Build with support format plugins") +add_feature_info(WEB WITH_WEB "Build with internal webserver") +add_feature_info(API WITH_API "Build with remote control API") +add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configuration syntax") + +if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + feature_summary(WHAT ALL VAR FEATURES) + message(STATUS "${FEATURES}") +endif() From e4e3fba8788efe3a4b6160938e9b0a5284943391 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 23 Jun 2018 19:58:39 +0200 Subject: [PATCH 05/40] cmake: add -Wall -Werror --- CMakeLists.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11d0514e8..f01160e05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,32 @@ set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) find_package(PkgConfig) include(CheckIncludeFile) include(FeatureSummary) +include(CheckCCompilerFlag) +#include(CheckCxxCompilerFlag) + +if(MSVC) + check_c_compiler_flag("/W4 /WX" C_SUPPORTS_WERROR) +# check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR) + + if(C_SUPPORTS_WERROR) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX") + endif() + + if(CXX_SUPPORTS_WERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX") + endif() +else() + check_c_compiler_flag("-Wall -Werror" C_SUPPORTS_WERROR) +# check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR) + + if(C_SUPPORTS_WERROR) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") + endif() + + if(CXX_SUPPORTS_WERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") + endif() +endif() # Check OS check_include_file("sys/eventfd.h" HAS_EVENTFD) From a224821791b695b83f1fea193e3f4a1f7deca65e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 23 Jun 2018 19:58:55 +0200 Subject: [PATCH 06/40] cmake: add more compiler flags --- CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f01160e05..a37609902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,28 @@ else() endif() endif() +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + string(APPEND VARIANTS "-debug") +else() + string(APPEND VARIANTS "-release") +endif() + +if(PROFILE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -pg") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") + + string(APPEND VARIANTS "-profile") +endif() + +if(COVERAGE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") + target_link_libraries("gcov") + + string(APPEND VARIANTS "-coverage") +endif() + # Check OS check_include_file("sys/eventfd.h" HAS_EVENTFD) From f585a94ebf1c931061b5ca135eb697b3d4c94f7b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 05:59:29 +0200 Subject: [PATCH 07/40] remove most of the old Makefiles --- Makefile | 182 --------------------------------- Makefile.config | 74 -------------- Makefile.help | 102 ------------------ clients/Makefile.inc | 32 ------ clients/opal/Makefile.inc | 46 --------- clients/python/Makefile.inc | 24 ----- doc/Makefile.inc | 33 ------ etc/Makefile.inc | 30 ------ lib/Makefile.inc | 64 ------------ lib/Makefile.villas-ext.inc | 54 ---------- lib/Makefile.villas.inc | 93 ----------------- lib/api/Makefile.inc | 25 ----- lib/api/actions/Makefile.inc | 23 ----- lib/formats/Makefile.inc | 41 -------- lib/hooks/Makefile.inc | 29 ------ packaging/Makefile.inc | 56 ---------- packaging/docker/Makefile.inc | 74 -------------- packaging/rpm/Makefile.inc | 44 -------- plugins/Makefile.inc | 55 ---------- src/Makefile.inc | 66 ------------ tests/Makefile.inc | 43 -------- tests/integration/Makefile.inc | 26 ----- tests/unit/Makefile.inc | 49 --------- tools/Makefile.inc | 61 ----------- web/Makefile.inc | 29 ------ 25 files changed, 1355 deletions(-) delete mode 100644 Makefile delete mode 100644 Makefile.config delete mode 100644 Makefile.help delete mode 100644 clients/Makefile.inc delete mode 100644 clients/opal/Makefile.inc delete mode 100644 clients/python/Makefile.inc delete mode 100644 doc/Makefile.inc delete mode 100644 etc/Makefile.inc delete mode 100644 lib/Makefile.inc delete mode 100644 lib/Makefile.villas-ext.inc delete mode 100644 lib/Makefile.villas.inc delete mode 100644 lib/api/Makefile.inc delete mode 100644 lib/api/actions/Makefile.inc delete mode 100644 lib/formats/Makefile.inc delete mode 100644 lib/hooks/Makefile.inc delete mode 100644 packaging/Makefile.inc delete mode 100644 packaging/docker/Makefile.inc delete mode 100644 packaging/rpm/Makefile.inc delete mode 100644 plugins/Makefile.inc delete mode 100644 src/Makefile.inc delete mode 100644 tests/Makefile.inc delete mode 100644 tests/integration/Makefile.inc delete mode 100644 tests/unit/Makefile.inc delete mode 100644 tools/Makefile.inc delete mode 100644 web/Makefile.inc diff --git a/Makefile b/Makefile deleted file mode 100644 index 23cc84d0f..000000000 --- a/Makefile +++ /dev/null @@ -1,182 +0,0 @@ -## Main project Makefile -# -# The build system of this project is based on GNU Make and pkg-config -# -# To retain maintainability, the project is divided into multiple modules. -# Each module has its own Makefile which gets included. -# -# Please read "Recursive Make Considered Harmful" from Peter Miller -# to understand the motivation for this structure. -# -# [1] http://aegis.sourceforge.net/auug97.pdf -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -# Project modules -MODULES = lib packaging doc etc web tests - -# Modules which are not included in default, install and clean targets -MODULES_EXCLUDE = thirdparty packaging doc - -# Default prefix for install target -PREFIX ?= /usr/local - -# Default out-of-source build path -BUILDDIR ?= build - -# Default debug level for executables -V ?= 2 - -# Platform -PLATFORM ?= $(shell uname) - -include Makefile.config - -ifeq ($(WITH_SRC),1) - MODULES += src -endif - -ifeq ($(WITH_TOOLS),1) - MODULES += tools -endif - -ifeq ($(WITH_PLUGINS),1) - MODULES += plugins -endif - -ifeq ($(WITH_TESTS),1) - MODULES += tests -endif - -# Common flags -LDLIBS = -CFLAGS += -std=c11 -MMD -mcx16 -I$(BUILDDIR)/include -I$(SRCDIR)/include -CFLAGS += -Wall -Werror -fdiagnostics-color=auto -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 - -ifeq ($(PLATFORM),Darwin) - CFLAGS += -D_DARWIN_C_SOURCE -endif - -LDFLAGS += -L$(BUILDDIR) - -# Some tools -PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/opt/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig - -PKGCONFIG := PKG_CONFIG_PATH=:$(PKG_CONFIG_PATH) pkg-config -SHELL := bash - -# We must compile without optimizations for gcov! -ifdef DEBUG - CFLAGS += -O0 -g - VARIANTS += debug -else - CFLAGS += -O3 - VARIANTS += release -endif - -ifdef PROFILE - CFLAGS += -pg - LDFLAGS += -pg - - VARIANTS += profile -endif - -ifdef COVERAGE - CFLAGS += --coverage - LDLIBS += -lgcov - - VARIANTS += coverage -endif - -EMPTY := -SPACE := $(EMPTY) $(EMPTY) - -VARIANT = $(shell uname -s)-$(shell uname -m)-$(subst $(SPACE),-,$(strip $(VARIANTS))) -BUILDDIR := $(BUILDDIR)/$(VARIANT) -SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - -VPATH = $(SRCDIR) - -# Add git revision and build variant defines -VERSION := $(shell git describe --tags --abbrev=0 --match 'v*') -VERSION_NUM := $(shell VERSION=$(VERSION); echo $${VERSION:1}) - -export BUILDDIR VARIANT VERSION VERSION_NUM - -ifdef CI - VARIANT := $(VARIANT)-ci - - GIT_REV := $(shell echo $${CI_COMMIT_SHA:0:7}) - GIT_BRANCH := $(CI_COMMIT_REF_NAME) - - ifdef CI_COMMIT_TAG - RELEASE = 1 - else - RELEASE = 1.$(subst -,_,$(CI_COMMIT_REF_NAME))_$(subst -,_,$(VARIANT)).$(shell date +%Y%m%d)git$(GIT_REV) - endif -else - GIT_REV := $(shell git rev-parse --short=7 HEAD) - GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) - - RELEASE = 1.$(subst -,_,$(GIT_BRANCH))_$(subst -,_,$(VARIANT)).$(shell date +%Y%m%d)git$(GIT_REV) -endif - -BUILDID = "$(VERSION)-$(GIT_REV)-$(VARIANT)" - -# pkg-config dependencies -PKGS = openssl jansson - -ifeq ($(WITH_CONFIG),1) - PKGS += libconfig -endif - -######## Targets ######## - -# Add flags by pkg-config -CFLAGS += $(shell $(PKGCONFIG) --cflags ${PKGS}) -LDLIBS += $(shell $(PKGCONFIG) --libs ${PKGS}) - -all: $(filter-out $(MODULES_EXCLUDE),$(MODULES)) -install: $(addprefix install-,$(filter-out $(MODULES_EXCLUDE),$(MODULES))) -clean: $(addprefix clean-, $(filter-out $(MODULES_EXCLUDE),$(MODULES))) - -src plugins tools tests: lib - -# Build all variants: debug, coverage, ... -everything: - $(MAKE) RELEASE=1 - $(MAKE) DEBUG=1 - $(MAKE) COVERAGE=1 - $(MAKE) PROFILE=1 - -# Create non-existent directories -.SECONDEXPANSION: -.PRECIOUS: %/ -%/: - mkdir -p $@ - -escape = $(shell echo $1 | tr a-z- A-Z_ | tr -dc ' A-Z0-9_') - -.PHONY: all everything clean install - -include $(wildcard $(BUILDDIR)/**/*.d) -include $(patsubst %,$(SRCDIR)/%/Makefile.inc,$(MODULES)) -include Makefile.help diff --git a/Makefile.config b/Makefile.config deleted file mode 100644 index fbb80c5c9..000000000 --- a/Makefile.config +++ /dev/null @@ -1,74 +0,0 @@ -## Main project Makefile -# -# The build system of this project is based on GNU Make and pkg-config -# -# To retain maintainability, the project is divided into multiple modules. -# Each module has its own Makefile which gets included. -# -# Please read "Recursive Make Considered Harmful" from Peter Miller -# to understand the motivation for this structure. -# -# [1] http://aegis.sourceforge.net/auug97.pdf -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -# Select modules -WITH_SRC ?= 1 -WITH_TOOLS ?= 1 -WITH_PLUGINS ?= 1 -WITH_TESTS ?= 0 -WITH_CLIENTS ?= 0 - -# Select features -WITH_CONFIG ?= 1 -WITH_HOOKS ?= 1 -WITH_WEB ?= 1 -WITH_API ?= 1 -WITH_IO ?= 1 - -# Select IO formats -WITH_FORMAT_PROTOBUF ?= 1 - -# Select node-types -ifeq ($(PLATFORM),Linux) - IS_LINUX = 1 -else - IS_LINUX = 0 -endif - -WITH_NODE_FPGA ?= $(IS_LINUX) -WITH_NODE_CBUILDER ?= $(IS_LINUX) -WITH_NODE_LOOPBACK ?= $(IS_LINUX) -WITH_NODE_COMEDI ?= $(IS_LINUX) -WITH_NODE_TEST_RTT ?= 1 -WITH_NODE_FILE ?= 1 -WITH_NODE_SIGNAL ?= 1 -WITH_NODE_NGSI ?= 1 -WITH_NODE_WEBSOCKET ?= 1 -WITH_NODE_SOCKET ?= 1 -WITH_NODE_ZEROMQ ?= 1 -WITH_NODE_NANOMSG ?= 1 -WITH_NODE_SHMEM ?= 1 -WITH_NODE_STATS ?= 1 -WITH_NODE_INFLUXDB ?= 1 -WITH_NODE_AMQP ?= 1 -WITH_NODE_IEC61850 ?= 1 -WITH_NODE_MQTT ?= 1 diff --git a/Makefile.help b/Makefile.help deleted file mode 100644 index 5b2a17d97..000000000 --- a/Makefile.help +++ /dev/null @@ -1,102 +0,0 @@ -# Makefile for clang autocompletion -# -# This Makefile produces .clang_complete files containing compiler flags -# which are used by clang autocompletion tools such as: -# -# - https://atom.io/packages/autocomplete-clang -# - https://github.com/Rip-Rip/clang_complete -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -E = @echo - -help: - $E "The following make targets are available:" - $E - $E " - make all" - $E " Build libvillas, villas CLI tools, tests" - $E - $E " - make everything" - $E " Build all in all available build variants" - $E - $E " - make docker" - $E " - make run-docker" - $E " - make deploy-docker" - $E - $E " - make docker-{app,dev,dev-centos,dev-fedora}" - $E " Build Docker images" - $E - $E " - make run-docker-{app,dev,dev-centos,dev-fedora}" - $E " Run Docker containers" - $E - $E " - make deploy-docker-{app,dev,dev-centos,dev-fedora}" - $E " Deploy Docker images to official registry" - $E - $E "The following environment variables can change the build:" - $E " DEBUG = 1" - $E " COVERAGE = 1" - $E - $E "Use the following variables to enable/disabled certain features of VILLASnode" - $E " The list also shows the currently active (default) value" - $E - $E "Enable modules:" - $E " WITH_SRC = $(WITH_SRC)" - $E " WITH_TOOLS = $(WITH_TOOLS)" - $E " WITH_PLUGINS = $(WITH_PLUGINS)" - $E " WITH_TESTS = $(WITH_TESTS)" - $E " WITH_CLIENTS = $(WITH_CLIENTS)" - $E - $E "Enable features:" - $E " WITH_CONFIG = $(WITH_CONFIG)" - $E " WITH_HOOKS = $(WITH_HOOKS)" - $E " WITH_WEB = $(WITH_WEB)" - $E " WITH_API = $(WITH_API)" - $E " WITH_IO = $(WITH_IO)" - $E - $E "Enable IO formats:" - $E " WITH_FORMAT_PROTOBUF = $(WITH_FORMAT_PROTOBUF)" - $E - $E "Enable node-types:" - $E " WITH_NODE_FPGA = $(WITH_NODE_FPGA)" - $E " WITH_NODE_CBUILDER = $(WITH_NODE_CBUILDER)" - $E " WITH_NODE_LOOPBACK = $(WITH_NODE_LOOPBACK)" - $E " WITH_NODE_TEST_RTT = $(WITH_NODE_TEST_RTT)" - $E " WITH_NODE_FILE = $(WITH_NODE_FILE)" - $E " WITH_NODE_SIGNAL = $(WITH_NODE_SIGNAL)" - $E " WITH_NODE_NGSI = $(WITH_NODE_NGSI)" - $E " WITH_NODE_WEBSOCKET = $(WITH_NODE_WEBSOCKET)" - $E " WITH_NODE_SOCKET = $(WITH_NODE_SOCKET)" - $E " WITH_NODE_ZEROMQ = $(WITH_NODE_ZEROMQ)" - $E " WITH_NODE_NANOMSG = $(WITH_NODE_NANOMSG)" - $E " WITH_NODE_SHMEM = $(WITH_NODE_SHMEM)" - $E " WITH_NODE_STATS = $(WITH_NODE_STATS)" - $E " WITH_NODE_INFLUXDB = $(WITH_NODE_INFLUXDB)" - $E " WITH_NODE_AMQP = $(WITH_NODE_AMQP)" - $E " WITH_NODE_MQTT = $(WITH_NODE_MQTT)" - $E " WITH_NODE_IEC61850 = $(WITH_NODE_IEC61850)" - $E " WITH_NODE_MQTT = $(WITH_NODE_MQTT)" - $E " WITH_NODE_COMEDI = $(WITH_NODE_COMEDI)" - $E - $E "Available dependencies: $(LIB_PKGS)" - $E "Enabled node-types: $(LIB_NODES)" - $E "Enabled formats: $(LIB_FORMATS)" - -.PHONY: help diff --git a/clients/Makefile.inc b/clients/Makefile.inc deleted file mode 100644 index c1106196c..000000000 --- a/clients/Makefile.inc +++ /dev/null @@ -1,32 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -CLIENTS = - -include $(SRCDIR)/clients/python/Makefile.inc -include $(SRCDIR)/clients/opal/Makefile.inc - -clients: $(addprefix clients-,$(filter-out opal,$(CLIENTS))) -clean-clients: $(addprefix clean-clients-,$(filter-out opal,$(CLIENTS))) -install-clients: $(addprefix install-clients-,$(filter-out opal,$(CLIENTS))) - -.PHONY: clients clean-clients install-clients diff --git a/clients/opal/Makefile.inc b/clients/opal/Makefile.inc deleted file mode 100644 index 2eca9f803..000000000 --- a/clients/opal/Makefile.inc +++ /dev/null @@ -1,46 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -ifneq ($(wildcard $(SRCDIR)/thirdparty/libopal/include/opal/AsyncApi.h),) - -CLIENTS += opal - -ASYNCIP_PATH = $(SRCDIR)/clients/opal/models/send_receive - -ASYNCIP_OPTS = RTLAB_INTEL_COMPILER=0 \ - PROTOCOL=GTNET_SKT \ - OPAL_LIBS="-lSystem -luuid" \ - OPAL_LIBPATH=-L$(SRCDIR)/thirdparty/libopal/ \ - OPAL_INCPATH=-I$(SRCDIR)/thirdparty/libopal/include/opal - -clients-opal: - $(MAKE) -C $(ASYNCIP_PATH) -f Makefile.mk AsyncIP $(ASYNCIP_OPTS) - -clean-clients-opal: - $(MAKE) -C $(ASYNCIP_PATH) -f Makefile.mk clean $(ASYNCIP_OPTS) - -install-clients-opal: - $(MAKE) -C $(ASYNCIP_PATH) -f Makefile.mk install $(ASYNCIP_OPTS) - -.PHONY: clients-opal clean-clients-opal install-clients-opal - -endif diff --git a/clients/python/Makefile.inc b/clients/python/Makefile.inc deleted file mode 100644 index c802e18da..000000000 --- a/clients/python/Makefile.inc +++ /dev/null @@ -1,24 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -clients/python/villas_pb2.py: lib/io/villas.proto - protoc --proto_path=$(dir $^) --python_out=$(dir $@) $^ diff --git a/doc/Makefile.inc b/doc/Makefile.inc deleted file mode 100644 index 552ceb33c..000000000 --- a/doc/Makefile.inc +++ /dev/null @@ -1,33 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -doc: | $(BUILDDIR)/doc/ - ( cat Doxyfile ; echo "OUTPUT_DIRECTORY=$(BUILDDIR)/doc/" ) | doxygen - - -install-doc: doc - mkdir -p $(DESTDIR)$(PREFIX)/share/villas/node/doc/ - cp -R $(BUILDDIR)/doc/html/* $(DESTDIR)$(PREFIX)/share/villas/node/doc/ - -clean-doc: - rm -rf $(BUILDDIR)/doc/ - -.PHONY: doc install-doc clean-doc \ No newline at end of file diff --git a/etc/Makefile.inc b/etc/Makefile.inc deleted file mode 100644 index f12aa55cc..000000000 --- a/etc/Makefile.inc +++ /dev/null @@ -1,30 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -etc: - -install-etc: | $(DESTDIR)/etc/villas/node/ - install -D -t $(DESTDIR)/etc/villas/node $(SRCDIR)/etc/*.conf - -clean-etc: - -.PHONY: etc install-etc clean-etc \ No newline at end of file diff --git a/lib/Makefile.inc b/lib/Makefile.inc deleted file mode 100644 index 29e513a41..000000000 --- a/lib/Makefile.inc +++ /dev/null @@ -1,64 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -SONAMES = villas villas-ext - -LIBS = $(patsubst %, lib%, $(SONAMES)) - -LIB_CFLAGS += $(CFLAGS) -fPIC - -include $(patsubst %, lib/Makefile.%.inc, $(SONAMES)) - -$(BUILDDIR)/include/villas/config.h: include/villas/config.h.in Makefile.config | $$(dir $$@) - cp $< $@ - - echo -e "\n" >> $@ - echo "#define BUILDID \"$(BUILDID)\"" >> $@ - echo "#define V $(V)" >> $@ - echo "#define PREFIX \"$(PREFIX)\"" >> $@ - - echo -e "\n" >> $@ - echo "/* Available Features */" >> $@ - - if (( $(WITH_WEB) )); then echo "#define WITH_WEB 1" >> $@; fi - if (( $(WITH_API) )); then echo "#define WITH_API 1" >> $@; fi - if (( $(WITH_HOOKS) )); then echo "#define WITH_HOOKS 1" >> $@; fi - if (( $(WITH_IO) )); then echo "#define WITH_IO 1" >> $@; fi - if (( $(WITH_CONFIG) )); then echo "#define WITH_CONFIG 1" >> $@; fi - - for NODE in $(call escape,$(LIB_NODES)); do echo "#define WITH_NODE_$${NODE} 1" >> $@; done - for FORMAT in $(call escape,$(LIB_FORMATS)); do echo "#define WITH_FORMAT_$${FORMAT} 1" >> $@; done - for PKG in $(call escape,$(LIB_PKGS)); do echo "#define WITH_$${PKG} 1" >> $@; done - -# Compile -$(BUILDDIR)/lib/%.o: lib/%.c $(BUILDDIR)/include/villas/config.h | $$(dir $$@) - $(CC) $(LIB_CFLAGS) -c $< -o $@ - -lib: $(patsubst %, lib%, $(SONAMES)) - -install-lib: $(patsubst %, install-lib%, $(SONAMES)) - -clean-lib: $(patsubst %, clean-lib%, $(SONAMES)) - rm -rf $(BUILDDIR)/lib - rm -rf $(BUILDDIR)/include - -.PHONY: lib install-lib clean-lib diff --git a/lib/Makefile.villas-ext.inc b/lib/Makefile.villas-ext.inc deleted file mode 100644 index b8558a46a..000000000 --- a/lib/Makefile.villas-ext.inc +++ /dev/null @@ -1,54 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIBEXT_NAME = libvillas-ext -LIBEXT_ABI_VERSION = 1 -LIBEXT = $(BUILDDIR)/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) - -LIBEXT_SRCS += $(addprefix lib/, sample.c queue.c queue_signalled.c \ - memory.c log.c shmem.c utils.c kernel/kernel.c list.c \ - timing.c pool.c log_helper.c \ - ) - -LIBEXT_LDFLAGS = -shared -LIBEXT_LDLIBS += - -ifeq ($(PLATFORM),Linux) - LIBEXT_LDLIBS += -ldl -lrt -Wl,-soname,$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) -endif - -LIBEXT_OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(LIBEXT_SRCS)) - -$(LIBEXT_NAME): $(LIBEXT) - -$(LIBEXT): $(LIBEXT_OBJS) - $(CC) $(LIBEXT_LDFLAGS) -o $@ $^ $(LIBEXT_LDLIBS) - ln -srf $@ $(BUILDDIR)/$(LIBEXT_NAME).so - -install-libvillas-ext: libvillas-ext - install -m 0755 -D -T $(LIBEXT) $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) - ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so - -clean-libvillas-ext: - rm -f $(LIBEXT) - -.PHONY: install-libvillas-ext clean-libvillas-ext $(LIBEXT_NAME) diff --git a/lib/Makefile.villas.inc b/lib/Makefile.villas.inc deleted file mode 100644 index dc0a3ca0a..000000000 --- a/lib/Makefile.villas.inc +++ /dev/null @@ -1,93 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIB_NAME = libvillas -LIB_ABI_VERSION = 1 -LIB = $(BUILDDIR)/$(LIB_NAME).so.$(LIB_ABI_VERSION) - -# Object files for libvillas -LIB_SRCS += $(addprefix lib/kernel/, kernel.c rt.c) \ - $(addprefix lib/, sample.c path.c node.c hook.c log.c log_config.c \ - utils.c super_node.c hist.c timing.c pool.c list.c queue.c \ - queue_signalled.c memory.c advio.c plugin.c node_type.c stats.c \ - mapping.c shmem.c config_helper.c crypt.c compat.c \ - log_helper.c task.c buffer.c table.c bitset.c signal.c \ - ) - -LIB_LDFLAGS += -shared -LIB_LDLIBS += $(LDLIBS) - -ifeq ($(PLATFORM),Linux) - LIB_LDLIBS += -ldl -lrt -Wl,-soname,$(LIB_NAME).so.$(LIB_ABI_VERSION) -endif - -LIB_PKGS += openssl libcurl - -include lib/nodes/Makefile.inc - -ifeq ($(WITH_IO),1) - LIB_SRCS += lib/io.c lib/format_type.c - include lib/formats/Makefile.inc -endif - -ifeq ($(WITH_HOOKS),1) - LIB_SRCS += lib/hook.c lib/hook_type.c - include lib/hooks/Makefile.inc -endif - -ifeq ($(WITH_WEB),1) - LIB_SRCS += lib/web.c - LIB_PKGS += libwebsockets -endif - -ifeq ($(WITH_API),1) - LIB_SRCS += lib/api.c - include lib/api/Makefile.inc -endif - -LIB_SRCS += $(patsubst %, lib/nodes/%.c, $(LIB_NODES)) -LIB_SRCS += $(patsubst %, lib/formats/%.c, $(LIB_FORMATS)) - -# Add flags by pkg-config -LIB_LDLIBS += $(shell $(PKGCONFIG) --libs $(LIB_PKGS)) -LIB_CFLAGS += $(shell $(PKGCONFIG) --cflags $(LIB_PKGS)) - -LIB_OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(LIB_SRCS)) - -$(LIB_NAME): $(LIB) - -# Link -$(LIB): $(LIB_OBJS) - $(CC) $(LIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS) - ln -srf $@ $(BUILDDIR)/$(LIB_NAME).so - -# Install -install-libvillas: libvillas | $(DESTDIR)$(PREFIX)/include/villas/ - install -m 0755 -D -T $(LIB) $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so.$(LIB_ABI_VERSION) - install -m 0644 -D -t $(DESTDIR)$(PREFIX)/include/villas/ include/villas/*.h - ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so.$(LIB_ABI_VERSION) $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so - if [ "$(PLATFORM)" == "Linux" ]; then ldconfig; fi - -clean-libvillas: - rm -f $(LIB) - -.PHONY: install-libvillas clean-libvillas $(LIB_NAME) diff --git a/lib/api/Makefile.inc b/lib/api/Makefile.inc deleted file mode 100644 index 72aa6d686..000000000 --- a/lib/api/Makefile.inc +++ /dev/null @@ -1,25 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIB_SRCS += $(wildcard lib/api/*.c) - -include lib/api/actions/Makefile.inc diff --git a/lib/api/actions/Makefile.inc b/lib/api/actions/Makefile.inc deleted file mode 100644 index e45e291b7..000000000 --- a/lib/api/actions/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIB_SRCS += $(wildcard lib/api/actions/*.c) diff --git a/lib/formats/Makefile.inc b/lib/formats/Makefile.inc deleted file mode 100644 index dc8e9b087..000000000 --- a/lib/formats/Makefile.inc +++ /dev/null @@ -1,41 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIB_FORMATS += json json_reserve villas_binary villas_human csv raw -LIB_SRCS += lib/formats/msg.c - -# Enable Google Protobuf format -ifeq ($(WITH_FORMAT_PROTOBUF),1) -ifeq ($(shell $(PKGCONFIG) libprotobuf-c; echo $$?),0) - LIB_SRCS += lib/formats/protobuf.c lib/formats/villas.pb-c.c - LIB_PKGS += libprotobuf-c - LIB_FORMATS += protobuf -endif -endif - -%.pb-c.c %.pb-c.h: %.proto - protoc-c --proto_path=$(SRCDIR) --c_out=$(SRCDIR) --dependency_out=$(BUILDDIR)/$*.d $(realpath $^) - -$(BUILDDIR)/%.pb-c.o: LIB_CFLAGS += -I$(SRCDIR) -$(BUILDDIR)/lib/formats/protobuf.o: LIB_CFLAGS += -I$(SRCDIR)/lib/formats - -$(BUILDDIR)/lib/formats/protobuf.o: lib/formats/villas.pb-c.h diff --git a/lib/hooks/Makefile.inc b/lib/hooks/Makefile.inc deleted file mode 100644 index 31455293c..000000000 --- a/lib/hooks/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -LIB_SRCS += $(addprefix lib/hooks/, convert.c decimate.c drop.c jitter_calc.c \ - map.c restart.c shift_seq.c shift_ts.c \ - skip_first.c stats.c ts.c limit_rate.c scale.c) - -ifeq ($(WITH_IO),1) - LIB_SRCS += lib/hooks/print.c -endif diff --git a/packaging/Makefile.inc b/packaging/Makefile.inc deleted file mode 100644 index f945f14eb..000000000 --- a/packaging/Makefile.inc +++ /dev/null @@ -1,56 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -TAR_OPTS = --exclude-ignore-recursive=$(SRCDIR)/.distignore --transform='s|^\.|villas-node-$(VERSION_NUM)|' --show-transformed-names - -TAR_VILLAS = $(BUILDDIR)/packaging/villas-node-$(VERSION_NUM)-$(RELEASE).tar.gz - -DEPLOY_USER ?= deploy -DEPLOY_HOST ?= acs-os-fein-website -DEPLOY_PATH ?= /var/www/villas/node - -packaging: rpm dist - -deploy: deploy-dist deploy-rpm deploy-docker - -# Source tarballs -dist: $(TAR_VILLAS) - -$(TAR_VILLAS): | $$(dir $$@) - tar $(TAR_OPTS) -C $(SRCDIR) -czf $@ . - -deploy-dist: $(TAR_VILLAS) - rsync $(TAR_VILLAS) $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/src - -deploy-rpm: - rsync -a --progress $(BUILDDIR)/../Linux-x86_64-release/packaging/rpm/RPMS/ $(DEPLOY_USER)@$(DEPLOY_HOST):/var/www/packages/redhat/ - ssh $(DEPLOY_USER)@$(DEPLOY_HOST) createrepo /var/www/packages/redhat - -clean-packaging: - rm -f $(BUILDDIR)/packaging/villas-node-$(VERSION_NUM).tar.gz - -install-packaging: - -.PHONY: packaging install-packaging clean-packaging deploy deploy-dist deploy-rpm dist $(TAR_VILLAS) - -include packaging/rpm/Makefile.inc -include packaging/docker/Makefile.inc diff --git a/packaging/docker/Makefile.inc b/packaging/docker/Makefile.inc deleted file mode 100644 index 599a6afce..000000000 --- a/packaging/docker/Makefile.inc +++ /dev/null @@ -1,74 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -DOCKER = docker - -DOCKER_FILE ?= Dockerfile -DOCKER_IMAGE ?= villas/node -DOCKER_TAG ?= $(GIT_BRANCH) - -DOCKER_TARGETS = docker-app docker-dev docker-dev-centos docker-dev-ubuntu -DOCKER_RUN_TARGETS = $(addprefix run-,$(DOCKER_TARGETS)) -DOCKER_DEPLOY_TARGETS = $(addprefix deploy-,$(DOCKER_TARGETS)) - -ifneq ($(CI_COMMIT_TAG),) - DOCKER_OPTS += --tag $(DOCKER_IMAGE)-$*:$(CI_COMMIT_TAG) -endif - -DOCKER_RUN_OPTS = --interactive --tty \ - --publish 80:80 --publish 443:443 --publish 12000:12000/udp --publish 12001:12001/udp \ - --privileged --security-opt seccomp:unconfined --volume "$(SRCDIR):/villas" - -# Special cases for 'docker'target -run-docker: run-docker-app -deploy-docker: deploy-docker-app -docker: docker-app - $(DOCKER) tag $(DOCKER_IMAGE)-app:$(DOCKER_TAG) $(DOCKER_IMAGE):$(DOCKER_TAG) - $(DOCKER) tag $(DOCKER_IMAGE)-app:$(DOCKER_TAG) $(DOCKER_IMAGE):latest - -.PHONY: docker run-docker deploy-docker - -$(DOCKER_DEPLOY_TARGETS): deploy-docker-%: docker-% - $(DOCKER) push $(DOCKER_IMAGE)-$*:$(DOCKER_TAG) - -$(DOCKER_RUN_TARGETS): run-docker-%: docker-% - $(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE)-$*:$(DOCKER_TAG) - -$(DOCKER_TARGETS): docker-%: $(BUILDDIR)/packaging/docker/Image.% - -# The docker build targets use the --iidfile option to write the newly build image -# id to an file. Make is using the modification timestamp of this file and the Dockerfile -# to determine when the image needs to be rebuild. -$(BUILDDIR)/packaging/docker/Image.%: packaging/docker/Dockerfile.% | $(BUILDDIR)/packaging/docker/ - $(DOCKER) build \ - --file $< --iidfile $@ \ - --tag $(DOCKER_IMAGE)-$*:$(DOCKER_TAG) \ - --tag $(DOCKER_IMAGE)-$*:latest \ - --build-arg BUILDER_IMAGE=$(DOCKER_IMAGE)-dev:$(DOCKER_TAG) \ - --build-arg DOCKER_TAG=${DOCKER_TAG} \ - --build-arg GIT_BRANCH=${GIT_BRANCH} \ - --build-arg GIT_REV=${GIT_REV} \ - --build-arg VERSION=${VERSION} \ - --build-arg VARIANT=${VARIANT} \ - $(DOCKER_OPTS) $(SRCDIR) - -.PHONY: $(DOCKER_TARGETS) $(DOCKER_RUN_TARGETS) $(DOCKER_DEPLOY_TARGETS) diff --git a/packaging/rpm/Makefile.inc b/packaging/rpm/Makefile.inc deleted file mode 100644 index 230ded665..000000000 --- a/packaging/rpm/Makefile.inc +++ /dev/null @@ -1,44 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -RPMDIR = $(BUILDDIR)/packaging/rpm - -SPEC_VILLAS = $(BUILDDIR)/packaging/rpm/villas-node.spec - -rpm: rpm-villas-node - -rpm-villas-node: $(TAR_VILLAS) $(SPEC_VILLAS) | $(RPMDIR)/SOURCES/ - cp $(TAR_VILLAS) $(RPMDIR)/SOURCES - rpmbuild -ba --define="_topdir $$(pwd)/$(RPMDIR)" $(BUILDDIR)/packaging/rpm/villas-node.spec - -# We patch version number and release fields of the spec file based on the current Git commit -$(SPEC_VILLAS): packaging/rpm/villas-node.spec | $$(dir $$@) - sed -e "s/§VERSION§/$(VERSION_NUM)/g" \ - -e "s/§RELEASE§/$(RELEASE)/g" < $^ > $@ - -sign-rpm: - rpmsign $(RPMDIR)/RPMS/*/.rpm - -clean-rpm: - rm -rf $(RPMDIR) - -.PHONY: rpm clean-rpm rpm-libwebsockets rpm-libxil $(SPEC_VILLAS) diff --git a/plugins/Makefile.inc b/plugins/Makefile.inc deleted file mode 100644 index c8e45e9fb..000000000 --- a/plugins/Makefile.inc +++ /dev/null @@ -1,55 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -# Plugins -PLUGINS = $(BUILDDIR)/simple_circuit.so - -ifeq ($(WITH_HOOKS),1) - PLUGINS += $(BUILDDIR)/example_hook.so -endif - -PLUGIN_CFLAGS = -fPIC -DVILLAS -I../include/villas -PLUGIN_LDFLAGS = -shared -L$(BUILDDIR) -PLUGIN_LDLIBS = -lvillas - -# Dependencies for plugins -$(BUILDDIR)/example_hook.so: $(BUILDDIR)/plugins/hooks/example_hook.o -$(BUILDDIR)/simple_circuit.so: $(BUILDDIR)/plugins/models/simple_circuit.o - -plugins: $(PLUGINS) - -# Compile -$(BUILDDIR)/plugins/%.o: plugins/%.c | $$(dir $$@) - $(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c $< -o $@ - -# Link -$(PLUGINS): - $(CC) $(PLUGIN_LDFLAGS) -o $@ $^ $(PLUGIN_LDLIBS) - -# Plugins are not installed to the system for now... -install-plugins: plugins | $(DESTDIR)$(PREFIX)/share/villas/node/plugins/ - install -D -t $(DESTDIR)$(PREFIX)/share/villas/node/plugins $(PLUGINS) - -clean-plugins: - rm -rf $(BUILDDIR)/plugins $(PLUGINS) - -.PHONY: plugins install-plugins clean-plugins diff --git a/src/Makefile.inc b/src/Makefile.inc deleted file mode 100644 index c7a26614e..000000000 --- a/src/Makefile.inc +++ /dev/null @@ -1,66 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -# Executables -TARGETS = $(BUILDDIR)/villas-node \ - $(BUILDDIR)/villas-test-rtt \ - $(BUILDDIR)/villas-test-shmem \ - $(BUILDDIR)/villas-convert - -ifeq ($(WITH_IO),1) - ifeq ($(WITH_HOOKS),1) - TARGETS += $(BUILDDIR)/villas-hook - endif - - TARGETS += $(BUILDDIR)/villas-pipe \ - $(BUILDDIR)/villas-signal \ - $(BUILDDIR)/villas-test-cmp -endif - -SRC_LDLIBS = $(LDLIBS) -pthread -lm -lvillas -SRC_CFLAGS = $(CFLAGS) -SRC_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' - -src: $(TARGETS) - -$(TARGETS): $(BUILDDIR)/villas-%: $(BUILDDIR)/src/%.o - -# Compile executable objects -$(BUILDDIR)/src/%.o: src/%.c | $$(dir $$@) - $(CC) $(SRC_CFLAGS) -c $< -o $@ - -# Build villas-shmem only with libvillas-ext (to ensure that libext contains everything needed) -$(BUILDDIR)/villas-shmem: $(BUILDDIR)/src/shmem.o libvillas-ext - $(CC) $(SRC_LDFLAGS) $(BUILDDIR)/src/shmem.o $(filter-out -lvillas,$(SRC_LDLIBS)) -lvillas-ext -o $@ - -# Link target executables -$(TARGETS): | $(LIBS) - $(CC) $(SRC_LDFLAGS) $^ $(SRC_LDLIBS) -o $@ - -# Install -install-src: src - install -m 0755 -D -t $(DESTDIR)$(PREFIX)/bin $(TARGETS) - -clean-src: - rm -rf $(BUILDDIR)/src $(TARGETS) - -.PHONY: src src-tests src-tests diff --git a/tests/Makefile.inc b/tests/Makefile.inc deleted file mode 100644 index 6f7c61178..000000000 --- a/tests/Makefile.inc +++ /dev/null @@ -1,43 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -include tests/unit/Makefile.inc - -ifdef COVERAGE - include tests/unit/Makefile.gcov.inc -endif - -include tests/integration/Makefile.inc - -tests: unit-tests integration-tests - -run-tests: run-unit-tests run-integration-tests run-valgrind - -VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp - -run-valgrind: src - $(VALGRIND) $(BUILDDIR)/villas-node & sleep 2; kill %1 - $(VALGRIND) $(BUILDDIR)/villas-pipe -t 2 $(SRCDIR)/etc/websocket-loopback.conf ws1 - $(VALGRIND) $(BUILDDIR)/villas-signal mixed -v 4 -l 10 - $(VALGRIND) $(BUILDDIR)/villas-hook stats < <($(BUILDDIR)/villas-signal mixed -l 5) - -.PHONY: tests run-tests run-valgrind diff --git a/tests/integration/Makefile.inc b/tests/integration/Makefile.inc deleted file mode 100644 index b2c5e068c..000000000 --- a/tests/integration/Makefile.inc +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -integration-tests: src tools - -run-integration-tests: integration-tests - @$(SRCDIR)/tools/integration-tests.sh diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc deleted file mode 100644 index ae50469fd..000000000 --- a/tests/unit/Makefile.inc +++ /dev/null @@ -1,49 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -TEST_SRCS = $(wildcard tests/unit/*.c) -TEST_OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(TEST_SRCS)) - -TEST_CFLAGS = $(CFLAGS) -TEST_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' -TEST_LDLIBS = $(LDLIBS) -lcriterion -lvillas -pthread -ljansson - -unit-tests: $(BUILDDIR)/unit-tests - -run-unit-tests: tests - $(BUILDDIR)/unit-tests $(CRITERION_OPTS) - -# Compile -$(BUILDDIR)/tests/unit/%.o: tests/unit/%.c $(BUILDDIR)/include/villas/config.h | $$(dir $$@) - $(CC) $(TEST_CFLAGS) -c $< -o $@ - -# Link -$(BUILDDIR)/unit-tests: $(TEST_OBJS) $(LIB) - $(CC) $(TEST_LDFLAGS) $^ $(TEST_LDLIBS) -o $@ - -# Tests are not installed -install-tests: - -clean-tests: - rm -rf $(BUILDDIR)/tests $(BUILDDIR)/testsuite - -.PHONY: unit-tests install-unit-tests clean-unit-tests run-unit-tests diff --git a/tools/Makefile.inc b/tools/Makefile.inc deleted file mode 100644 index da01a51ba..000000000 --- a/tools/Makefile.inc +++ /dev/null @@ -1,61 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -ifeq ($(WITH_CONFIG),1) -ifeq ($(shell $(PKGCONFIG) libconfig; echo $$?),0) - TOOLS += $(BUILDDIR)/conf2json -endif -endif - -TOOLS_CFLAGS = $(CFLAGS) -TOOLS_LDLIBS = $(LDLIBS) -lconfig -ljansson -lvillas -TOOLS_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' - -ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0) - TOOLS += $(BUILDDIR)/zmq-keygen - TOOLS_CFLAGS += $(shell $(PKGCONFIG) --cflags libzmq) - TOOLS_LDLIBS += $(shell $(PKGCONFIG) --libs libzmq) -endif - -ifeq ($(IS_LINUX),1) - TOOLS += $(BUILDDIR)/rmshm $(BUILDDIR)/rmsem - TOOLS_LDLIBS += -lrt -pthread -endif - -# Compile executable objects -$(BUILDDIR)/tools/%.o: tools/%.c | $$(dir $$@) - $(CC) $(TOOLS_CFLAGS) -c $< -o $@ - -# Link target executables -$(TOOLS): $(BUILDDIR)/%: $(BUILDDIR)/tools/%.o | $(LIBS) - $(CC) $(TOOLS_LDFLAGS) $^ $(TOOLS_LDLIBS) -o $@ - -tools: $(TOOLS) - -clean-tools: - rm -rf $(BUILDDIR)/tools $(TOOLS) - -install-tools: $(TOOLS) - install -m 0755 tools/villas.sh $(DESTDIR)$(PREFIX)/bin/villas - install -m 0755 -D -t $(DESTDIR)$(PREFIX)/bin $(TOOLS) - -.PHONY: tools clean-tools install-tools diff --git a/web/Makefile.inc b/web/Makefile.inc deleted file mode 100644 index dbfd3e647..000000000 --- a/web/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -install-web: - mkdir -p $(DESTDIR)$(PREFIX)/share/villas/node/web/ - cp -R $(SRCDIR)/web/socket/* $(DESTDIR)$(PREFIX)/share/villas/node/web/ - -clean-web: - -.PHONY: web install-web clean-web \ No newline at end of file From 58a13ae92e315a66ec07c5c3ccf3c5a0dafc937a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 06:00:34 +0200 Subject: [PATCH 08/40] cmake: fix some #ifdefs --- include/villas/config.h.in | 9 ++++++++- include/villas/nodes/socket.h | 4 ++-- lib/config_helper.c | 4 ++-- lib/super_node.c | 4 ++-- lib/web.c | 4 ++-- src/pipe.c | 4 ++-- tests/unit/config_json.c | 4 ++-- tests/unit/io.c | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/villas/config.h.in b/include/villas/config.h.in index cf552bb6f..d62812107 100644 --- a/include/villas/config.h.in +++ b/include/villas/config.h.in @@ -70,11 +70,18 @@ extern "C"{ #cmakedefine WITH_API #cmakedefine WITH_HOOKS #cmakedefine WITH_IO -#cmakedefine WITH_CONFIG /* OS Headers */ #cmakedefine HAS_EVENTFD +#cmakedefine HAS_SEMAPHORE + +#cmakedefine LIBWEBSOCKETS_FOUND +#cmakedefine HDF5_FOUND +#cmakedefine PROTOBUF_FOUND +#cmakedefine LIBNL3_ROUTE_FOUND +#cmakedefine LIBCONFIG_FOUND + #ifdef __cplusplus } #endif diff --git a/include/villas/nodes/socket.h b/include/villas/nodes/socket.h index 6cccdf848..ad2ed1372 100644 --- a/include/villas/nodes/socket.h +++ b/include/villas/nodes/socket.h @@ -40,13 +40,13 @@ #include #include -#ifdef WITH_LIBNL_ROUTE_30 +#ifdef LIBNL3_ROUTE_FOUND #include #include #include #define WITH_NETEM -#endif /* WITH_LIBNL_ROUTE_30 */ +#endif /* LIBNL3_ROUTE_FOUND */ #include diff --git a/lib/config_helper.c b/lib/config_helper.c index 320e759f1..2e3cb8f1a 100644 --- a/lib/config_helper.c +++ b/lib/config_helper.c @@ -26,7 +26,7 @@ #include #include -#ifdef WITH_CONFIG +#ifdef LIBCONFIG_FOUND static int json_to_config_type(int type) { @@ -143,7 +143,7 @@ int json_to_config(json_t *json, config_setting_t *parent) return 0; } -#endif /* WITH_CONFIG */ +#endif /* LIBCONFIG_FOUND */ void json_object_extend_key_value(json_t *obj, const char *key, const char *value) { diff --git a/lib/super_node.c b/lib/super_node.c index 705b8cab7..7f00521f2 100644 --- a/lib/super_node.c +++ b/lib/super_node.c @@ -103,7 +103,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri) /* Parse config */ sn->cfg = json_loadf(f, 0, &err); if (sn->cfg == NULL) { -#ifdef WITH_CONFIG +#ifdef LIBCONFIG_FOUND int ret; config_t cfg; @@ -150,7 +150,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri) config_destroy(&cfg); #else jerror(&err, "Failed to parse configuration file"); -#endif /* WITH_CONFIG */ +#endif /* LIBCONFIG_FOUND */ } /* Close configuration file */ diff --git a/lib/web.c b/lib/web.c index a9b3d9030..106dc4e34 100644 --- a/lib/web.c +++ b/lib/web.c @@ -58,14 +58,14 @@ lws_callback_function websocket_protocol_cb; .rx_buffer_size = 0 }, #endif /* WITH_API */ -#ifdef WITH_NODE_WEBSOCKET +#ifdef LIBWEBSOCKETS_FOUND { .name = "live", .callback = websocket_protocol_cb, .per_session_data_size = sizeof(struct websocket_connection), .rx_buffer_size = 0 }, -#endif /* WITH_NODE_WEBSOCKET */ +#endif /* LIBWEBSOCKETS_FOUND */ #if 0 /* not supported yet */ { .name = "log", diff --git a/src/pipe.c b/src/pipe.c index ee27df078..7b387645e 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -341,13 +341,13 @@ check: if (optarg == endptr) if (!node) error("Node '%s' does not exist!", nodestr); -#ifdef WITH_NODE_WEBSOCKET +#ifdef LIBWEBSOCKETS_FOUND /* Only start web subsystem if villas-pipe is used with a websocket node */ if (node->_vt->start == websocket_start) { web_start(&sn.web); api_start(&sn.api); } -#endif /* WITH_NODE_WEBSOCKET */ +#endif /* LIBWEBSOCKETS_FOUND */ if (reverse) node_reverse(node); diff --git a/tests/unit/config_json.c b/tests/unit/config_json.c index fff947dd4..274e653ff 100644 --- a/tests/unit/config_json.c +++ b/tests/unit/config_json.c @@ -22,7 +22,7 @@ #include -#ifdef WITH_LIBCONFIG +#ifdef LIBCONFIG_FOUND #include #include @@ -117,4 +117,4 @@ Test(utils, json_to_config) json_decref(json); } -#endif +#endif /* LIBCONFIG_FOUND */ diff --git a/tests/unit/io.c b/tests/unit/io.c index 4abdc57a2..cf8d5e162 100644 --- a/tests/unit/io.c +++ b/tests/unit/io.c @@ -39,10 +39,10 @@ #define NUM_VALUES 10 static char formats[][32] = { -#ifdef WITH_FORMAT_HDF5 +#ifdef LIBHDF5_FOUND "hdf5", #endif -#ifdef WITH_FORMAT_PROTOBUF +#ifdef LIBPROTOBUF_FOUND "protobuf", #endif "raw.int8", From 34e6891192094cc28533d9e8f7eac1659f6cb3b6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 06:01:47 +0200 Subject: [PATCH 09/40] iec61850: fix ether_aton() call on OS X --- include/villas/nodes/iec61850.h | 6 ++++++ lib/nodes/iec61850.c | 1 - lib/nodes/iec61850_sv.c | 9 +++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/villas/nodes/iec61850.h b/include/villas/nodes/iec61850.h index 9f7944b4b..349549ffa 100644 --- a/include/villas/nodes/iec61850.h +++ b/include/villas/nodes/iec61850.h @@ -31,6 +31,12 @@ #include +#ifdef __APPLE__ + #include +#else + #include +#endif + #include #include #include diff --git a/lib/nodes/iec61850.c b/lib/nodes/iec61850.c index c14a5a21b..b6aae1706 100644 --- a/lib/nodes/iec61850.c +++ b/lib/nodes/iec61850.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "villas/nodes/iec61850_sv.h" #include "villas/plugin.h" diff --git a/lib/nodes/iec61850_sv.c b/lib/nodes/iec61850_sv.c index 70c91efca..13699049e 100644 --- a/lib/nodes/iec61850_sv.c +++ b/lib/nodes/iec61850_sv.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "villas/nodes/iec61850_sv.h" #include "villas/plugin.h" @@ -166,8 +165,14 @@ int iec61850_sv_parse(struct node *n, json_t *json) if (interface) i->interface = strdup(interface); - if (dst_address) + if (dst_address) { +#ifdef __APPLE__ + struct ether_addr *ether = ether_aton(dst_address); + memcpy(&i->dst_address, ether, sizeof(struct ether_addr)); +#else ether_aton_r(dst_address, &i->dst_address); +#endif + } if (json_pub) { i->publisher.enabled = true; From c16c53ffb92040ad12f4267e0d654f68d863bb70 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 06:02:01 +0200 Subject: [PATCH 10/40] test_rtt: fix compiler warnings --- lib/nodes/test_rtt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/nodes/test_rtt.c b/lib/nodes/test_rtt.c index 6ccbae612..2de5d887f 100644 --- a/lib/nodes/test_rtt.c +++ b/lib/nodes/test_rtt.c @@ -188,11 +188,7 @@ int test_rtt_parse(struct node *n, json_t *cfg) else c->limit = 1000; /* default value */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-result" - asprintf(&c->filename, "%s/%s_%d_%.0f.log", t->output, t->prefix, c->values, c->rate); -#pragma GCC diagnostic pop - + c->filename = strf("%s/%s_%d_%.0f.log", t->output, t->prefix, c->values, c->rate); list_push(&t->cases, c); } From a163535d23706ef815b307e43d717b4741c2642c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 06:06:12 +0200 Subject: [PATCH 11/40] cmake: add support for building and installing documentation --- CMakeLists.txt | 1 + doc/CMakeLists.txt | 38 +++++++++++++++++++++++++++++++++++++ Doxyfile => doc/Doxyfile.in | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 doc/CMakeLists.txt rename Doxyfile => doc/Doxyfile.in (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a37609902..2cf132528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,7 @@ include_directories( add_subdirectory(lib) add_subdirectory(src) add_subdirectory(tools) +add_subdirectory(doc) # Show feature summary add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 000000000..99ca867c5 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,38 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +add_custom_target(doc + COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +) + +configure_file( + Doxyfile.in + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile +) + +install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + DESTINATION share/villas/node/doc + COMPONENT doc +) diff --git a/Doxyfile b/doc/Doxyfile.in similarity index 99% rename from Doxyfile rename to doc/Doxyfile.in index f901b6c0d..4db7e3af4 100644 --- a/Doxyfile +++ b/doc/Doxyfile.in @@ -58,7 +58,7 @@ PROJECT_LOGO = doc/pictures/villas_node.svg # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = build/doc/ +OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@ # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and From 09f55734f00f83622d3959403fe0bdbac6cbc646 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 09:15:24 +0200 Subject: [PATCH 12/40] remove unreleated RPM spec files --- packaging/rpm/libiec61850.spec | 70 --------------- packaging/rpm/nanomsg.spec | 157 --------------------------------- 2 files changed, 227 deletions(-) delete mode 100644 packaging/rpm/libiec61850.spec delete mode 100644 packaging/rpm/nanomsg.spec diff --git a/packaging/rpm/libiec61850.spec b/packaging/rpm/libiec61850.spec deleted file mode 100644 index 4e0b9d42f..000000000 --- a/packaging/rpm/libiec61850.spec +++ /dev/null @@ -1,70 +0,0 @@ -Name: libiec61850 -Version: 1.2 -Vendor: MZ Automation -Packager: Steffen Vogel -Release: 1%{?dist} -Summary: Open source libraries for IEC 61850 and IEC 60870-5-104 - -License: GPL-3.0 -URL: https://github.com/mz-automation/libiec61850 -#Source0: https://github.com/mz-automation/libiec61850/repository/archive.tar.gz?ref=v1.2.0 -Source0: libiec61850_1.2.0.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -BuildRequires: gcc cmake - -%description - -IEC 61850 is an international standard for communication systems in Substation Automation Systems (SAS) and management of Decentralized Energy Resources (DER). -It is seen as one of the communication standards of the emerging Smart Grid. -Despite of its complexity and other drawbacks that make it difficult to implement and to use, the protocol is the only one of its kind that is in widespread use by utility companies and equipment manufacturers. - -The project libIEC61850 provides a server and client library for the IEC 61850/MMS, IEC 61850/GOOSE and IEC 61850-9-2/Sampled Values communication protocols written in C. -It is available under the GPLv3 license. With this library available everybody can now become easily familiar with IEC 61850. -A tabular overview of the provided IEC 61850 ACSI services is available on the project website. - -The library is designed according to edition 2 of the IEC 61850 standard series, but should be compatible to edition 1 in most cases. - -%package devel - -Summary: Headers and libraries for building apps that use libiec61850 -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel - -The development headers for libiec61850. - -%prep -%setup -q -n libiec61850_1.2.0/ - -%build -mkdir -p build -cd build -rm CMakeCache.txt -%cmake -DCMAKE_INSTALL_LIBDIR=${_libdir} -DBUILD_EXAMPLES=0 -DBUILD_PYTHON_BINDINGS=0 .. -make %{?_smp_mflags} - -%install -rm -rf $RPM_BUILD_ROOT -cd build -make install DESTDIR=$RPM_BUILD_ROOT - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%{_prefix}/lib/libiec61850.so.1.2.0 -%{_prefix}/lib/libiec61850.so - -%files devel -%{_includedir}/libiec61850/* -%{_prefix}/share/pkgconfig/libiec61850.pc -%{_prefix}/lib/libiec61850.a - -%changelog -* Mon Nov 6 2017 Steffen Vogel - 1.0.0-1 -- Updated to 1.0.0 final release -- nanomsg moved to CMake, so this spec did too -- Changed source URL -- Moved contents of -doc package into -devel -- Removed conditional check, all tests should pass -- The nanocat symlink stuff is gone, nanocat is now a single binary with options - -* Tue Oct 27 2015 Japheth Cleaver 0.7-0.1.beta -- update to 0.7-beta release - -* Fri Nov 14 2014 Japheth Cleaver 0.5-0.1.beta -- update to 0.5-beta release - -* Sun Jul 27 2014 Japheth Cleaver 0.4-0.3.beta -- compile with correct Fedora flags -- move documentation back to base package -- spec file cleanups - -* Thu Jul 17 2014 Japheth Cleaver 0.4-0.2.beta -- drop the 'lib' prefix from package name -- remove explicit pkgconfig requires in nanomsg-devel -- move overview man pages to devel subpackage -- move html to doc subpackage - -* Thu Jul 17 2014 Japheth Cleaver 0.4-0.1.beta -- new "libnanomsg" package based on BZ#1012392, with current versioning -- devel and utils subpackages created, static lib a build conditional -- check section added as a build conditional -- ensure man pages for nanocat symlinks present -- disable RPATH in library -- License set to MIT From 9094941b4c1aa1e29020e4c25b20d29370f8812d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 09:44:58 +0200 Subject: [PATCH 13/40] cmake: add more CMakeLists.txt --- CMakeLists.txt | 114 +++++++++++++++++++------------ clients/CMakeLists.txt | 24 +++++++ clients/opal/CMakeLists.txt | 32 +++++++++ clients/python/CMakeLists.txt | 27 ++++++++ cmake/FindMosquitto.cmake | 40 +++++++++++ cmake/FindOpal.cmake | 39 +++++++++++ cmake/VILLASnodePackaging.cmake | 54 +++++++++++++++ cmake/config/Coverage.cmake | 58 ++++++++++++++++ cmake/config/Debug.cmake | 25 +++++++ cmake/config/Profiling.cmake | 58 ++++++++++++++++ cmake/config/Release.cmake | 25 +++++++ etc/CMakeLists.txt | 25 +++++++ lib/CMakeLists.txt | 49 ++++++++----- lib/api/CMakeLists.txt | 17 +++-- lib/formats/CMakeLists.txt | 11 +-- lib/hooks/CMakeLists.txt | 6 +- lib/nodes/CMakeLists.txt | 90 ++++++++++++++++++++++-- packaging/CMakeLists.txt | 54 +++++++++++++++ packaging/docker/CMakeLists.txt | 66 ++++++++++++++++++ plugins/CMakeLists.txt | 32 +++++++++ src/CMakeLists.txt | 32 +++++++++ tests/CMakeLists.txt | 46 +++++++++++++ tests/integration/CMakeLists.txt | 33 +++++++++ tests/unit/CMakeLists.txt | 50 ++++++++++++++ tools/CMakeLists.txt | 19 ++++-- tools/integration-tests.sh | 6 +- web/CMakeLists.txt | 27 ++++++++ 27 files changed, 965 insertions(+), 94 deletions(-) create mode 100644 clients/CMakeLists.txt create mode 100644 clients/opal/CMakeLists.txt create mode 100644 clients/python/CMakeLists.txt create mode 100644 cmake/FindMosquitto.cmake create mode 100644 cmake/FindOpal.cmake create mode 100644 cmake/VILLASnodePackaging.cmake create mode 100644 cmake/config/Coverage.cmake create mode 100644 cmake/config/Debug.cmake create mode 100644 cmake/config/Profiling.cmake create mode 100644 cmake/config/Release.cmake create mode 100644 etc/CMakeLists.txt create mode 100644 packaging/CMakeLists.txt create mode 100644 packaging/docker/CMakeLists.txt create mode 100644 plugins/CMakeLists.txt create mode 100644 tests/CMakeLists.txt create mode 100644 tests/integration/CMakeLists.txt create mode 100644 tests/unit/CMakeLists.txt create mode 100644 web/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cf132528..adce01b2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Main CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -22,17 +22,36 @@ cmake_minimum_required(VERSION 3.0) -project(VILLASnode) +project(VILLASnode C CXX) set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 11) -set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig") -find_package(PkgConfig) +if(APPLE) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/local/lib/pkgconfig") +endif() + +include(FindPkgConfig) include(CheckIncludeFile) include(FeatureSummary) include(CheckCCompilerFlag) #include(CheckCxxCompilerFlag) +include(GNUInstallDirs) +include(VILLASnodePackaging) + +# Compiler flags +if(BUILD32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32") +endif() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1") if(MSVC) check_c_compiler_flag("/W4 /WX" C_SUPPORTS_WERROR) @@ -58,53 +77,58 @@ else() endif() endif() -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - string(APPEND VARIANTS "-debug") -else() - string(APPEND VARIANTS "-release") -endif() - -if(PROFILE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") - set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -pg") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") - - string(APPEND VARIANTS "-profile") -endif() - -if(COVERAGE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") - target_link_libraries("gcov") - - string(APPEND VARIANTS "-coverage") -endif() - # Check OS check_include_file("sys/eventfd.h" HAS_EVENTFD) +check_include_file("semaphore.h" HAS_SEMAPHORE) +check_include_file("sys/mman.h" HAS_MMAN) + +pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) +pkg_check_modules(LIBNL3_ROUTE IMPORTED_TARGET libnl-route-3.0) +pkg_check_modules(LIBIEC61850 IMPORTED_TARGET libiec61850>=1.2.0) +pkg_check_modules(LIBCONFIG IMPORTED_TARGET libconfig) +pkg_check_modules(RABBITMQ_C IMPORTED_TARGET librabbitmq) +pkg_check_modules(COMEDILIB IMPORTED_TARGET comedilib) +pkg_check_modules(LIBZMQ IMPORTED_TARGET libzmq) +pkg_check_modules(NANOMSG IMPORTED_TARGET nanomsg) +if(NOT NANOMSG_FOUND) + pkg_check_modules(NANOMSG IMPORTED_TARGET libnanomsg) +endif() + +find_package(Libwebsockets REQUIRED) +find_package(OpenSSL REQUIRED) +find_package(CURL REQUIRED) +find_package(Protobuf) +find_package(Opal) # Build options -option(WITH_HOOKS "Build with support for processing hook plugins" ON) -option(WITH_IO "Build with support format plugins" ON) -option(WITH_WEB "Build with internal webserver" ON) -option(WITH_API "Build with remote control API" ON) -option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON) +option(WITH_HOOKS "Build with support for processing hook plugins" ON) +option(WITH_IO "Build with support format plugins" ON) +option(WITH_WEB "Build with internal webserver" ON) +option(WITH_API "Build with remote control API" ON) +option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON) set(V 2) set(PREFIX ${CMAKE_INSTALL_PREFIX}) set(VARIANT "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +# Add more build configurations +include(cmake/config/Debug.cmake) +include(cmake/config/Release.cmake) +include(cmake/config/Coverage.cmake) +include(cmake/config/Profiling.cmake) + # Add git revision and build variant defines +set(PROJECT_SOVERSION 1) + execute_process( COMMAND git describe --tags --abbrev=0 --match "v*" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION + OUTPUT_VARIABLE PROJECT_VERSION_STR OUTPUT_STRIP_TRAILING_WHITESPACE ) -string(SUBSTRING ${VERSION} 2 -1 VERSION_NUM) - +string(SUBSTRING ${PROJECT_VERSION_STR} 2 -1 PROJECT_VERSION) string(TIMESTAMP BUILD_DATE "%Y%m%d") if(DEFINED ENV{CI}) @@ -128,20 +152,15 @@ else() endif() if(DEFINED ENV{CI_COMMIT_TAG}) - set(RELEASE 1) + set(PROJECT_RELEASE 1) else() string(REPLACE "-" "_" GIT_BRANCH_NORM ${GIT_BRANCH}) string(REPLACE "-" "_" VARIANT_NORM ${VARIANT}) - set(RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}") + set(PROJECT_RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}") endif() -set(BUILDID "${VERSION}-${GIT_REV}-${VARIANT}") - -configure_file( - ${CMAKE_SOURCE_DIR}/include/villas/config.h.in - ${CMAKE_BINARY_DIR}/include/villas/config.h -) +set(BUILDID "${PROJECT_VERSION_STR}-${GIT_REV}-${VARIANT}") include_directories( ${CMAKE_SOURCE_DIR}/include @@ -151,7 +170,18 @@ include_directories( add_subdirectory(lib) add_subdirectory(src) add_subdirectory(tools) +add_subdirectory(plugins) +add_subdirectory(etc) add_subdirectory(doc) +add_subdirectory(web) +add_subdirectory(clients) +add_subdirectory(tests) +add_subdirectory(packaging) + +configure_file( + ${CMAKE_SOURCE_DIR}/include/villas/config.h.in + ${CMAKE_BINARY_DIR}/include/villas/config.h +) # Show feature summary add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt new file mode 100644 index 000000000..9f97b7376 --- /dev/null +++ b/clients/CMakeLists.txt @@ -0,0 +1,24 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +add_subdirectory(python) +add_subdirectory(opal) diff --git a/clients/opal/CMakeLists.txt b/clients/opal/CMakeLists.txt new file mode 100644 index 000000000..8bdbeeedb --- /dev/null +++ b/clients/opal/CMakeLists.txt @@ -0,0 +1,32 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +if(OPAL_FOUND) + set(ASYNCIP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/models/send_receive) + + set(ASYNCIP_OPTS RTLAB_INTEL_COMPILER=0 PROTOCOL=GTNET_SKT OPAL_LIBS="-lSystem -luuid" OPAL_LIBPATH=-L$(SRCDIR)/thirdparty/libopal/ OPAL_INCPATH=-I$(SRCDIR)/thirdparty/libopal/include/opal) + + # Just call the original Makefile + add_custom_target(clients-opal + COMMAND make -C ${ASYNCIP_PATH} -f Makefile.mk AsyncIP ${ASYNCIP_OPTS} + ) +endif() diff --git a/clients/python/CMakeLists.txt b/clients/python/CMakeLists.txt new file mode 100644 index 000000000..310a2927b --- /dev/null +++ b/clients/python/CMakeLists.txt @@ -0,0 +1,27 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +add_custom_command(OUTPUT villas_pb2.py + COMMAND protoc ${CMAKE_SOURCE_DIR}/lib/nodes/villas.proto + MAIN_DEPENDENCY villas.proto +) + diff --git a/cmake/FindMosquitto.cmake b/cmake/FindMosquitto.cmake new file mode 100644 index 000000000..8782092c2 --- /dev/null +++ b/cmake/FindMosquitto.cmake @@ -0,0 +1,40 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +find_path(MOSQUITTO_INCLUDE_DIR + NAMES mosquitto.h +) + +find_library(MOSQUITTO_LIBRARY + NAMES mosquitto +) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set VILLASNODE_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(MOSQUITTO DEFAULT_MSG + MOSQUITTO_LIBRARY MOSQUITTO_INCLUDE_DIR) + +mark_as_advanced(MOSQUITTO_INCLUDE_DIR MOSQUITTO_LIBRARY) + +set(MOSQUITTO_LIBRARIES ${MOSQUITTO_LIBRARY}) +set(MOSQUITTO_INCLUDE_DIRS ${MOSQUITTO_INCLUDE_DIR}) diff --git a/cmake/FindOpal.cmake b/cmake/FindOpal.cmake new file mode 100644 index 000000000..24255d228 --- /dev/null +++ b/cmake/FindOpal.cmake @@ -0,0 +1,39 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +find_path(OPAL_INCLUDE_DIR + NAMES opal/AsyncApi.h +) + +find_library(OPAL_LIBRARY + NAMES OpalAsyncApiCore +) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set VILLASNODE_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(OPAL DEFAULT_MSG OPAL_LIBRARY OPAL_INCLUDE_DIR) + +mark_as_advanced(OPAL_INCLUDE_DIR OPAL_LIBRARY) + +set(OPAL_LIBRARIES ${OPAL_LIBRARY} OpalCore OpalUtils irc) +set(OPAL_INCLUDE_DIRS ${OPAL_INCLUDE_DIR}) diff --git a/cmake/VILLASnodePackaging.cmake b/cmake/VILLASnodePackaging.cmake new file mode 100644 index 000000000..acdee4894 --- /dev/null +++ b/cmake/VILLASnodePackaging.cmake @@ -0,0 +1,54 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(PROJECT_AUTHOR "Steffen Vogel") +set(PROJECT_COPYRIGHT "2018, Institute for Automation of Complex Power Systems, RWTH Aachen University") + +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) +set(CPACK_PACKAGE_VENDOR ${PROJECT_AUTHOR}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is VILLASnode, a gateway for processing and forwardning simulation data between real-time simulators.") +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_MAJOR_VERSION}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_PATCH_VERSION}) + +set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_RPM_PACKAGE_RELEASE ${PROJECT_RELEASE}) +set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") +set(CPACK_RPM_PACKAGE_LICENSE "GPLv3") +set(CPACK_RPM_PACKAGE_URL "http://www.fein-aachen.org/projects/dpsim/") +set(CPACK_RPM_PACKAGE_REQUIRES "openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib") +set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") + +# As close as possible to Fedoras naming +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}") + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") + +set(CPACK_SOURCE_IGNORE_FILES "build/;\\.gitmodules;\\.git/;\\.vscode;\\.editorconfig;\\.gitlab-ci.yml;\\.(docker|git)ignore;\\.DS_Store") + +if(NOT DEFINED CPACK_GENERATOR) + set(CPACK_GENERATOR "RPM;TGZ") +endif() + +include(CPack) diff --git a/cmake/config/Coverage.cmake b/cmake/config/Coverage.cmake new file mode 100644 index 000000000..ef5bfdbbf --- /dev/null +++ b/cmake/config/Coverage.cmake @@ -0,0 +1,58 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(CMAKE_CXX_FLAGS_COVERAGE + "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C++ compiler during coverage builds." + FORCE +) + +set(CMAKE_C_FLAGS_COVERAGE + "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage" + CACHE STRING "Flags used by the C compiler during coverage builds." + FORCE +) + +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE + "${CMAKE_EXE_LINKER_FLAGS}" + CACHE STRING "Flags used for linking binaries during coverage builds." + FORCE +) + +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + "${CMAKE_SHARED_LINKER_FLAGS_COVERAGE}" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." + FORCE +) + +mark_as_advanced( + CMAKE_CXX_FLAGS_COVERAGE + CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE +) + +if(CMAKE_BUILD_TYPE STREQUAL "Coverage") + target_link_libraries("gcov") + + string(APPEND VARIANTS "-coverage") +endif() diff --git a/cmake/config/Debug.cmake b/cmake/config/Debug.cmake new file mode 100644 index 000000000..18d5cea7c --- /dev/null +++ b/cmake/config/Debug.cmake @@ -0,0 +1,25 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + string(APPEND VARIANTS "-debug") +endif() diff --git a/cmake/config/Profiling.cmake b/cmake/config/Profiling.cmake new file mode 100644 index 000000000..c048e310d --- /dev/null +++ b/cmake/config/Profiling.cmake @@ -0,0 +1,58 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(CMAKE_CXX_FLAGS_PROFILING + "${CMAKE_CXX_FLAGS} -pg" + CACHE STRING "Flags used by the C++ compiler during coverage builds." + FORCE +) + +set(CMAKE_C_FLAGS_PROFILING + "${CMAKE_C_FLAGS} -pg" + CACHE STRING "Flags used by the C compiler during coverage builds." + FORCE +) + +set(CMAKE_EXE_LINKER_FLAGS_PROFILING + "${CMAKE_EXE_LINKER_FLAGS} -pg" + CACHE STRING "Flags used for linking binaries during coverage builds." + FORCE +) + +set(CMAKE_SHARED_LINKER_FLAGS_PROFILING + "${CMAKE_SHARED_LINKER_FLAGS_COVERAGE} -pg" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." + FORCE +) + +mark_as_advanced( + CMAKE_CXX_FLAGS_PROFILING + CMAKE_C_FLAGS_PROFILING + CMAKE_EXE_LINKER_FLAGS_PROFILING + CMAKE_SHARED_LINKER_FLAGS_PROFILING +) + +if(CMAKE_BUILD_TYPE STREQUAL "Profiling") + string(APPEND VARIANTS "-profile") +endif() + + diff --git a/cmake/config/Release.cmake b/cmake/config/Release.cmake new file mode 100644 index 000000000..cfa3432bc --- /dev/null +++ b/cmake/config/Release.cmake @@ -0,0 +1,25 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + string(APPEND VARIANTS "-release") +endif() diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt new file mode 100644 index 000000000..43c7c9435 --- /dev/null +++ b/etc/CMakeLists.txt @@ -0,0 +1,25 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +install(DIRECTORY . + DESTINATION etc/villas/node/ +) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 86f50325a..cdeb80165 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -20,11 +20,6 @@ # along with this program. If not, see . ################################################################################### -find_package(OpenSSL REQUIRED) -find_package(curl REQUIRED) - -pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) - set(INCLUDE_DIRS ${JANSSON_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} @@ -73,11 +68,9 @@ set(LIB_SRC add_subdirectory(nodes) -if(WITH_CONFIG) - pkg_check_modules(CONFIG IMPORTED_TARGET REQUIRED libconfig) - - list(APPEND INCLUDE_DIRS ${CONFIG_INCLUDE_DIRS}) - list(APPEND LIBRARIES PkgConfig::CONFIG) +if(LIBCONFIG_FOUND) + list(APPEND INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::LIBCONFIG) endif() if(WITH_IO) @@ -95,7 +88,7 @@ if(WITH_HOOKS) hook.c hook_type.c ) - + add_subdirectory(hooks) list(APPEND LIBRARIES villas-hooks) endif() @@ -104,10 +97,6 @@ if(WITH_WEB) list(APPEND LIB_SRC web.c ) - - find_package(libwebsockets REQUIRED) - - message("LWS: ${LIBWEBSOCKETS_LIBRARIES}") list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS}) list(APPEND LIBRARIES websockets_shared) @@ -122,7 +111,35 @@ if(WITH_API AND WITH_WEB) list(APPEND LIBRARIES villas-api) endif() +# libnl3 is optional but required for network emulation and IRQ pinning +if(LIBNL3_ROUTE_FOUND) + list(APPEND LIB_SRC + kernel/nl.c + kernel/tc.c + kernel/tc_netem.c + kernel/if.c + ) + + list(APPEND INCLUDE_DIRS ${LIBNL3_ROUTE_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::LIBNL3_ROUTE) +endif() + add_library(villas SHARED ${LIB_SRC}) target_include_directories(villas PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas PUBLIC ${LIBRARIES}) + +set_target_properties(villas PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_SOVERSION} +) + +install(TARGETS villas EXPORT VILLASNodeConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(DIRECTORY ../include/villas/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/villas/) + +#install(EXPORT VILLASNodeConfig DESTINATION share/VILLASNode/cmake) +#export(TARGETS villas FILE VILLASNodeConfig.cmake) diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt index 97cc687d8..906b348c0 100644 --- a/lib/api/CMakeLists.txt +++ b/lib/api/CMakeLists.txt @@ -2,7 +2,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -21,8 +21,6 @@ # along with this program. If not, see . ################################################################################### -find_package(openssl REQUIRED) - set(INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR} ) @@ -31,12 +29,17 @@ set(LIBRARIES ${OPENSSL_LIBRARIES} ) -file(GLOB ACTION_SRC actions/*.c) - -add_library(villas-api STATIC - ${ACTION_SRC} +set(API_SRC session.c + actions/capabiltities.c + actions/config.c + actions/nodes.c + actions/paths.c + actions/restart.c + actions/shutdown.c + actions/status.c ) +add_library(villas-api SHARED ${API_SRC}) target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-api PUBLIC ${LIBRARIES}) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt index 33670bbd1..f7d7a74fc 100644 --- a/lib/formats/CMakeLists.txt +++ b/lib/formats/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -29,8 +29,6 @@ set(FORMAT_SRC raw.c ) -find_package(openssl REQUIRED) - set(INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR} ) @@ -40,7 +38,6 @@ set(LIBRARIES ) # Enable Google Protobuf format -find_package(Protobuf) if(Protobuf_FOUND) list(APPEND FORMAT_SRC protobuf.c @@ -73,10 +70,6 @@ if(Protobuf_FOUND) ) endif() -add_library(villas-formats STATIC ${FORMAT_SRC}) +add_library(villas-formats SHARED ${FORMAT_SRC}) target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-formats PUBLIC ${LIBRARIES}) - -if(Protobuf_FOUND) -# add_dependencies(villas-formats villas.pb-c.c villas.pb-c.h) -endif() diff --git a/lib/hooks/CMakeLists.txt b/lib/hooks/CMakeLists.txt index e49483d99..ef7802d28 100644 --- a/lib/hooks/CMakeLists.txt +++ b/lib/hooks/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -20,8 +20,6 @@ # along with this program. If not, see . ################################################################################### -pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) - set(INCLUDE_DIRS ${JANSSON_INCLUDE_DIRS} ) @@ -52,6 +50,6 @@ if(WITH_IO) ) endif() -add_library(villas-hooks STATIC ${HOOK_SRC}) +add_library(villas-hooks SHARED ${HOOK_SRC}) target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-hooks PUBLIC ${LIBRARIES}) diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index ce7ab8a36..36c9e76e3 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -20,8 +20,6 @@ # along with this program. If not, see . ################################################################################### -pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) - set(INCLUDE_DIRS ${JANSSON_INCLUDE_DIRS} ) @@ -33,9 +31,22 @@ set(LIBRARIES set(NODE_SRC influxdb.c stats.c - file.c + signal_generator.c ) +if(LIBNL3_ROUTE_FOUND) + list(APPEND LIBRARIES PkgConfig::LIBNL3_ROUTE) + list(APPEND INCLUDE_DIRS LIBNL3_ROUTE_INCLUDE_DIRS) +endif() + +if(WITH_IO) + list(APPEND NODE_SRC + test_rtt.c + file.c + socket.c + ) +endif() + if(HAS_EVENTFD) list(APPEND NODE_SRC loopback.c @@ -43,6 +54,75 @@ if(HAS_EVENTFD) ) endif() -add_library(villas-nodes STATIC ${NODE_SRC}) +# Enable shared memory node-type +if(HAS_SEMAPHORE AND HAS_MMAN) + list(APPEND NODE_SRC shmem.c) + list(APPEND LIBRARIES "rt") +endif() + +# Enable IEC61850 node-types when libiec61850 is available +if(LIBIEC61850_FOUND) + list(APPEND NODE_SRC iec61850_sv.c iec61850.c) + list(APPEND INCLUDE_DIRS ${LIBIEC61850_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::LIBIEC61850) +endif() + +# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) +if(OPAL_FOUND AND BUILD32) + list(APPEND NODE_SRC opal.c) + list(APPEND INCLUDE_DIRS ${OPAL_INCLUDE_DIRS}) + list(APPEND LIBRARIES ${OPAL_LIBRARIES}) +endif() + +# Enable nanomsg node type when libnanomsg is available +if(NANOMSG_FOUND AND WITH_IO) + list(APPEND NODE_SRC nanomsg.c) + list(APPEND INCLUDE_DIRS ${NANOMSG_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::NANOMSG) +endif() + +# Enable ZeroMQ node type when libzmq is available +if(LIBZMQ_FOUND AND WITH_IO) + list(APPEND NODE_SRC zeromq.c) + list(APPEND INCLUDE_DIRS ${LIBZMQ_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::LIBZMQ) +endif() + +# Enable NGSI support +if(CURL_FOUND) + list(APPEND NODE_SRC ngsi.c) + list(APPEND INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) + list(APPEND LIBRARIES ${CURL_LIBRARIES}) +endif() + +# Enable WebSocket support +if(LIBWEBSOCKETS_FOUND AND WITH_WEB AND WITH_IO) + list(APPEND NODE_SRC websockets.c) + list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS}) + list(APPEND LIBRARIES websockets_shared) +endif() + +# Enable AMQP support +if(RABBITMQ_C_FOUND AND WITH_IO) + list(APPEND NODE_SRC amqp.c) + list(APPEND INCLUDE_DIRS ${RABBITMQ_C_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::RABBITMQ_C) +endif() + +# Enable MQTT support +if(MOSQUITTO_FOUND AND WITH_IO) + list(APPEND NODE_SRC mqtt.c) + list(APPEND INCLUDE_DIRS ${MOSQUITTO_INCLUDE_DIRS}) + list(APPEND LIBRARIES ${MOSQUITTO_LIBRARIES}) +endif() + +# Enable Comedi support +if(COMEDILIB_FOUND) + list(APPEND NODE_SRC comedi.c) + list(APPEND INCLUDE_DIRS ${COMEDILIB_INCLUDE_DIRS}) + list(APPEND LIBRARIES PkgConfig::COMEDILIB) +endif() + +add_library(villas-nodes SHARED ${NODE_SRC}) target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-nodes PUBLIC ${LIBRARIES}) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 000000000..8a12f074d --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,54 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +if (NOT DEFINED DEPLOY_USER) + set(DEPLOY_USER deploy) +endif() + +if (NOT DEFINED DEPLOY_HOST) + set(DEPLOY_USER acs-os-fein-website) +endif() + +if (NOT DEFINED DEPLOY_PATH) + set(DEPLOY_USER /var/www/villas/node) +endif() + +add_custom_target(deploy-dist + COMMAND rsync ${CMAKE_BINARY_DIR}/*.tar.gz ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/src +) + +add_custom_target(deploy-rpm + COMMAND rsync -a --progress ${CMAKE_BINARY_DIR}/*.rpm ${DEPLOY_USER}@${DEPLOY_HOST}:/var/www/packages/redhat/ + COMMAND ssh ${DEPLOY_USER}@${DEPLOY_HOST} createrepo /var/www/packages/redhat +) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/libvillas.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libvillas.pc +) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/libvillas.pc + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig +) + +add_subdirectory(docker) diff --git a/packaging/docker/CMakeLists.txt b/packaging/docker/CMakeLists.txt new file mode 100644 index 000000000..d26a785d1 --- /dev/null +++ b/packaging/docker/CMakeLists.txt @@ -0,0 +1,66 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(DOCKER_FILE Dockerfile) +set(DOCKER_IMAGE villas/node) +set(DOCKER_TAG ${GIT_BRANCH}) +set(DOCKER_RUN_OPTS "--interactive --tty --publish 80:80 --publish 443:443 --publish 12000:12000/udp --publish 12001:12001/udp --privileged --security-opt seccomp:unconfined --volume \"${CMAKE_SOURCE_DIR}:/villas\"") + +foreach(SUFFIX app dev dev-centos dev-ubuntu) + add_custom_target(deploy-docker-${SUFFIX} + COMMAND docker push ${DOCKER_IMAGE}-${SUFFIX}:${DOCKER_TAG} + COMMAND docker push ${DOCKER_IMAGE}-${SUFFIX}:latest + DEPENDS docker-${SUFFIX} + ) + + add_custom_target(run-docker-${SUFFIX} + COMMAND docker run ${DOCKER_RUN_OPTS} ${DOCKER_IMAGE}-${SUFFIX}:${DOCKER_TAG} + DEPENDS docker-${SUFFIX} + ) + + add_custom_target(docker-${SUFFIX} + COMMAND docker build + --file ${CMAKE_CURRENT_SOURCE_DIR}/Dockerfile.${SUFFIX} + --tag ${DOCKER_IMAGE}-${SUFFIX}:${DOCKER_TAG} + --tag ${DOCKER_IMAGE}-${SUFFIX}:latest + --build-arg BUILDER_IMAGE=${DOCKER_IMAGE}-dev:${DOCKER_TAG} + --build-arg DOCKER_TAG=${DOCKER_TAG} + --build-arg GIT_BRANCH=${GIT_BRANCH} + --build-arg GIT_REV=${GIT_REV} + --build-arg VERSION=${PROJECT_VERSION} + --build-arg VARIANT=${VARIANT} + ${DOCKER_BUILD_OPTS} ${CMAKE_SOURCE_DIR} + ) +endforeach() + +# Special cases for 'docker'target +add_custom_target(docker DEPENDS docker-app + COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:${DOCKER_TAG} + COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:latest +) + +add_custom_target(deploy-docker DEPENDS docker-app + COMMAND docker push ${DOCKER_IMAGE}:${DOCKER_TAG} + COMMAND docker push ${DOCKER_IMAGE}:latest +) + +add_custom_target(run-docker DEPENDS run-docker-app) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 000000000..7c04e463f --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,32 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +# Plugins +link_libraries(villas) +include_directories("${CMAKE_SOURCE_DIR}/include") +add_definitions("-DVILLAS") + +add_library(simple_circuit SHARED models/simple_circuit.c) + +if(WITH_HOOKS) + add_library(example_hook SHARED hooks/example_hook.c) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab489b07b..3f279dcdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,26 @@ +# CMakeLists. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +# All executables link against libvillas link_libraries(villas) add_executable(villas-node node.c) @@ -6,11 +29,20 @@ add_executable(villas-test-shmem test-shmem.c) if(WITH_IO) add_executable(villas-test-cmp test-cmp.c) + add_executable(villas-convert convert.c) + add_executable(villas-pipe pipe.c) + target_link_libraries(villas-pipe PUBLIC pthread) + add_executable(villas-signal signal.c) endif() if(WITH_IO AND WITH_HOOKS) add_executable(villas-hook hook.c) endif() + +install( + TARGETS ${BUILDSYSTEM_TARGETS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..7efc9713e --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,46 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +add_subdirectory(unit) +add_subdirectory(integration) + +if(CMAKE_BUILD_TYPE STREQUAL "Coverage") + #include tests/unit/Makefile.gcov.inc +endif() + +add_custom_target(tests + DEPENDS unit-tests integration-tests +) + +add_custom_target(run-tests + DEPENDS run-unit-tests run-integration-tests +) + +set(VALGRIND "valgrind --leak-check=full --show-leak-kinds=all --suppressions=${CMAKE_CURRENT_SOURCE_DIR}/valgrind.supp") + +add_custom_target(run-valgrind + COMMAND ${VALGRIND} $ & sleep 2; kill %1 + COMMAND ${VALGRIND} $ -t 2 ${CMAKE_SOURCE_DIR}/etc/websocket-loopback.conf ws1 + COMMAND ${VALGRIND} $ mixed -v 4 -l 10 + COMMAND ${VALGRIND} $ stats < <($ mixed -l 5) + DEPENDS villas-node villas-pipe villas-signal villas-hook +) diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt new file mode 100644 index 000000000..1cd7fb6df --- /dev/null +++ b/tests/integration/CMakeLists.txt @@ -0,0 +1,33 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +add_custom_target(run-integration-tests + COMMAND + SRCDIR=${CMAKE_SOURCE_DIR} + BUILDDIR=${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/tools/integration-tests.sh + DEPENDS + villas-node + villas-pipe + villas-signal + villas-hook +) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt new file mode 100644 index 000000000..dae9b6414 --- /dev/null +++ b/tests/unit/CMakeLists.txt @@ -0,0 +1,50 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +set(TEST_SRC + advio.c + bitset.c + config_json.c + hist.c + io.c + json.c + kernel.c + list.c + log.c + main.c + mapping.c + memory.c + pool.c + queue.c + queue_signalled.c + task.c + timing.c + utils.c +) + +add_executable(unit-tests ${TEST_SRC}) +target_link_libraries(unit-tests PUBLIC villas criterion pthread) + +add_custom_target(run-unit-tests + COMMAND $ ${CRITERION_OPTS} + DEPENDS unit-tests +) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c04a4545d..4137c06e6 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists. # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -20,9 +20,9 @@ # along with this program. If not, see . ################################################################################### -if(WITH_CONFIG) +if(LIBCONFIG_FOUND) + list(APPEND TOOLS conf2json) add_executable(conf2json conf2json.c) - target_link_libraries(conf2json PUBLIC villas) endif() @@ -34,9 +34,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(rmsem PUBLIC pthread rt) endif() -pkg_check_modules(ZMQ IMPORTED_TARGET REQUIRED libzmq) -if(ZMQ_FOUND) +if(LIBZMQ_FOUND) add_executable(zmq-keygen zmq-keygen.c) - target_include_directories(zmq-keygen PUBLIC ${ZMQ_INCLUDE_DIRS}) - target_link_libraries(zmq-keygen PUBLIC PkgConfig::ZMQ) + target_include_directories(zmq-keygen PUBLIC ${LIBZMQ_INCLUDE_DIRS}) + target_link_libraries(zmq-keygen PUBLIC PkgConfig::LIBZMQ) endif() + +install( + PROGRAMS villas.sh + DESTINATION ${CMAKE_INSTALL_BINDIR} + RENAME villas +) diff --git a/tools/integration-tests.sh b/tools/integration-tests.sh index 1c2934640..f3360d1d1 100755 --- a/tools/integration-tests.sh +++ b/tools/integration-tests.sh @@ -25,13 +25,11 @@ SCRIPT=$(realpath ${BASH_SOURCE[0]}) SCRIPTPATH=$(dirname $SCRIPT) -VARIANTS=${VARIANTS:-"release"} -VARIANT=${VARIANT:-$(uname -s)-$(uname -m)-$(echo ${VARIANTS} | tr ' ' '_')} SRCDIR=${SRCDIR:-$(realpath ${SCRIPTPATH}/..)} -BUILDDIR=${BUILDDIR:-${SRCDIR}/build/${VARIANT}} +BUILDDIR=${BUILDDIR:-${SRCDIR}/build} LOGDIR=${BUILDDIR}/tests/integration -PATH=${BUILDDIR}:${PATH} +PATH=${BUILDDIR}/src:${PATH} export PATH SRCDIR BUILDDIR LOGDIR diff --git a/web/CMakeLists.txt b/web/CMakeLists.txt new file mode 100644 index 000000000..96286035a --- /dev/null +++ b/web/CMakeLists.txt @@ -0,0 +1,27 @@ +# CMakeLists.txt. +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +install( + DIRECTORY socket/ + DESTINATION share/villas/node/web + COMPONENT runtime +) From 32db08659d48137408bb9a2b7aacb712c85d62c3 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 09:45:27 +0200 Subject: [PATCH 14/40] remove .distignore --- .distignore | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .distignore diff --git a/.distignore b/.distignore deleted file mode 100644 index 979ecd28d..000000000 --- a/.distignore +++ /dev/null @@ -1,17 +0,0 @@ -build/ -thirdparty/ - -.git/ - -.gitmodules -.gitignore -.dockerignore -.distignore - -.DS_Store -*~ - -*.o -*.d - -villas-* From cbfa94cb3cd9fc70869128ca61cc50421c4d6294 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jun 2018 09:45:44 +0200 Subject: [PATCH 15/40] add missing dependency to Dockerfile --- packaging/docker/Dockerfile.dev | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/docker/Dockerfile.dev b/packaging/docker/Dockerfile.dev index 20fee6ef9..dece0626b 100644 --- a/packaging/docker/Dockerfile.dev +++ b/packaging/docker/Dockerfile.dev @@ -74,6 +74,7 @@ RUN dnf -y install \ libwebsockets-devel \ zeromq-devel \ nanomsg-devel \ + protobuf-devel \ protobuf-c-devel \ libiec61850-devel \ librabbitmq-devel \ From 0a4f1a37316dfdf77014fb331729e0f85fe11cf9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 01:29:45 +0200 Subject: [PATCH 16/40] cmake: add install targets and several other cpack improvments --- CMakeLists.txt | 45 +++++++++++------ cmake/FindProtobufC.cmake | 20 ++++++++ cmake/VILLASnodePackaging.cmake | 28 +++++++---- cmake/config/Coverage.cmake | 2 - cmake/config/Debug.cmake | 4 -- cmake/config/Profiling.cmake | 4 -- cmake/config/Release.cmake | 4 -- doc/CMakeLists.txt | 54 ++++++++++++++------ etc/CMakeLists.txt | 9 +++- lib/CMakeLists.txt | 35 +++++++++---- lib/api/CMakeLists.txt | 11 ++++ lib/formats/CMakeLists.txt | 22 +++++--- lib/hooks/CMakeLists.txt | 11 ++++ lib/nodes/CMakeLists.txt | 11 ++++ packaging/CMakeLists.txt | 2 + packaging/docker/CMakeLists.txt | 3 +- packaging/docker/Dockerfile.dev | 10 ++-- packaging/libvillas.pc.in | 13 +++++ packaging/rpm/villas-node.spec | 89 --------------------------------- plugins/CMakeLists.txt | 10 ++++ src/CMakeLists.txt | 3 ++ tools/CMakeLists.txt | 18 ++++++- web/CMakeLists.txt | 2 +- 23 files changed, 244 insertions(+), 166 deletions(-) create mode 100644 cmake/FindProtobufC.cmake create mode 100644 packaging/libvillas.pc.in delete mode 100644 packaging/rpm/villas-node.spec diff --git a/CMakeLists.txt b/CMakeLists.txt index adce01b2e..70444b0a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ # along with this program. If not, see . ################################################################################### -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.3) project(VILLASnode C CXX) @@ -38,9 +38,10 @@ include(FindPkgConfig) include(CheckIncludeFile) include(FeatureSummary) include(CheckCCompilerFlag) -#include(CheckCxxCompilerFlag) +include(CheckCXXCompilerFlag) include(GNUInstallDirs) -include(VILLASnodePackaging) + +set(CMAKE_SKIP_RPATH ON) # Compiler flags if(BUILD32) @@ -55,7 +56,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto -D_POSIX_C_SOURCE=2 if(MSVC) check_c_compiler_flag("/W4 /WX" C_SUPPORTS_WERROR) -# check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR) + check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR) if(C_SUPPORTS_WERROR) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX") @@ -66,7 +67,7 @@ if(MSVC) endif() else() check_c_compiler_flag("-Wall -Werror" C_SUPPORTS_WERROR) -# check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR) + check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR) if(C_SUPPORTS_WERROR) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") @@ -82,6 +83,14 @@ check_include_file("sys/eventfd.h" HAS_EVENTFD) check_include_file("semaphore.h" HAS_SEMAPHORE) check_include_file("sys/mman.h" HAS_MMAN) +# Check packages +find_package(PkgConfig REQUIRED) +find_package(Libwebsockets REQUIRED) +find_package(OpenSSL REQUIRED) +find_package(CURL REQUIRED) +find_package(ProtobufC) +find_package(Opal) + pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) pkg_check_modules(LIBNL3_ROUTE IMPORTED_TARGET libnl-route-3.0) pkg_check_modules(LIBIEC61850 IMPORTED_TARGET libiec61850>=1.2.0) @@ -94,12 +103,6 @@ if(NOT NANOMSG_FOUND) pkg_check_modules(NANOMSG IMPORTED_TARGET libnanomsg) endif() -find_package(Libwebsockets REQUIRED) -find_package(OpenSSL REQUIRED) -find_package(CURL REQUIRED) -find_package(Protobuf) -find_package(Opal) - # Build options option(WITH_HOOKS "Build with support for processing hook plugins" ON) option(WITH_IO "Build with support format plugins" ON) @@ -110,7 +113,11 @@ option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON) set(V 2) set(PREFIX ${CMAKE_INSTALL_PREFIX}) -set(VARIANT "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +if(CMAKE_BUILD_TYPE) + string(TOLOWER "${CMAKE_BUILD_TYPE}" VARIANT) +else() + set(VARIANT "release") +endif() # Add more build configurations include(cmake/config/Debug.cmake) @@ -119,6 +126,9 @@ include(cmake/config/Coverage.cmake) include(cmake/config/Profiling.cmake) # Add git revision and build variant defines +set(PROJECT_AUTHOR "Steffen Vogel") +set(PROJECT_COPYRIGHT "2018, Institute for Automation of Complex Power Systems, RWTH Aachen University") + set(PROJECT_SOVERSION 1) execute_process( @@ -128,7 +138,11 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -string(SUBSTRING ${PROJECT_VERSION_STR} 2 -1 PROJECT_VERSION) +string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" PROJECT_VERSION ${PROJECT_VERSION_STR}) +string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\1" PROJECT_MAJOR_VERSION ${PROJECT_VERSION_STR}) +string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\2" PROJECT_MINOR_VERSION ${PROJECT_VERSION_STR}) +string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" PROJECT_PATCH_VERSION ${PROJECT_VERSION_STR}) + string(TIMESTAMP BUILD_DATE "%Y%m%d") if(DEFINED ENV{CI}) @@ -160,7 +174,7 @@ else() set(PROJECT_RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}") endif() -set(BUILDID "${PROJECT_VERSION_STR}-${GIT_REV}-${VARIANT}") +set(BUILDID "v${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}-${GIT_REV}-${VARIANT}") include_directories( ${CMAKE_SOURCE_DIR}/include @@ -193,4 +207,7 @@ add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configurat if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) feature_summary(WHAT ALL VAR FEATURES) message(STATUS "${FEATURES}") + message(STATUS "Building VILLASnode: ${BUILDID}") endif() + +include(VILLASnodePackaging) diff --git a/cmake/FindProtobufC.cmake b/cmake/FindProtobufC.cmake new file mode 100644 index 000000000..d02cceba9 --- /dev/null +++ b/cmake/FindProtobufC.cmake @@ -0,0 +1,20 @@ +pkg_check_modules(PC_PROTOBUFC QUIET libprotobuf-c) +set(PROTOBUFC_DEFINITIONS ${PC_PROTOBUFC_CFLAGS_OTHER}) + +find_path(PROTOBUFC_INCLUDE_DIR google/protobuf-c/protobuf-c.h + HINTS ${PC_PROTOBUFC_INCLUDEDIR} ${PC_PROTOBUFC_INCLUDE_DIRS} + PATH_SUFFIXES libprotobuf-c) + +find_library(PROTOBUFC_LIBRARY NAMES protobuf-c + HINTS ${PC_PROTOBUFC_LIBDIR} + ${PC_PROTOBUFC_LIBRARY_DIRS}) + +find_program(PROTOBUFC_COMPILER protoc-c) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(libprotobuf-c DEFAULT_MSG + PROTOBUFC_LIBRARY PROTOBUFC_INCLUDE_DIR PROTOBUFC_COMPILER) +mark_as_advanced(PROTOBUFC PROTOBUFC_INCLUDE_DIR PROTOBUFC_LIBRARY) + +set(PROTOBUFC_LIBRARIES ${PROTOBUFC_LIBRARY}) +set(PROTOBUFC_INCLUDE_DIRS ${PROTOBUFC_INCLUDE_DIR}) diff --git a/cmake/VILLASnodePackaging.cmake b/cmake/VILLASnodePackaging.cmake index acdee4894..5977288c9 100644 --- a/cmake/VILLASnodePackaging.cmake +++ b/cmake/VILLASnodePackaging.cmake @@ -20,9 +20,6 @@ # along with this program. If not, see . ################################################################################### -set(PROJECT_AUTHOR "Steffen Vogel") -set(PROJECT_COPYRIGHT "2018, Institute for Automation of Complex Power Systems, RWTH Aachen University") - set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_PACKAGE_VENDOR ${PROJECT_AUTHOR}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is VILLASnode, a gateway for processing and forwardning simulation data between real-time simulators.") @@ -31,21 +28,34 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_MAJOR_VERSION}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION}) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_PATCH_VERSION}) -set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_RPM_COMPONENT_INSTALL ON) +set(CPACK_RPM_MAIN_COMPONENT "bin") + +set(CPACK_RPM_LIB_PACKAGE_REQUIRES "openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib") +set(CPACK_RPM_BIN_PACKAGE_REQUIRES "libvillas") +set(CPACK_RPM_PLUGINS_PACKAGE_REQUIRES "libvillas") +set(CPACK_RPM_TOOLS_PACKAGE_REQUIRES "libvillas") +set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES "libvillas") + +set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) set(CPACK_RPM_PACKAGE_RELEASE ${PROJECT_RELEASE}) set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_PACKAGE_LICENSE "GPLv3") -set(CPACK_RPM_PACKAGE_URL "http://www.fein-aachen.org/projects/dpsim/") -set(CPACK_RPM_PACKAGE_REQUIRES "openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib") +set(CPACK_RPM_PACKAGE_URL "http://www.fein-aachen.org/projects/villas-node/") set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") -# As close as possible to Fedoras naming -set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}") +set(SUFFIX "${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") +set(CPACK_RPM_FILE_NAME "villas-node-${SUFFIX}") +set(CPACK_RPM_TOOLS_FILE_NAME "villas-node-tools-${SUFFIX}") +set(CPACK_RPM_PLUGINS_FILE_NAME "villas-node-plugins-${SUFFIX}") +set(CPACK_RPM_DOC_FILE_NAME "villas-node-doc-${SUFFIX}") +set(CPACK_RPM_LIB_FILE_NAME "libvillas-${SUFFIX}") +set(CPACK_RPM_DEVEL_FILE_NAME "libvillas-devel-${SUFFIX}") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md") set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") -set(CPACK_SOURCE_IGNORE_FILES "build/;\\.gitmodules;\\.git/;\\.vscode;\\.editorconfig;\\.gitlab-ci.yml;\\.(docker|git)ignore;\\.DS_Store") +set(CPACK_SOURCE_IGNORE_FILES "build/;\\\\.gitmodules;\\\\.git/;\\\\.vscode;\\\\.editorconfig;\\\\.gitlab-ci.yml;\\\\.(docker|git)ignore;\\\\.DS_Store") if(NOT DEFINED CPACK_GENERATOR) set(CPACK_GENERATOR "RPM;TGZ") diff --git a/cmake/config/Coverage.cmake b/cmake/config/Coverage.cmake index ef5bfdbbf..d92286c4f 100644 --- a/cmake/config/Coverage.cmake +++ b/cmake/config/Coverage.cmake @@ -53,6 +53,4 @@ mark_as_advanced( if(CMAKE_BUILD_TYPE STREQUAL "Coverage") target_link_libraries("gcov") - - string(APPEND VARIANTS "-coverage") endif() diff --git a/cmake/config/Debug.cmake b/cmake/config/Debug.cmake index 18d5cea7c..4aa187da1 100644 --- a/cmake/config/Debug.cmake +++ b/cmake/config/Debug.cmake @@ -19,7 +19,3 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . ################################################################################### - -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - string(APPEND VARIANTS "-debug") -endif() diff --git a/cmake/config/Profiling.cmake b/cmake/config/Profiling.cmake index c048e310d..27bd63863 100644 --- a/cmake/config/Profiling.cmake +++ b/cmake/config/Profiling.cmake @@ -51,8 +51,4 @@ mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS_PROFILING ) -if(CMAKE_BUILD_TYPE STREQUAL "Profiling") - string(APPEND VARIANTS "-profile") -endif() - diff --git a/cmake/config/Release.cmake b/cmake/config/Release.cmake index cfa3432bc..4aa187da1 100644 --- a/cmake/config/Release.cmake +++ b/cmake/config/Release.cmake @@ -19,7 +19,3 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . ################################################################################### - -if(CMAKE_BUILD_TYPE STREQUAL "Release") - string(APPEND VARIANTS "-release") -endif() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 99ca867c5..aa3f57c67 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -20,19 +20,45 @@ # along with this program. If not, see . ################################################################################### -add_custom_target(doc - COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} -) +find_package(Doxygen) -configure_file( - Doxyfile.in - ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile -) +if(DOXYGEN_FOUND) + set(DOXYGEN_PROJECT_LOGO doc/pictures/villas_node.svg) + set(DOXYGEN_WARN_LOGFILE ${CMAKE_CURRENT_BINARY_DIR}/warnings.log) + set(DOXYGEN_TAB_SIZE 8) + set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) + set(DOXYGEN_LAYOUT_FILE doc/theme/layout.xml) + set(DOXYGEN_RECURSIVE YES) + set(DOXYGEN_EXAMPLE_PATH etc/) + set(DOXYGEN_EXAMPLE_RECURSIVE YES) + set(DOXYGEN_IMAGE_PATH doc/pictures) + set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md) + set(DOXYGEN_SOURCE_BROWSER YES) + set(DOXYGEN_REFERENCED_BY_RELATION YES) + set(DOXYGEN_HTML_HEADER doc/theme/header.html) + set(DOXYGEN_HTML_EXTRA_STYLESHEET doc/theme/style.css) + set(DOXYGEN_HTML_EXTRA_FILES doc/pictures/acs_eonerc_logo.svg) + set(DOXYGEN_HTML_COLORSTYLE_HUE 209) + set(DOXYGEN_HTML_COLORSTYLE_SAT 88) + set(DOXYGEN_HTML_TIMESTAMP YES) + set(DOXYGEN_HTML_DYNAMIC_SECTIONS YES) + set(DOXYGEN_GENERATE_TREEVIEW YES) + set(DOXYGEN_TREEVIEW_WIDTH 280) + set(DOXYGEN_UML_LOOK YES) + set(DOXYGEN_CALL_GRAPH YES) + set(DOXYGEN_CALLER_GRAPH YES) + set(DOXYGEN_DOT_IMAGE_FORMAT svg) + set(DOXYGEN_INTERACTIVE_SVG YES) + set(DOXYGEN_DIAFILE_DIRS doc/figures/) -install( - DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html - DESTINATION share/villas/node/doc - COMPONENT doc -) + doxygen_add_docs(doc + README.md CONTRIBUTING.md COPYING.md src/ lib/ tests/ include/ doc/ + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + + install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/villas/node + COMPONENT doc + ) +endif() diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt index 43c7c9435..412ee2b07 100644 --- a/etc/CMakeLists.txt +++ b/etc/CMakeLists.txt @@ -20,6 +20,11 @@ # along with this program. If not, see . ################################################################################### -install(DIRECTORY . - DESTINATION etc/villas/node/ +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMPONENT bin + DESTINATION etc/villas/node + FILES_MATCHING + PATTERN "*.conf" + PATTERN "*.json" ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index cdeb80165..cffebee4d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -129,17 +129,32 @@ add_library(villas SHARED ${LIB_SRC}) target_include_directories(villas PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas PUBLIC ${LIBRARIES}) -set_target_properties(villas PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_SOVERSION} +#set_target_properties(villas PROPERTIES +# VERSION ${PROJECT_VERSION} +# SOVERSION ${PROJECT_SOVERSION} +#) + +install( + TARGETS villas + EXPORT VILLASNodeConfig + COMPONENT lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(TARGETS villas EXPORT VILLASNodeConfig - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install( + DIRECTORY ../include/villas/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/villas + COMPONENT devel + FILES_MATCHING + PATTERN "*.h" +) -install(DIRECTORY ../include/villas/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/villas/) +#install( +# EXPORT VILLASNodeConfig +# DESTINATION share/VILLASNode/cmake +#) -#install(EXPORT VILLASNodeConfig DESTINATION share/VILLASNode/cmake) -#export(TARGETS villas FILE VILLASNodeConfig.cmake) +#export( +# TARGETS villas +# FILE VILLASNodeConfig.cmake +#) diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt index 906b348c0..c7f3cbf30 100644 --- a/lib/api/CMakeLists.txt +++ b/lib/api/CMakeLists.txt @@ -43,3 +43,14 @@ set(API_SRC add_library(villas-api SHARED ${API_SRC}) target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-api PUBLIC ${LIBRARIES}) + +#set_target_properties(villas-api PROPERTIES +# VERSION ${PROJECT_VERSION} +# SOVERSION ${PROJECT_SOVERSION} +#) + +install( + TARGETS villas-api + COMPONENT lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt index f7d7a74fc..f6c7828de 100644 --- a/lib/formats/CMakeLists.txt +++ b/lib/formats/CMakeLists.txt @@ -27,6 +27,7 @@ set(FORMAT_SRC villas_human.c csv.c raw.c + msg.c ) set(INCLUDE_DIRS @@ -38,21 +39,19 @@ set(LIBRARIES ) # Enable Google Protobuf format -if(Protobuf_FOUND) +if(ProtobufC_FOUND) list(APPEND FORMAT_SRC protobuf.c ${CMAKE_CURRENT_BINARY_DIR}/villas.pb-c.c ) list(APPEND INCLUDE_DIRS - ${Protobuf_INCLUDE_DIRS} - ${Protobuf_PROTOC_INCLUDE_DIRS} + ${PROTOBUFC_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ) list(APPEND LIBRARIES - ${Protobuf_LIBRARY} - ${Protobuf_PROTOC_LIBRARIES} + ${PROTOBUFC_LIBRARIES} ) set_source_files_properties(villas.pb-c.h villas.pb-c.c @@ -61,7 +60,7 @@ if(Protobuf_FOUND) ) add_custom_command( - COMMAND ${Protobuf_PROTOC_EXECUTABLE} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto + COMMAND ${PROTOBUFC_COMPILER} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto OUTPUT villas.pb-c.c villas.pb-c.h @@ -73,3 +72,14 @@ endif() add_library(villas-formats SHARED ${FORMAT_SRC}) target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-formats PUBLIC ${LIBRARIES}) + +#set_target_properties(villas-formats PROPERTIES +# VERSION ${PROJECT_VERSION} +# SOVERSION ${PROJECT_SOVERSION} +#) + +install( + TARGETS villas-formats + COMPONENT lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/lib/hooks/CMakeLists.txt b/lib/hooks/CMakeLists.txt index ef7802d28..e0f1a37da 100644 --- a/lib/hooks/CMakeLists.txt +++ b/lib/hooks/CMakeLists.txt @@ -53,3 +53,14 @@ endif() add_library(villas-hooks SHARED ${HOOK_SRC}) target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-hooks PUBLIC ${LIBRARIES}) + +#set_target_properties(villas-hooks PROPERTIES +# VERSION ${PROJECT_VERSION} +# SOVERSION ${PROJECT_SOVERSION} +#) + +install( + TARGETS villas-hooks + COMPONENT lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index 36c9e76e3..6f39e1f03 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -126,3 +126,14 @@ endif() add_library(villas-nodes SHARED ${NODE_SRC}) target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas-nodes PUBLIC ${LIBRARIES}) + +#set_target_properties(villas-nodes PROPERTIES +# VERSION ${PROJECT_VERSION} +# SOVERSION ${PROJECT_SOVERSION} +#) + +install( + TARGETS villas-nodes + COMPONENT lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 8a12f074d..dac32b74a 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -44,10 +44,12 @@ add_custom_target(deploy-rpm configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/libvillas.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libvillas.pc + @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libvillas.pc + COMPONENT devel DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig ) diff --git a/packaging/docker/CMakeLists.txt b/packaging/docker/CMakeLists.txt index d26a785d1..72de0defc 100644 --- a/packaging/docker/CMakeLists.txt +++ b/packaging/docker/CMakeLists.txt @@ -23,7 +23,7 @@ set(DOCKER_FILE Dockerfile) set(DOCKER_IMAGE villas/node) set(DOCKER_TAG ${GIT_BRANCH}) -set(DOCKER_RUN_OPTS "--interactive --tty --publish 80:80 --publish 443:443 --publish 12000:12000/udp --publish 12001:12001/udp --privileged --security-opt seccomp:unconfined --volume \"${CMAKE_SOURCE_DIR}:/villas\"") +set(DOCKER_RUN_OPTS --interactive --tty --publish 80:80 --publish 443:443 --publish 12000:12000/udp --publish 12001:12001/udp --privileged --security-opt seccomp:unconfined --volume \"${CMAKE_SOURCE_DIR}:/villas\") foreach(SUFFIX app dev dev-centos dev-ubuntu) add_custom_target(deploy-docker-${SUFFIX} @@ -56,6 +56,7 @@ endforeach() add_custom_target(docker DEPENDS docker-app COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:${DOCKER_TAG} COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:latest + DEPENDS docker-dev ) add_custom_target(deploy-docker DEPENDS docker-app diff --git a/packaging/docker/Dockerfile.dev b/packaging/docker/Dockerfile.dev index dece0626b..54af8157a 100644 --- a/packaging/docker/Dockerfile.dev +++ b/packaging/docker/Dockerfile.dev @@ -38,9 +38,7 @@ ARG VARIANT=unkown # Toolchain RUN dnf -y install \ gcc gcc-c++ \ - pkgconfig make cmake \ - autoconf automake autogen libtool \ - flex bison \ + pkgconfig cmake make ninja-build \ texinfo git curl tar \ protobuf-compiler protobuf-c-compiler @@ -64,6 +62,11 @@ RUN pip install \ # Some of the dependencies are only available in our own repo ADD https://packages.fein-aachen.org/redhat/fein.repo /etc/yum.repos.d/ +# We need to use our own RPM packages of libwebsockets +# as the official ones do contain the CMake files +RUN dnf -y install --repo=villas \ + libwebsockets-2.4.2 + # Dependencies RUN dnf -y install \ openssl openssl-devel \ @@ -71,7 +74,6 @@ RUN dnf -y install \ libnl3-devel \ libcurl-devel \ jansson-devel \ - libwebsockets-devel \ zeromq-devel \ nanomsg-devel \ protobuf-devel \ diff --git a/packaging/libvillas.pc.in b/packaging/libvillas.pc.in new file mode 100644 index 000000000..512fbcf78 --- /dev/null +++ b/packaging/libvillas.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_LIBDIR@ +sharedlibdir=@CMAKE_INSTALL_LIBDIR@ +includedir=@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir} diff --git a/packaging/rpm/villas-node.spec b/packaging/rpm/villas-node.spec deleted file mode 100644 index 71a8a3255..000000000 --- a/packaging/rpm/villas-node.spec +++ /dev/null @@ -1,89 +0,0 @@ -Name: villas-node -Version: §VERSION§ -Vendor: Institute for Automation of Complex Power Systems -Packager: Steffen Vogel -Release: §RELEASE§%{?dist} -Summary: This is VILLASnode, a gateway for processing and forwardning simulation data between real-time simulators. - -License: GPLv3 -URL: https://git.rwth-aachen.de/VILLASframework/VILLASnode -Source0: villas-node-§VERSION§-§RELEASE§.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -BuildRequires: gcc pkgconfig make - -Requires: iproute module-init-tools - -BuildRequires: openssl-devel libconfig-devel libnl3-devel libcurl-devel jansson-devel libwebsockets-devel zeromq-devel nanomsg-devel libiec61850-devel librabbitmq-devel mosquitto-devel comedilib-devel comedilib -Requires: openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib - -%description - -%package doc - -Summary: HTML documentation for users and developers. -Group: Documentation - -%package devel - -Summary: Headers and libraries for building apps that use libvillas. -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel - -The development headers for libvillas. - -%description doc - -%prep -%setup -q - -%build -make DEBUG=1 PREFIX=/usr - -%install -rm -rf %{?buildroot} -make DEBUG=1 PREFIX=/usr DESTDIR=%{?buildroot} install -make DEBUG=1 PREFIX=/usr DESTDIR=%{?buildroot} install-doc - -%check -make DEBUG=1 run-unit-tests -make DEBUG=1 run-integration-tests - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%clean -rm -rf %{?buildroot} - -%files -/usr/bin/rmsem -/usr/bin/rmshm -/usr/bin/villas -/usr/bin/villas-* -/usr/bin/conf2json -/usr/bin/zmq-keygen - -/usr/lib/libvillas.so -/usr/lib/libvillas.so.* - -/usr/lib/libvillas-ext.so -/usr/lib/libvillas-ext.so.* - -/usr/share/villas/node/web/ -/usr/share/villas/node/plugins/ - -%config /etc/villas/node/*.conf -%license COPYING.md - -%files doc -%docdir /usr/share/villas/node/doc/ -/usr/share/villas/node/doc/ - -%files devel -/usr/include/villas/ - -%changelog -* Fri Mar 17 2017 Steffen Vogel Date: Sat, 30 Jun 2018 01:29:56 +0200 Subject: [PATCH 17/40] fix documentation of kernel code --- include/villas/kernel/if.h | 4 +++- include/villas/kernel/kernel.h | 4 +++- include/villas/kernel/nl.h | 4 +++- include/villas/kernel/rt.h | 4 +++- include/villas/kernel/tc.h | 4 +++- include/villas/kernel/tc_netem.h | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/villas/kernel/if.h b/include/villas/kernel/if.h index 1d6420098..1ff8fc68a 100644 --- a/include/villas/kernel/if.h +++ b/include/villas/kernel/if.h @@ -24,7 +24,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once diff --git a/include/villas/kernel/kernel.h b/include/villas/kernel/kernel.h index 265e125f4..d02735139 100644 --- a/include/villas/kernel/kernel.h +++ b/include/villas/kernel/kernel.h @@ -21,7 +21,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once diff --git a/include/villas/kernel/nl.h b/include/villas/kernel/nl.h index 894df4f9f..13f03eff1 100644 --- a/include/villas/kernel/nl.h +++ b/include/villas/kernel/nl.h @@ -21,7 +21,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once diff --git a/include/villas/kernel/rt.h b/include/villas/kernel/rt.h index c6c5c0e9b..9877882d1 100644 --- a/include/villas/kernel/rt.h +++ b/include/villas/kernel/rt.h @@ -22,7 +22,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once diff --git a/include/villas/kernel/tc.h b/include/villas/kernel/tc.h index 0b5afbbc3..283f7a89d 100644 --- a/include/villas/kernel/tc.h +++ b/include/villas/kernel/tc.h @@ -26,7 +26,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once diff --git a/include/villas/kernel/tc_netem.h b/include/villas/kernel/tc_netem.h index b6d0a86c4..76db24db0 100644 --- a/include/villas/kernel/tc_netem.h +++ b/include/villas/kernel/tc_netem.h @@ -26,7 +26,9 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel @{ */ +/** @addtogroup kernel Kernel + * @{ + */ #pragma once From ebf1592dabbbd9b80ebd66b477eb17449ba9cd9c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 01:30:06 +0200 Subject: [PATCH 18/40] update README --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a9163095a..cca9b365e 100644 --- a/README.md +++ b/README.md @@ -16,19 +16,16 @@ VILLASnode is a client/server application to connect simulation equipment and so by using protcols such as: - IEEE 802.2 Ethernet / IP / UDP, - - ZeroMQ, - - nanomsg, + - ZeroMQ & nanomsg, + - MQTT & AMQP - WebSockets - Shared Memory - Files + - IEC 61850 Sampled Values / GOOSE + - Analog/Digital IO via Comedi drivers + - Infiniband (ibverbs) -Planned: - - - IEC 61850-9-2 Sampled Values, - - IEC 61850-8-1 GOOSE, - - AMQP - -It's designed with a focus on very low latency to achieve almost realtime exchange of simulation data. +It's designed with a focus on very low latency to achieve real-time exchange of simulation data. VILLASnode is used in distributed- and co-simulation scenarios and developed for the field of power grid simulation at the EON Energy Research Center in Aachen, Germany. ## Documentation @@ -37,7 +34,7 @@ User documentation is available here: Date: Sat, 30 Jun 2018 01:30:13 +0200 Subject: [PATCH 19/40] update CI config --- .gitlab-ci.yml | 108 ++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 809867c71..704802724 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,7 +25,7 @@ before_script: docker-dev: stage: prepare script: - - make docker-dev + - docker build -f packaging/docker/Dockerfile.dev -t ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} . tags: - shell - linux @@ -36,6 +36,8 @@ docker-dev: build:source: stage: build script: + - mkdir -p build && cd build + - cmake .. - make artifacts: expire_in: 1 week @@ -53,6 +55,8 @@ build:docs: paths: - build/release/doc/ script: + - mkdir -p build && cd build + - cmake .. - make doc image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} tags: @@ -67,13 +71,15 @@ build:packages: - dnf -y config-manager --add-repo https://${DEPLOY_USER}:${DEPLOY_PASS}@${DEPLOY_HOST}/packages/villas.repo - dnf -y --refresh install openssl-devel libconfig-devel libnl3-devel libcurl-devel jansson-devel libxil-devel libwebsockets-devel zeromq-devel nanomsg-devel script: - - make rpm-villas-node + - mkdir -p build && cd build + - cmake .. + - make package artifacts: expire_in: 1 week name: ${CI_PROJECT_NAME}-packages-${CI_BUILD_REF} paths: - - build/release/packaging/*.tar.gz - - build/release/packaging/rpm/RPMS/ + - build/*.tar.gz + - build/*.rpm image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} tags: - docker @@ -85,28 +91,30 @@ build:packages: # Stage: test ############################################################################## -test:coverage: - stage: test - variables: - COVERAGE: "1" - script: - - make coverage - artifacts: - name: ${CI_PROJECT_NAME}-coverage-${CI_BUILD_REF} - paths: - - build/release-coverage/coverage/ - - build/release-coverage/coverage.txt - - build/release-coverage/coverage.xml - image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} - coverage: '/lines: (\d+\.\d+\%)/' - tags: - - docker +#test:coverage: +# stage: test +# variables: +# COVERAGE: "1" +# script: +# - make coverage +# artifacts: +# name: ${CI_PROJECT_NAME}-coverage-${CI_BUILD_REF} +# paths: +# - build/release-coverage/coverage/ +# - build/release-coverage/coverage.txt +# - build/release-coverage/coverage.xml +# image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} +# coverage: '/lines: (\d+\.\d+\%)/' +# tags: +# - docker test:unit: stage: test dependencies: - build:source script: + - mkdir -p build && cd build + - cmake .. - make run-unit-tests image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} tags: @@ -117,6 +125,8 @@ test:integration: dependencies: - build:source script: + - mkdir -p build && cd build + - cmake .. - make run-integration-tests artifacts: name: ${CI_PROJECT_NAME}-integration-tests-${CI_BUILD_REF} @@ -127,18 +137,20 @@ test:integration: tags: - docker -test:valgrind: - stage: test - variables: - DEBUG: "1" - script: - - make run-valgrind - dependencies: - - build:source - allow_failure: true - image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} - tags: - - docker +#test:valgrind: +# stage: test +# variables: +# DEBUG: "1" +# script: +# - mkdir -p build && cd build +# - cmake .. +# - make run-valgrind +# dependencies: +# - build:source +# allow_failure: true +# image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} +# tags: +# - docker # Stage: deploy ############################################################################## @@ -147,13 +159,12 @@ deploy:web: stage: deploy script: - ssh ${DEPLOY_USER}@${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}/{coverage,doc}/${CI_BUILD_REF_NAME}/ - - rsync ${RSYNC_OPTS} build/release-coverage/coverage/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/coverage/$CI_BUILD_REF_NAME/ - - rsync ${RSYNC_OPTS} build/release/doc/html/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/doc/$CI_BUILD_REF_NAME/ +# - rsync ${RSYNC_OPTS} build/release-coverage/coverage/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/coverage/$CI_BUILD_REF_NAME/ + - rsync ${RSYNC_OPTS} build/doc/html/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/doc/$CI_BUILD_REF_NAME/ - rsync ${RSYNC_OPTS} web/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/ dependencies: - build:docs - - build:packages - - test:coverage +# - test:coverage only: - tags tags: @@ -163,8 +174,8 @@ deploy:packages: stage: deploy script: - ssh ${DEPLOY_USER}@${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}/{dist,../packages} - - rsync ${RSYNC_OPTS} build/release/packaging/rpm/RPMS/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/../packages/ - - rsync ${RSYNC_OPTS} build/release/packaging/*.tar.gz ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/dist/ + - rsync ${RSYNC_OPTS} build/*.rpm ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/../packages/x86_64/ + - rsync ${RSYNC_OPTS} build/*.tar.gz ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/dist/ - ssh ${DEPLOY_USER}@${DEPLOY_HOST} createrepo ${DEPLOY_PATH}/../packages dependencies: - build:packages @@ -187,24 +198,9 @@ docker: DOCKER_IMAGE: villas/node DOCKER_TAG: $CI_COMMIT_TAG script: - - make docker - - make deploy-docker - - docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest - - docker push ${DOCKER_IMAGE}:latest - dependencies: - - build:packages + - mkdir -p build && cd build + - cmake .. + - make deploy-docker deploy-docker-dev tags: - shell - linux - only: - - tags - -docker:dev: - stage: docker - script: - - make deploy-docker-dev - tags: - - shell - - linux - only: - - develop From f7ed74386a08377f595b300815aa190c1bccae03 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 03:01:29 +0200 Subject: [PATCH 20/40] fix CI --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70444b0a4..5b877164a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,7 @@ string(TIMESTAMP BUILD_DATE "%Y%m%d") if(DEFINED ENV{CI}) string(APPEND VARIANT "-ci") string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 GIT_REV) - set(GIT_BRANCH ${CI_COMMIT_REF_NAME}) + set(GIT_BRANCH $ENV{CI_COMMIT_REF_NAME}) else() execute_process( COMMAND git rev-parse --short=7 HEAD From bea165de41838f6ea255be5ab268eb5185d46ae6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:36:47 +0200 Subject: [PATCH 21/40] rename source files of executables to match their name --- src/CMakeLists.txt | 18 ++++++++---------- src/{convert.c => villas-convert.c} | 0 src/{hook.c => villas-hook.c} | 0 src/{node.c => villas-node.c} | 0 src/{pipe.c => villas-pipe.c} | 0 src/{signal.c => villas-signal.c} | 0 src/{test-cmp.c => villas-test-cmp.c} | 0 src/{test-rtt.c => villas-test-rtt.c} | 0 src/{test-shmem.c => villas-test-shmem.c} | 0 9 files changed, 8 insertions(+), 10 deletions(-) rename src/{convert.c => villas-convert.c} (100%) rename src/{hook.c => villas-hook.c} (100%) rename src/{node.c => villas-node.c} (100%) rename src/{pipe.c => villas-pipe.c} (100%) rename src/{signal.c => villas-signal.c} (100%) rename src/{test-cmp.c => villas-test-cmp.c} (100%) rename src/{test-rtt.c => villas-test-rtt.c} (100%) rename src/{test-shmem.c => villas-test-shmem.c} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 260e2c7d9..6f9ad7bc3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,25 +23,23 @@ # All executables link against libvillas link_libraries(villas) -add_executable(villas-node node.c) -add_executable(villas-test-rtt test-rtt.c) -add_executable(villas-test-shmem test-shmem.c) +add_executable(villas-node villas-node.c) +add_executable(villas-test-rtt villas-test-rtt.c) +add_executable(villas-test-shmem villas-test-shmem.c) set(SRCS ) if(WITH_IO) - add_executable(villas-test-cmp test-cmp.c) - - add_executable(villas-convert convert.c) - - add_executable(villas-pipe pipe.c) target_link_libraries(villas-pipe PUBLIC pthread) + add_executable(villas-test-cmp villas-test-cmp.c) + add_executable(villas-convert villas-convert.c) + add_executable(villas-pipe villas-pipe.c) + add_executable(villas-signal villas-signal.c) - add_executable(villas-signal signal.c) endif() if(WITH_IO AND WITH_HOOKS) - add_executable(villas-hook hook.c) + add_executable(villas-hook villas-hook.c) endif() install( diff --git a/src/convert.c b/src/villas-convert.c similarity index 100% rename from src/convert.c rename to src/villas-convert.c diff --git a/src/hook.c b/src/villas-hook.c similarity index 100% rename from src/hook.c rename to src/villas-hook.c diff --git a/src/node.c b/src/villas-node.c similarity index 100% rename from src/node.c rename to src/villas-node.c diff --git a/src/pipe.c b/src/villas-pipe.c similarity index 100% rename from src/pipe.c rename to src/villas-pipe.c diff --git a/src/signal.c b/src/villas-signal.c similarity index 100% rename from src/signal.c rename to src/villas-signal.c diff --git a/src/test-cmp.c b/src/villas-test-cmp.c similarity index 100% rename from src/test-cmp.c rename to src/villas-test-cmp.c diff --git a/src/test-rtt.c b/src/villas-test-rtt.c similarity index 100% rename from src/test-rtt.c rename to src/villas-test-rtt.c diff --git a/src/test-shmem.c b/src/villas-test-shmem.c similarity index 100% rename from src/test-shmem.c rename to src/villas-test-shmem.c From f7bf0cc1fe58969b2c1cee771d9d35c5cd580ae6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:37:49 +0200 Subject: [PATCH 22/40] cmake: check if criterion is present --- CMakeLists.txt | 9 ++++-- src/CMakeLists.txt | 2 +- tests/unit/CMakeLists.txt | 59 ++++++++++++++++++++++----------------- 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b877164a..d924b0a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,11 +24,12 @@ cmake_minimum_required(VERSION 3.3) project(VILLASnode C CXX) +# Several CMake settings/defaults set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) - +set(CMAKE_THREAD_PREFER_PTHREAD ON) +set(CMAKE_SKIP_INSTALL_RPATH ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig") if(APPLE) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/local/lib/pkgconfig") @@ -85,12 +86,16 @@ check_include_file("sys/mman.h" HAS_MMAN) # Check packages find_package(PkgConfig REQUIRED) +find_package(Threads REQUIRED) find_package(Libwebsockets REQUIRED) find_package(OpenSSL REQUIRED) find_package(CURL REQUIRED) find_package(ProtobufC) find_package(Opal) +set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig") + +pkg_check_modules(CRITERION IMPORTED_TARGET criterion) pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) pkg_check_modules(LIBNL3_ROUTE IMPORTED_TARGET libnl-route-3.0) pkg_check_modules(LIBIEC61850 IMPORTED_TARGET libiec61850>=1.2.0) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f9ad7bc3..3c0fe85dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,12 +30,12 @@ add_executable(villas-test-shmem villas-test-shmem.c) set(SRCS ) if(WITH_IO) - target_link_libraries(villas-pipe PUBLIC pthread) add_executable(villas-test-cmp villas-test-cmp.c) add_executable(villas-convert villas-convert.c) add_executable(villas-pipe villas-pipe.c) add_executable(villas-signal villas-signal.c) + target_link_libraries(villas-pipe PUBLIC Threads::Threads) endif() if(WITH_IO AND WITH_HOOKS) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index dae9b6414..1bae9350b 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -20,31 +20,38 @@ # along with this program. If not, see . ################################################################################### -set(TEST_SRC - advio.c - bitset.c - config_json.c - hist.c - io.c - json.c - kernel.c - list.c - log.c - main.c - mapping.c - memory.c - pool.c - queue.c - queue_signalled.c - task.c - timing.c - utils.c -) +if(CRITERION_FOUND) -add_executable(unit-tests ${TEST_SRC}) -target_link_libraries(unit-tests PUBLIC villas criterion pthread) + set(TEST_SRC + advio.c + bitset.c + config_json.c + hist.c + io.c + json.c + kernel.c + list.c + log.c + main.c + mapping.c + memory.c + pool.c + queue.c + queue_signalled.c + task.c + timing.c + utils.c + ) -add_custom_target(run-unit-tests - COMMAND $ ${CRITERION_OPTS} - DEPENDS unit-tests -) + add_executable(unit-tests ${TEST_SRC}) + target_link_libraries(unit-tests PUBLIC + ${CRITERION_LIBRARIES} + villas + Threads::Threads + ) + + add_custom_target(run-unit-tests + COMMAND $ ${CRITERION_OPTS} + DEPENDS unit-tests + ) +endif() From 66f821a0f4d84cb461cadcb93ab12de34bc99c16 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:38:09 +0200 Subject: [PATCH 23/40] ci: check location of artifacts --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 704802724..a9e277698 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,7 +43,7 @@ build:source: expire_in: 1 week name: ${CI_PROJECT_NAME}-${CI_BUILD_REF} paths: - - build/release/ + - build/ image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} tags: - docker @@ -53,7 +53,7 @@ build:docs: artifacts: name: ${CI_PROJECT_NAME}-doc-${CI_BUILD_REF} paths: - - build/release/doc/ + - build/doc/ script: - mkdir -p build && cd build - cmake .. From 30c7b8fa7eecea1427bcad67839eb7dbadc73ab1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:38:20 +0200 Subject: [PATCH 24/40] ci: fix docker deployment --- .gitlab-ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9e277698..851a5a9df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,9 @@ variables: PREFIX: /usr/ RSYNC_OPTS: --recursive --ignore-missing-args --chown ${DEPLOY_USER}:${DEPLOY_USER} CRITERION_OPTS: --ignore-warnings + DOCKER_TAG: $CI_COMMIT_TAG DOCKER_TAG_DEV: ${CI_COMMIT_REF_NAME} + DOCKER_IMAGE: villas/node DOCKER_IMAGE_DEV: villas/node-dev stages: @@ -194,13 +196,10 @@ deploy:packages: docker: stage: docker - variables: - DOCKER_IMAGE: villas/node - DOCKER_TAG: $CI_COMMIT_TAG script: - - mkdir -p build && cd build - - cmake .. - - make deploy-docker deploy-docker-dev + - docker build -f packaging/docker/Dockerfile.app -t ${DOCKER_IMAGE}:${DOCKER_TAG} . + - docker push ${DOCKER_IMAGE}:${DOCKER_TAG} + - docker push ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} tags: - shell - linux From ab2b7d95cf908e20a7917e9cd26dbe80f4a34ec5 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:40:33 +0200 Subject: [PATCH 25/40] ci: remove support for valgrind and coverage testing --- .gitlab-ci.yml | 32 --------------------- tests/unit/Makefile.gcov.inc | 56 ------------------------------------ 2 files changed, 88 deletions(-) delete mode 100644 tests/unit/Makefile.gcov.inc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 851a5a9df..b1b93fee1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,23 +93,6 @@ build:packages: # Stage: test ############################################################################## -#test:coverage: -# stage: test -# variables: -# COVERAGE: "1" -# script: -# - make coverage -# artifacts: -# name: ${CI_PROJECT_NAME}-coverage-${CI_BUILD_REF} -# paths: -# - build/release-coverage/coverage/ -# - build/release-coverage/coverage.txt -# - build/release-coverage/coverage.xml -# image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} -# coverage: '/lines: (\d+\.\d+\%)/' -# tags: -# - docker - test:unit: stage: test dependencies: @@ -139,21 +122,6 @@ test:integration: tags: - docker -#test:valgrind: -# stage: test -# variables: -# DEBUG: "1" -# script: -# - mkdir -p build && cd build -# - cmake .. -# - make run-valgrind -# dependencies: -# - build:source -# allow_failure: true -# image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} -# tags: -# - docker - # Stage: deploy ############################################################################## diff --git a/tests/unit/Makefile.gcov.inc b/tests/unit/Makefile.gcov.inc deleted file mode 100644 index 973ee2a48..000000000 --- a/tests/unit/Makefile.gcov.inc +++ /dev/null @@ -1,56 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -COVERAGE_TESTS = $(BUILDDIR)/unit-tests -COVERAGE_OBJS = $(LIB_OBJS) $(SRC_OBJS) - -GCDAS = $(COVERAGE_OBJS:.o=.gcda) -GCNOS = $(COVERAGE_OBJS:.o=.gcno) - -GCOVR_OPTS = --exclude $(SRCDIR)/include --root $(SRCDIR) --sort-percentage --print-summary - -coverage: $(BUILDDIR)/coverage/index.html $(BUILDDIR)/coverage.xml $(BUILDDIR)/coverage.txt - -$(BUILDDIR)/coverage.txt: $(addsuffix .gcdas,$(COVERAGE_TESTS)) | $$(dir $$@) - gcovr $(GCOVR_OPTS) -o $@ - -$(BUILDDIR)/coverage.xml: $(addsuffix .gcdas,$(COVERAGE_TESTS)) | $$(dir $$@) - gcovr $(GCOVR_OPTS) --xml --xml-pretty -o $@ - -$(BUILDDIR)/coverage/index.html: $(addsuffix .gcdas,$(COVERAGE_TESTS)) | $$(dir $$@) - gcovr $(GCOVR_OPTS) --html --html-details -o $@ - -# This is an intermediate target. It is used to run the test only once for all gcovr rules. -%.gcdas: % - @echo "Delete previous coverage information" - rm -f $(GCDAS) - @echo "Run $< for collecting coverage information (.gcda)" - $^ $(CRITERION_OPTS) - -clean-coverage: - rm -rf $(BUILDDIR)/coverage $(BUILDDIR)/coverage.txt $(BUILDDIR)/coverage.xml - rm -f $(GCDAS) - -install-coverage: - -.INTERMEDIATE: $(addsuffix .gcdas,$(COVERAGE_TESTS)) -.PHONY: coverage gcda clean-coverage install-coverage From 3120256dc44111ec78c5a1bbc472a71af089f84d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:41:17 +0200 Subject: [PATCH 26/40] cmake: link tools against pthread imported target --- tools/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f18a5c568..107c7bfae 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -29,10 +29,10 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") add_executable(rmshm rmshm.c) - target_link_libraries(rmshm PUBLIC pthread rt) + target_link_libraries(rmshm PUBLIC Threads::Threads rt) add_executable(rmsem rmsem.c) - target_link_libraries(rmsem PUBLIC pthread rt) + target_link_libraries(rmsem PUBLIC Threads::Threads rt) list(APPEND TOOLS rmsem rmshm) endif() From 994f912a9fb37c138e1d3a0ea39fe59dde1e8fae Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:43:10 +0200 Subject: [PATCH 27/40] cmake: use MODULE targets for plugins --- plugins/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index cb26458c1..a2e195c35 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -25,7 +25,7 @@ link_libraries(villas) include_directories("${CMAKE_SOURCE_DIR}/include") add_definitions("-DVILLAS") -add_library(simple_circuit SHARED models/simple_circuit.c) +add_library(simple_circuit MODULE models/simple_circuit.c) install( TARGETS simple_circuit COMPONENT plugins @@ -33,7 +33,7 @@ install( ) if(WITH_HOOKS) - add_library(example_hook SHARED hooks/example_hook.c) + add_library(example_hook MODULE hooks/example_hook.c) install( TARGETS example_hook COMPONENT plugins From c0688ae2cc7bfcbcac05e67b54f3a73578a2d19d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:43:26 +0200 Subject: [PATCH 28/40] cmake: remove some obsolete coverage bits --- tests/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7efc9713e..03bb103c4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,10 +23,6 @@ add_subdirectory(unit) add_subdirectory(integration) -if(CMAKE_BUILD_TYPE STREQUAL "Coverage") - #include tests/unit/Makefile.gcov.inc -endif() - add_custom_target(tests DEPENDS unit-tests integration-tests ) From 937c75ee368c0343e2a3a27f19bbb6d79fb9bfea Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 10:53:52 +0200 Subject: [PATCH 29/40] ci: remove Git mirror as it is now handled by GitLab itself --- .gitlab-ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1b93fee1..ffa31f7e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -129,12 +129,10 @@ deploy:web: stage: deploy script: - ssh ${DEPLOY_USER}@${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}/{coverage,doc}/${CI_BUILD_REF_NAME}/ -# - rsync ${RSYNC_OPTS} build/release-coverage/coverage/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/coverage/$CI_BUILD_REF_NAME/ - rsync ${RSYNC_OPTS} build/doc/html/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/doc/$CI_BUILD_REF_NAME/ - rsync ${RSYNC_OPTS} web/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/ dependencies: - build:docs -# - test:coverage only: - tags tags: @@ -154,11 +152,6 @@ deploy:packages: only: - tags -.deploy:git-mirror: - stage: deploy - script: - - git push --force --mirror https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/VILLASframework/VILLASnode.git - # Stage: docker ############################################################################## From 3944544f6d3a19d5409ae7f61b80eafc802a3425 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 11:54:38 +0200 Subject: [PATCH 30/40] cmake: make build more configurable --- CMakeLists.txt | 55 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d924b0a68..f10fb3b8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,6 @@ include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(GNUInstallDirs) -set(CMAKE_SKIP_RPATH ON) - # Compiler flags if(BUILD32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") @@ -90,11 +88,15 @@ find_package(Threads REQUIRED) find_package(Libwebsockets REQUIRED) find_package(OpenSSL REQUIRED) find_package(CURL REQUIRED) -find_package(ProtobufC) find_package(Opal) +# Check programs +find_program(PROTOBUFC_COMPILER NAMES protoc-c) +find_program(PROTOBUF_COMPILER NAMES protoc) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig") +pkg_check_modules(PROTOBUFC IMPORTED_TARGET libprotobuf-c) pkg_check_modules(CRITERION IMPORTED_TARGET criterion) pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson) pkg_check_modules(LIBNL3_ROUTE IMPORTED_TARGET libnl-route-3.0) @@ -114,6 +116,11 @@ option(WITH_IO "Build with support format plugins" ON) option(WITH_WEB "Build with internal webserver" ON) option(WITH_API "Build with remote control API" ON) option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON) +option(WITH_TOOLS "Build auxilary tools" ON) +option(WITH_TESTS "Run tests" ON) +option(WITH_PLUGINS "Build plugins" ON) +option(WITH_CLIENTS "Build client applications" ON) +option(WITH_DOC "Build documentation" ON) set(V 2) set(PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -186,28 +193,48 @@ include_directories( ${CMAKE_BINARY_DIR}/include ) +add_subdirectory(etc) add_subdirectory(lib) add_subdirectory(src) -add_subdirectory(tools) -add_subdirectory(plugins) -add_subdirectory(etc) -add_subdirectory(doc) add_subdirectory(web) -add_subdirectory(clients) -add_subdirectory(tests) add_subdirectory(packaging) +if(WITH_TOOLS) + add_subdirectory(tools) +endif() + +if(WITH_TOOLS) + add_subdirectory(plugins) +endif() + +if(WITH_DOC) + add_subdirectory(doc) +endif() + +if(WITH_CLIENTS) + add_subdirectory(clients) +endif() + +if(WITH_TESTS) + add_subdirectory(tests) +endif() + configure_file( ${CMAKE_SOURCE_DIR}/include/villas/config.h.in ${CMAKE_BINARY_DIR}/include/villas/config.h ) # Show feature summary -add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") -add_feature_info(IO WITH_IO "Build with support format plugins") -add_feature_info(WEB WITH_WEB "Build with internal webserver") -add_feature_info(API WITH_API "Build with remote control API") -add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configuration syntax") +add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") +add_feature_info(IO WITH_IO "Build with support format plugins") +add_feature_info(WEB WITH_WEB "Build with internal webserver") +add_feature_info(API WITH_API "Build with remote control API") +add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configuration syntax") +add_feature_info(TOOLS WITH_TOOLS "Build auxilary tools") +add_feature_info(TESTS WITH_TESTS "Run tests") +add_feature_info(PLUGINS WITH_PLUGINS "Build plugins") +add_feature_info(CLIENTS WITH_CLIENTS "Build client applications") +add_feature_info(DOC WITH_DOC "Build documentation") if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) feature_summary(WHAT ALL VAR FEATURES) From c1d011b14252e4741aa1b1d96e0a39a0a10e0c3c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 11:54:55 +0200 Subject: [PATCH 31/40] ci: move packaging into seperate stage --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ffa31f7e0..ab64b3ff2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ variables: stages: - prepare - build + - build2 - test - deploy - docker @@ -67,11 +68,10 @@ build:docs: - tags - master -build:packages: - stage: build - before_script: - - dnf -y config-manager --add-repo https://${DEPLOY_USER}:${DEPLOY_PASS}@${DEPLOY_HOST}/packages/villas.repo - - dnf -y --refresh install openssl-devel libconfig-devel libnl3-devel libcurl-devel jansson-devel libxil-devel libwebsockets-devel zeromq-devel nanomsg-devel +build2:packages: + stage: build2 + dependencies: + - build:docs script: - mkdir -p build && cd build - cmake .. @@ -146,7 +146,7 @@ deploy:packages: - rsync ${RSYNC_OPTS} build/*.tar.gz ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/dist/ - ssh ${DEPLOY_USER}@${DEPLOY_HOST} createrepo ${DEPLOY_PATH}/../packages dependencies: - - build:packages + - build2:packages tags: - villas-deploy only: From e06b0c984339e38da9f37d4acd0499a8c9fefe4b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Jun 2018 11:55:19 +0200 Subject: [PATCH 32/40] white space changes --- packaging/docker/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packaging/docker/CMakeLists.txt b/packaging/docker/CMakeLists.txt index 72de0defc..15d14e529 100644 --- a/packaging/docker/CMakeLists.txt +++ b/packaging/docker/CMakeLists.txt @@ -23,7 +23,18 @@ set(DOCKER_FILE Dockerfile) set(DOCKER_IMAGE villas/node) set(DOCKER_TAG ${GIT_BRANCH}) -set(DOCKER_RUN_OPTS --interactive --tty --publish 80:80 --publish 443:443 --publish 12000:12000/udp --publish 12001:12001/udp --privileged --security-opt seccomp:unconfined --volume \"${CMAKE_SOURCE_DIR}:/villas\") +set(DOCKER_RUN_OPTS + --interactive + --tty + --publish 80:80 + --publish 443:443 + --publish 12000:12000/udp + --publish 12001:12001/udp + --publish 2345:2345 + --privileged + --security-opt seccomp:unconfined + --volume \"${CMAKE_SOURCE_DIR}:/villas\" +) foreach(SUFFIX app dev dev-centos dev-ubuntu) add_custom_target(deploy-docker-${SUFFIX} From 590166f7fa517c551b3063346487d068480cf02c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 15:13:04 +0200 Subject: [PATCH 33/40] cmake: change capitalization of FindPackage modules --- cmake/FindMosquitto.cmake | 2 +- cmake/FindOpal.cmake | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/FindMosquitto.cmake b/cmake/FindMosquitto.cmake index 8782092c2..0d65c6780 100644 --- a/cmake/FindMosquitto.cmake +++ b/cmake/FindMosquitto.cmake @@ -31,7 +31,7 @@ find_library(MOSQUITTO_LIBRARY include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set VILLASNODE_FOUND to TRUE # if all listed variables are TRUE -find_package_handle_standard_args(MOSQUITTO DEFAULT_MSG +find_package_handle_standard_args(Mosquitto DEFAULT_MSG MOSQUITTO_LIBRARY MOSQUITTO_INCLUDE_DIR) mark_as_advanced(MOSQUITTO_INCLUDE_DIR MOSQUITTO_LIBRARY) diff --git a/cmake/FindOpal.cmake b/cmake/FindOpal.cmake index 24255d228..fca8ad7f2 100644 --- a/cmake/FindOpal.cmake +++ b/cmake/FindOpal.cmake @@ -29,9 +29,7 @@ find_library(OPAL_LIBRARY ) include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set VILLASNODE_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(OPAL DEFAULT_MSG OPAL_LIBRARY OPAL_INCLUDE_DIR) +find_package_handle_standard_args(Opal DEFAULT_MSG OPAL_LIBRARY OPAL_INCLUDE_DIR) mark_as_advanced(OPAL_INCLUDE_DIR OPAL_LIBRARY) From b35a60e038c8c76ca4f7b85ebfc37b9a9dd0d243 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 15:13:32 +0200 Subject: [PATCH 34/40] cmake: add missing library dependency to libvillas --- lib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index cffebee4d..8be8e1f17 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -67,6 +67,7 @@ set(LIB_SRC ) add_subdirectory(nodes) +list(APPEND LIBRARIES villas-nodes) if(LIBCONFIG_FOUND) list(APPEND INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS}) From 54c9964f6c621453c8f63c9750c2e5963aa17216 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:24:20 +0200 Subject: [PATCH 35/40] cmake: improve handling of protofbuf outputs --- clients/python/CMakeLists.txt | 6 +---- cmake/FindProtobufC.cmake | 20 -------------- lib/formats/CMakeLists.txt | 51 ++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 47 deletions(-) delete mode 100644 cmake/FindProtobufC.cmake diff --git a/clients/python/CMakeLists.txt b/clients/python/CMakeLists.txt index 310a2927b..e9bfca724 100644 --- a/clients/python/CMakeLists.txt +++ b/clients/python/CMakeLists.txt @@ -20,8 +20,4 @@ # along with this program. If not, see . ################################################################################### -add_custom_command(OUTPUT villas_pb2.py - COMMAND protoc ${CMAKE_SOURCE_DIR}/lib/nodes/villas.proto - MAIN_DEPENDENCY villas.proto -) - + diff --git a/cmake/FindProtobufC.cmake b/cmake/FindProtobufC.cmake deleted file mode 100644 index d02cceba9..000000000 --- a/cmake/FindProtobufC.cmake +++ /dev/null @@ -1,20 +0,0 @@ -pkg_check_modules(PC_PROTOBUFC QUIET libprotobuf-c) -set(PROTOBUFC_DEFINITIONS ${PC_PROTOBUFC_CFLAGS_OTHER}) - -find_path(PROTOBUFC_INCLUDE_DIR google/protobuf-c/protobuf-c.h - HINTS ${PC_PROTOBUFC_INCLUDEDIR} ${PC_PROTOBUFC_INCLUDE_DIRS} - PATH_SUFFIXES libprotobuf-c) - -find_library(PROTOBUFC_LIBRARY NAMES protobuf-c - HINTS ${PC_PROTOBUFC_LIBDIR} - ${PC_PROTOBUFC_LIBRARY_DIRS}) - -find_program(PROTOBUFC_COMPILER protoc-c) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(libprotobuf-c DEFAULT_MSG - PROTOBUFC_LIBRARY PROTOBUFC_INCLUDE_DIR PROTOBUFC_COMPILER) -mark_as_advanced(PROTOBUFC PROTOBUFC_INCLUDE_DIR PROTOBUFC_LIBRARY) - -set(PROTOBUFC_LIBRARIES ${PROTOBUFC_LIBRARY}) -set(PROTOBUFC_INCLUDE_DIRS ${PROTOBUFC_INCLUDE_DIR}) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt index f6c7828de..8e4ecee3f 100644 --- a/lib/formats/CMakeLists.txt +++ b/lib/formats/CMakeLists.txt @@ -38,6 +38,31 @@ set(LIBRARIES ${OPENSSL_LIBRARIES} ) +if(DEFINED PROTOBUF_COMPILER) + add_custom_target(protobuf ALL + COMMAND ${PROTOBUF_COMPILER} + --python_out=${CMAKE_CURRENT_BINARY_DIR} + #--php_out=${CMAKE_BINARY_DIR} + --js_out=${CMAKE_CURRENT_BINARY_DIR} + --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + villas.proto + DEPENDS villas.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif() + +if(DEFINED PROTOBUFC_COMPILER) + add_custom_target(protobuf-c ALL + COMMAND ${PROTOBUFC_COMPILER} + --c_out=${CMAKE_CURRENT_BINARY_DIR} + villas.proto + DEPENDS villas.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_dependencies(protobuf protobuf-c) +endif() + # Enable Google Protobuf format if(ProtobufC_FOUND) list(APPEND FORMAT_SRC @@ -59,27 +84,9 @@ if(ProtobufC_FOUND) GENERATED TRUE ) - add_custom_command( - COMMAND ${PROTOBUFC_COMPILER} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto - OUTPUT - villas.pb-c.c - villas.pb-c.h - MAIN_DEPENDENCY villas.proto - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) + add_dependencies(formats protobuf-c) endif() -add_library(villas-formats SHARED ${FORMAT_SRC}) -target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS}) -target_link_libraries(villas-formats PUBLIC ${LIBRARIES}) - -#set_target_properties(villas-formats PROPERTIES -# VERSION ${PROJECT_VERSION} -# SOVERSION ${PROJECT_SOVERSION} -#) - -install( - TARGETS villas-formats - COMPONENT lib - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +add_library(formats STATIC ${FORMAT_SRC}) +target_include_directories(formats PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(formats INTERFACE ${LIBRARIES}) From a27de9542c9631e922731606e6e0bb11f3a8bb69 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:24:37 +0200 Subject: [PATCH 36/40] cmake: improve RPM dependencies --- cmake/VILLASnodePackaging.cmake | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/cmake/VILLASnodePackaging.cmake b/cmake/VILLASnodePackaging.cmake index 5977288c9..39e07c942 100644 --- a/cmake/VILLASnodePackaging.cmake +++ b/cmake/VILLASnodePackaging.cmake @@ -29,13 +29,30 @@ set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION}) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_PATCH_VERSION}) set(CPACK_RPM_COMPONENT_INSTALL ON) -set(CPACK_RPM_MAIN_COMPONENT "bin") +set(CPACK_RPM_MAIN_COMPONENT bin) + +set(CPACK_RPM_LIB_PACKAGE_NAME libvillas) +set(CPACK_RPM_DEVEL_PACKAGE_NAME libvillas-devel) +set(CPACK_RPM_BIN_PACKAGE_NAME villas-node) +set(CPACK_RPM_PLUGINS_PACKAGE_NAME villas-node-plugins) +set(CPACK_RPM_TOOLS_PACKAGE_NAME villas-node-tools) +set(CPACK_RPM_DOC_PACKAGE_NAME villas-node-doc) + +set(SUFFIX "${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") +set(CPACK_RPM_LIB_FILE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-${SUFFIX}") +set(CPACK_RPM_DEVEL_FILE_NAME "${CPACK_RPM_DEVEL_PACKAGE_NAME}-devel-${SUFFIX}") +set(CPACK_RPM_BIN_FILE_NAME "${CPACK_RPM_BIN_PACKAGE_NAME}-${SUFFIX}") +set(CPACK_RPM_PLUGINS_FILE_NAME "${CPACK_RPM_PLUGINS_PACKAGE_NAME}-${SUFFIX}") +set(CPACK_RPM_TOOLS_FILE_NAME "${CPACK_RPM_TOOLS_PACKAGE_NAME}-${SUFFIX}") +set(CPACK_RPM_DOC_FILE_NAME "${CPACK_RPM_DOC_PACKAGE_NAME}-${SUFFIX}") set(CPACK_RPM_LIB_PACKAGE_REQUIRES "openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib") -set(CPACK_RPM_BIN_PACKAGE_REQUIRES "libvillas") -set(CPACK_RPM_PLUGINS_PACKAGE_REQUIRES "libvillas") -set(CPACK_RPM_TOOLS_PACKAGE_REQUIRES "libvillas") -set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES "libvillas") +set(CPACK_RPM_BIN_PACKAGE_REQUIRES ${CPACK_RPM_LIB_PACKAGE_NAME}) +set(CPACK_RPM_PLUGINS_PACKAGE_REQUIRES ${CPACK_RPM_LIB_PACKAGE_NAME}) +set(CPACK_RPM_TOOLS_PACKAGE_REQUIRES ${CPACK_RPM_LIB_PACKAGE_NAME}) + +set(CPACK_RPM_DEVEL_PACKAGE_SUGGESTS ${CPACK_RPM_LIB_PACKAGE_NAME}) +set(CPACK_RPM_BIN_PACKAGE_SUGGESTS "villas-node-tools villas-node-plugins villas-node-doc") set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) set(CPACK_RPM_PACKAGE_RELEASE ${PROJECT_RELEASE}) @@ -44,14 +61,6 @@ set(CPACK_RPM_PACKAGE_LICENSE "GPLv3") set(CPACK_RPM_PACKAGE_URL "http://www.fein-aachen.org/projects/villas-node/") set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") -set(SUFFIX "${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") -set(CPACK_RPM_FILE_NAME "villas-node-${SUFFIX}") -set(CPACK_RPM_TOOLS_FILE_NAME "villas-node-tools-${SUFFIX}") -set(CPACK_RPM_PLUGINS_FILE_NAME "villas-node-plugins-${SUFFIX}") -set(CPACK_RPM_DOC_FILE_NAME "villas-node-doc-${SUFFIX}") -set(CPACK_RPM_LIB_FILE_NAME "libvillas-${SUFFIX}") -set(CPACK_RPM_DEVEL_FILE_NAME "libvillas-devel-${SUFFIX}") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md") set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") From fc6f63b1927fb97a9a11596c50cee73210a1d6c2 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:25:15 +0200 Subject: [PATCH 37/40] cmake: change sub-libraries to be statically linked --- lib/CMakeLists.txt | 25 ++++-- lib/api/CMakeLists.txt | 17 +--- lib/hooks/CMakeLists.txt | 17 +--- lib/log.c | 1 + lib/nodes/CMakeLists.txt | 22 ++---- lib/nodes/Makefile.inc | 166 --------------------------------------- lib/nodes/socket.c | 1 + 7 files changed, 32 insertions(+), 217 deletions(-) delete mode 100644 lib/nodes/Makefile.inc diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8be8e1f17..72a655bb5 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -20,6 +20,8 @@ # along with this program. If not, see . ################################################################################### +add_compile_options(-fPIC) + set(INCLUDE_DIRS ${JANSSON_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} @@ -67,7 +69,7 @@ set(LIB_SRC ) add_subdirectory(nodes) -list(APPEND LIBRARIES villas-nodes) +list(APPEND WHOLE_ARCHIVES nodes) if(LIBCONFIG_FOUND) list(APPEND INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS}) @@ -81,7 +83,7 @@ if(WITH_IO) ) add_subdirectory(formats) - list(APPEND LIBRARIES villas-formats) + list(APPEND WHOLE_ARCHIVES formats) endif() if(WITH_HOOKS) @@ -91,7 +93,7 @@ if(WITH_HOOKS) ) add_subdirectory(hooks) - list(APPEND LIBRARIES villas-hooks) + list(APPEND WHOLE_ARCHIVES hooks) endif() if(WITH_WEB) @@ -109,7 +111,7 @@ if(WITH_API AND WITH_WEB) ) add_subdirectory(api) - list(APPEND LIBRARIES villas-api) + list(APPEND WHOLE_ARCHIVES api) endif() # libnl3 is optional but required for network emulation and IRQ pinning @@ -130,10 +132,17 @@ add_library(villas SHARED ${LIB_SRC}) target_include_directories(villas PUBLIC ${INCLUDE_DIRS}) target_link_libraries(villas PUBLIC ${LIBRARIES}) -#set_target_properties(villas PROPERTIES -# VERSION ${PROJECT_VERSION} -# SOVERSION ${PROJECT_SOVERSION} -#) +if(APPLE) + target_link_libraries(villas PRIVATE -Wl,-all_load ${WHOLE_ARCHIVES} -Wl,-noall_load) +else() + target_link_libraries(villas PRIVATE -Wl,--whole-archive ${WHOLE_ARCHIVES} -Wl,--no-whole-archive) +endif() + + +set_target_properties(villas PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_SOVERSION} +) install( TARGETS villas diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt index c7f3cbf30..453cd2dca 100644 --- a/lib/api/CMakeLists.txt +++ b/lib/api/CMakeLists.txt @@ -40,17 +40,6 @@ set(API_SRC actions/status.c ) -add_library(villas-api SHARED ${API_SRC}) -target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS}) -target_link_libraries(villas-api PUBLIC ${LIBRARIES}) - -#set_target_properties(villas-api PROPERTIES -# VERSION ${PROJECT_VERSION} -# SOVERSION ${PROJECT_SOVERSION} -#) - -install( - TARGETS villas-api - COMPONENT lib - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +add_library(api STATIC ${API_SRC}) +target_include_directories(api PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(api INTERFACE ${LIBRARIES}) diff --git a/lib/hooks/CMakeLists.txt b/lib/hooks/CMakeLists.txt index e0f1a37da..137381e61 100644 --- a/lib/hooks/CMakeLists.txt +++ b/lib/hooks/CMakeLists.txt @@ -50,17 +50,6 @@ if(WITH_IO) ) endif() -add_library(villas-hooks SHARED ${HOOK_SRC}) -target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS}) -target_link_libraries(villas-hooks PUBLIC ${LIBRARIES}) - -#set_target_properties(villas-hooks PROPERTIES -# VERSION ${PROJECT_VERSION} -# SOVERSION ${PROJECT_SOVERSION} -#) - -install( - TARGETS villas-hooks - COMPONENT lib - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +add_library(hooks STATIC ${HOOK_SRC}) +target_include_directories(hooks PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(hooks INTERFACE ${LIBRARIES}) diff --git a/lib/log.c b/lib/log.c index c2c328df6..8bb6e058f 100644 --- a/lib/log.c +++ b/lib/log.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index 6f39e1f03..d4e07cb71 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -57,7 +57,10 @@ endif() # Enable shared memory node-type if(HAS_SEMAPHORE AND HAS_MMAN) list(APPEND NODE_SRC shmem.c) - list(APPEND LIBRARIES "rt") + + if(CMAKE_SUSTEM_NAME STREQUAL Linux) + list(APPEND LIBRARIES rt) + endif() endif() # Enable IEC61850 node-types when libiec61850 is available @@ -123,17 +126,6 @@ if(COMEDILIB_FOUND) list(APPEND LIBRARIES PkgConfig::COMEDILIB) endif() -add_library(villas-nodes SHARED ${NODE_SRC}) -target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS}) -target_link_libraries(villas-nodes PUBLIC ${LIBRARIES}) - -#set_target_properties(villas-nodes PROPERTIES -# VERSION ${PROJECT_VERSION} -# SOVERSION ${PROJECT_SOVERSION} -#) - -install( - TARGETS villas-nodes - COMPONENT lib - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +add_library(nodes STATIC ${NODE_SRC}) +target_include_directories(nodes PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(nodes LINK_PRIVATE ${LIBRARIES}) diff --git a/lib/nodes/Makefile.inc b/lib/nodes/Makefile.inc deleted file mode 100644 index 180a98669..000000000 --- a/lib/nodes/Makefile.inc +++ /dev/null @@ -1,166 +0,0 @@ -# Makefile. -# -# @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC -# @license GNU General Public License (version 3) -# -# VILLASnode -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -################################################################################### - -# Enabled loopback node-type -ifeq ($(WITH_NODE_LOOPBACK),1) - LIB_NODES += loopback -endif - -# Enabled Cbuilder node-type -ifeq ($(WITH_NODE_CBUILDER),1) - LIB_NODES += cbuilder -endif - -# Enable InfluxDB node-type -ifeq ($(WITH_NODE_INFLUXDB),1) - LIB_NODES += influxdb -endif - -# Enable stats node-type -ifeq ($(WITH_NODE_STATS),1) - LIB_NODES += stats -endif - -# Enable file node-type -ifeq ($(WITH_NODE_FILE),1) - LIB_NODES += file - WITH_IO = 1 -endif - -# Enable shared memory node-type -ifeq ($(WITH_NODE_SHMEM),1) - LIB_NODES += shmem -endif - -# Enable signal generator node-type -ifeq ($(WITH_NODE_SIGNAL),1) - LIB_NODES += signal_generator -endif - -# Enable RTT test node-tyoe -ifeq ($(WITH_NODE_TEST_RTT),1) - LIB_NODES += test_rtt - WITH_IO = 1 -endif - -# Enable IEC61850 node-types when libiec61850 is available -ifeq ($(WITH_NODE_IEC61850),1) -ifeq ($(shell $(PKGCONFIG) --atleast-version=1.2.0 libiec61850; echo $$?),0) - LIB_SRCS += lib/nodes/iec61850_sv.c - LIB_NODES += iec61850 - LIB_PKGS += libiec61850 -endif -endif - -# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) -ifeq ($(WITH_NODE_OPAL),1) -ifneq ($(wildcard $(SRCDIR)/thirdparty/libopal/include/opal/AsyncApi.h),) - LIB_CFLAGS += -I $(SRCDIR)/thirdparty/libopal/include/opal/ - LIB_LDFLAGS += -L/lib/i386-linux-gnu/ -L/usr/lib/i386-linux-gnu/ -L$(SRCDIR)/thirdparty/libopal/ - LIB_LDLIBS += -lOpalAsyncApiCore -lOpalCore -lOpalUtils -lirc - LIB_NODES += opal - - # libOpalAsyncApi is a 32bit library. So we need to build everything in 32bit - CFLAGS += -m32 - LDFLAGS += -m32 -endif -endif - -# Enable Socket node type when libnl3 is available -ifeq ($(WITH_NODE_SOCKET),1) - LIB_NODES += socket - WITH_IO = 1 - - # libnl3 is optional but required for network emulation and IRQ pinning - ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0) - LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c tc_netem.c if.c) - LIB_PKGS += libnl-route-3.0 - endif -endif - -# Enable nanomsg node type when libnanomsg is available -ifeq ($(WITH_NODE_NANOMSG),1) -ifeq ($(shell $(PKGCONFIG) nanomsg; echo $$?),0) - LIB_PKGS += nanomsg - LIB_NODES += nanomsg - WITH_IO = 1 -else ifeq ($(shell $(PKGCONFIG) libnanomsg; echo $$?),0) - LIB_PKGS += libnanomsg - LIB_NODES += nanomsg - WITH_IO = 1 -endif -endif - -# Enable ZeroMQ node type when libzmq is available -ifeq ($(WITH_NODE_ZEROMQ),1) -ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0) - LIB_PKGS += libzmq - LIB_NODES += zeromq - WITH_IO = 1 -endif -endif - -# Enable NGSI support -ifeq ($(WITH_NODE_NGSI),1) -ifeq ($(shell $(PKGCONFIG) libcurl; echo $$?),0) - LIB_PKGS += libcurl - LIB_NODES += ngsi -endif -endif - -# Enable WebSocket support -ifeq ($(WITH_NODE_WEBSOCKET),1) -ifeq ($(shell $(PKGCONFIG) libwebsockets; echo $$?),0) - LIB_PKGS += libwebsockets - LIB_NODES += websocket - WITH_IO = 1 - WITH_WEB = 1 -endif -endif - -# Enable AMQP support -ifeq ($(WITH_NODE_AMQP),1) -ifeq ($(shell $(PKGCONFIG) librabbitmq; echo $$?),0) - LIB_PKGS += librabbitmq - LIB_NODES += amqp - WITH_IO = 1 -endif -endif - -# Enable MQTT support -ifeq ($(WITH_NODE_MQTT),1) -ifneq ($(wildcard /usr/include/mosquitto.h),) - LIB_SRCS += lib/nodes/mqtt.c - LIB_NODES += mqtt - LIB_LDLIBS += -lmosquitto - WITH_IO = 1 -endif -endif - -# Enable Comedi support -ifeq ($(WITH_NODE_COMEDI),1) -ifeq ($(shell $(PKGCONFIG) comedilib; echo $$?),0) - LIB_PKGS += comedilib - LIB_SRCS += lib/nodes/comedi.c - LIB_NODES += comedi -endif -endif diff --git a/lib/nodes/socket.c b/lib/nodes/socket.c index c4c4b4f02..61c7fa2a1 100644 --- a/lib/nodes/socket.c +++ b/lib/nodes/socket.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include From b10235ffabfac126b590fb17c6d132258f2fd791 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:25:27 +0200 Subject: [PATCH 38/40] cmake: fix docker builds --- packaging/docker/CMakeLists.txt | 16 +++++--- packaging/docker/Dockerfile.app | 52 +++++++++----------------- packaging/docker/Dockerfile.dev | 12 +++--- packaging/docker/Dockerfile.dev-centos | 8 ++-- packaging/docker/Dockerfile.dev-ubuntu | 8 ++-- 5 files changed, 43 insertions(+), 53 deletions(-) diff --git a/packaging/docker/CMakeLists.txt b/packaging/docker/CMakeLists.txt index 15d14e529..8ac13b4ff 100644 --- a/packaging/docker/CMakeLists.txt +++ b/packaging/docker/CMakeLists.txt @@ -40,12 +40,10 @@ foreach(SUFFIX app dev dev-centos dev-ubuntu) add_custom_target(deploy-docker-${SUFFIX} COMMAND docker push ${DOCKER_IMAGE}-${SUFFIX}:${DOCKER_TAG} COMMAND docker push ${DOCKER_IMAGE}-${SUFFIX}:latest - DEPENDS docker-${SUFFIX} ) add_custom_target(run-docker-${SUFFIX} COMMAND docker run ${DOCKER_RUN_OPTS} ${DOCKER_IMAGE}-${SUFFIX}:${DOCKER_TAG} - DEPENDS docker-${SUFFIX} ) add_custom_target(docker-${SUFFIX} @@ -61,13 +59,19 @@ foreach(SUFFIX app dev dev-centos dev-ubuntu) --build-arg VARIANT=${VARIANT} ${DOCKER_BUILD_OPTS} ${CMAKE_SOURCE_DIR} ) + + add_dependencies(deploy-docker-${SUFFIX} docker-${SUFFIX}) + add_dependencies(run-docker-${SUFFIX} docker-${SUFFIX}) endforeach() # Special cases for 'docker'target -add_custom_target(docker DEPENDS docker-app +add_custom_target(run-docker + COMMAND docker run ${DOCKER_RUN_OPTS} ${DOCKER_IMAGE}:${DOCKER_TAG} node -h +) + +add_custom_target(docker COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:${DOCKER_TAG} COMMAND docker tag ${DOCKER_IMAGE}-app:${DOCKER_TAG} ${DOCKER_IMAGE}:latest - DEPENDS docker-dev ) add_custom_target(deploy-docker DEPENDS docker-app @@ -75,4 +79,6 @@ add_custom_target(deploy-docker DEPENDS docker-app COMMAND docker push ${DOCKER_IMAGE}:latest ) -add_custom_target(run-docker DEPENDS run-docker-app) +add_dependencies(docker docker-app) +add_dependencies(deploy-docker deploy-docker-app) +add_dependencies(run-docker docker) diff --git a/packaging/docker/Dockerfile.app b/packaging/docker/Dockerfile.app index 950c3a7cb..8128abb9c 100644 --- a/packaging/docker/Dockerfile.app +++ b/packaging/docker/Dockerfile.app @@ -1,11 +1,11 @@ -# Dockerfile for VILLASnode dependencies. +# Dockerfile # -# This Dockerfile builds an image which contains all library dependencies -# and tools to build VILLASnode. -# However, VILLASnode itself it not part of the image. +# This image can be used for running VILLASnode +# by running: +# make docker # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -25,45 +25,29 @@ ################################################################################### ARG BUILDER_IMAGE=villas/node-dev +ARG DOCKER_TAG=latest +ARG GIT_REV=unknown +ARG GIT_BRANCH=unknown +ARG VERSION=unknown +ARG VARIANT=unknown # This image is built by villas-node-git/packaging/docker/Dockerfile.dev -FROM villas/node-dev:develop AS builder +FROM $BUILDER_IMAGE AS builder -COPY . /villas-node/ +COPY . /villas/ -RUN rm -rf /villas-node/build -WORKDIR /villas-node - -#RUN dnf -y install - -RUN make -j2 rpm-villas-node +RUN rm -rf /villas/build && mkdir /villas/build +WORKDIR /villas/build +RUN cmake -DCPACK_GENERATOR=RPM .. +RUN make -j$(nproc) doc +RUN make -j$(nproc) package FROM fedora:28 - -ARG GIT_REV=unkown -ARG GIT_BRANCH=unkown -ARG VERSION=unkown -ARG VARIANT=unkown # Some of the dependencies are only available in our own repo ADD https://packages.fein-aachen.org/redhat/fein.repo /etc/yum.repos.d/ -# Usually the following dependecies would be resolved by dnf -# when installing villas-node. -# We add them here to utilise Dockers caching and layer feature -# in order reduce bandwidth and space usage. -RUN dnf -y install \ - openssl \ - libconfig \ - libnl3 \ - libcurl \ - jansson \ - iproute \ - module-init-tools - -ADD https://villas.fein-aachen.org/packages/villas.repo /etc/yum.repos.d/ - -COPY --from=builder /villas-node/build/Linux-x86_64-release/packaging/rpm/RPMS/x86_64/*.rpm /tmp/ +COPY --from=builder /villas/build/*.rpm /tmp/ RUN dnf -y install /tmp/*.rpm # For WebSocket / API access diff --git a/packaging/docker/Dockerfile.dev b/packaging/docker/Dockerfile.dev index 54af8157a..33045f21d 100644 --- a/packaging/docker/Dockerfile.dev +++ b/packaging/docker/Dockerfile.dev @@ -6,10 +6,10 @@ # # This image can be used for developing VILLASnode # by running: -# make docker +# make docker-dev # # @author Steffen Vogel -# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC # @license GNU General Public License (version 3) # # VILLASnode @@ -30,10 +30,10 @@ FROM fedora:28 -ARG GIT_REV=unkown -ARG GIT_BRANCH=unkown -ARG VERSION=unkown -ARG VARIANT=unkown +ARG GIT_REV=unknown +ARG GIT_BRANCH=unknown +ARG VERSION=unknown +ARG VARIANT=unknown # Toolchain RUN dnf -y install \ diff --git a/packaging/docker/Dockerfile.dev-centos b/packaging/docker/Dockerfile.dev-centos index 575ba79c6..505aa27bf 100644 --- a/packaging/docker/Dockerfile.dev-centos +++ b/packaging/docker/Dockerfile.dev-centos @@ -30,10 +30,10 @@ FROM centos:7 -ARG GIT_REV=unkown -ARG GIT_BRANCH=unkown -ARG VERSION=unkown -ARG VARIANT=unkown +ARG GIT_REV=unknown +ARG GIT_BRANCH=unknown +ARG VERSION=unknown +ARG VARIANT=unknown # Some of the dependencies are only available in our own repo ADD https://villas.fein-aachen.org/packages/villas.repo /etc/yum.repos.d/ diff --git a/packaging/docker/Dockerfile.dev-ubuntu b/packaging/docker/Dockerfile.dev-ubuntu index 32685b9d4..9541bf283 100644 --- a/packaging/docker/Dockerfile.dev-ubuntu +++ b/packaging/docker/Dockerfile.dev-ubuntu @@ -32,10 +32,10 @@ FROM ubuntu:xenial #FROM debian:jessie -ARG GIT_REV=unkown -ARG GIT_BRANCH=unkown -ARG VERSION=unkown -ARG VARIANT=unkown +ARG GIT_REV=unknown +ARG GIT_BRANCH=unknown +ARG VERSION=unknown +ARG VARIANT=unknown # Toolchain RUN apt-get update && apt-get install -y \ From 4f7b1ba7adb47f87774cff7b244dc05891254928 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:25:47 +0200 Subject: [PATCH 39/40] cmake: improve handling of compiler flags --- CMakeLists.txt | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f10fb3b8e..64b01ad13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,13 +22,16 @@ cmake_minimum_required(VERSION 3.3) +# Policies +cmake_policy(SET CMP0068 NEW) + project(VILLASnode C CXX) # Several CMake settings/defaults set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) set(CMAKE_THREAD_PREFER_PTHREAD ON) -set(CMAKE_SKIP_INSTALL_RPATH ON) +#set(CMAKE_SKIP_INSTALL_RPATH ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") if(APPLE) @@ -38,43 +41,25 @@ endif() include(FindPkgConfig) include(CheckIncludeFile) include(FeatureSummary) -include(CheckCCompilerFlag) -include(CheckCXXCompilerFlag) include(GNUInstallDirs) # Compiler flags if(BUILD32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") - set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32") + add_compile_options(-m32) + link_libraries(-m32) endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1") +if(APPLE) + add_definitions(-D_DARWIN_C_SOURCE) +endif() + +add_definitions(-D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE) +add_compile_options(-fdiagnostics-color=auto) if(MSVC) - check_c_compiler_flag("/W4 /WX" C_SUPPORTS_WERROR) - check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR) - - if(C_SUPPORTS_WERROR) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX") - endif() - - if(CXX_SUPPORTS_WERROR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX") - endif() + add_compile_options(/W4 /WX) else() - check_c_compiler_flag("-Wall -Werror" C_SUPPORTS_WERROR) - check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR) - - if(C_SUPPORTS_WERROR) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") - endif() - - if(CXX_SUPPORTS_WERROR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") - endif() + add_compile_options(-Wall -Werror) endif() # Check OS From b26f631eb344f7dacb7cb61bac0ac8ccf97705e1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 3 Jul 2018 18:27:44 +0200 Subject: [PATCH 40/40] cmake: install src executables --- src/CMakeLists.txt | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c0fe85dc..538b55703 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,7 +27,11 @@ add_executable(villas-node villas-node.c) add_executable(villas-test-rtt villas-test-rtt.c) add_executable(villas-test-shmem villas-test-shmem.c) -set(SRCS ) +install( + TARGETS villas-node villas-test-rtt villas-test-shmem + COMPONENT bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) if(WITH_IO) add_executable(villas-test-cmp villas-test-cmp.c) @@ -36,14 +40,21 @@ if(WITH_IO) add_executable(villas-signal villas-signal.c) target_link_libraries(villas-pipe PUBLIC Threads::Threads) + + install( + TARGETS villas-convert villas-pipe villas-signal villas-test-cmp + COMPONENT bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) endif() if(WITH_IO AND WITH_HOOKS) add_executable(villas-hook villas-hook.c) + + install( + TARGETS villas-hook + COMPONENT bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) endif() -install( - TARGETS ${BUILDSYSTEM_TARGETS} - COMPONENT bin - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -)