diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bc01987f..652c30151 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,27 @@ option(WITH_PLUGINS "Build plugins" ${TOPLEVEL_PROJECT}) option(WITH_CLIENTS "Build client applications" ${TOPLEVEL_PROJECT}) option(WITH_DOC "Build documentation" ${TOPLEVEL_PROJECT}) +option(WITH_NODE_AMQP "Build with amqp node-type" ${RABBITMQ_C_FOUND}) +option(WITH_NODE_COMEDI "Build with comedi node-type" ${COMEDILIB_FOUND}) +option(WITH_NODE_FILE "Build with file node-type" ON) +option(WITH_NODE_IEC61850 "Build with iec61850 node-types" ${LIBIEC61850_FOUND}) +option(WITH_NODE_INFINIBAND "Build with infiniband node-type" ${IBVerbs_FOUND}) +option(WITH_NODE_INFLUXDB "Build with influxdb node-type" ON) +option(WITH_NODE_LOOPBACK "Build with loopback node-type" ON) +option(WITH_NODE_MQTT "Build with mqtt node-type" ${Mosquitto_FOUND}) +option(WITH_NODE_NANOMSG "Build with nanomsg node-type" ${NANOMSG_FOUND}) +option(WITH_NODE_NGSI "Build with ngsi node-type" ${CURL_FOUND}) +option(WITH_NODE_OPAL "Build with opal node-type" ${Opal_FOUND}) +option(WITH_NODE_RTP "Build with rtp node-type" ${RE_FOUND}) +option(WITH_NODE_SHMEM "Build with shmem node-type" ON) +option(WITH_NODE_SIGNAL_GENERATOR "Build with signal node-type" ON) +option(WITH_NODE_SOCKET "Build with socket node-type" ${LIBNL3_ROUTE_FOUND}) +option(WITH_NODE_STATS "Build with stats node-type" ON) +option(WITH_NODE_TEST_RTT "Build with test_rtt node-type" ON) +option(WITH_NODE_ULDAQ "Build with uldaq node-type" ${ULDAQ_FOUND}) +option(WITH_NODE_WEBSOCKET "Build with websocket node-type" ${LIBWEBSOCKETS_LDFLAGS}) +option(WITH_NODE_ZEROMQ "Build with zeromq node-type" ${LIBZMQ_FOUND}) + # Add more build configurations include(cmake/config/Debug.cmake) include(cmake/config/Release.cmake) diff --git a/include/villas/node/config.h.in b/include/villas/node/config.h.in index c66c0a3fc..9059ee554 100644 --- a/include/villas/node/config.h.in +++ b/include/villas/node/config.h.in @@ -58,8 +58,6 @@ #cmakedefine HAS_SEMAPHORE /* Available Libraries */ -#cmakedefine LIBWEBSOCKETS_FOUND -#cmakedefine HDF5_FOUND #cmakedefine PROTOBUF_FOUND #cmakedefine LIBNL3_ROUTE_FOUND #cmakedefine IBVERBS_FOUND diff --git a/include/villas/super_node.h b/include/villas/super_node.h index e7ab761e1..41fc05a35 100644 --- a/include/villas/super_node.h +++ b/include/villas/super_node.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #ifdef __cplusplus extern "C" { diff --git a/include/villas/web.hpp b/include/villas/web.hpp index 212fc222d..3b16587f0 100644 --- a/include/villas/web.hpp +++ b/include/villas/web.hpp @@ -69,7 +69,7 @@ public: * * The web interface is based on the libwebsockets library. */ - Web(Api *a); + Web(Api *a = nullptr); void start(); void stop(); diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index b9b269ceb..e2e514e8d 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -20,35 +20,50 @@ # along with this program. If not, see . ################################################################################### -set(NODE_SRC - influxdb.c - stats.c - signal_generator.c - loopback.c -) +set(NODE_SRC) 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 - ) +if(WITH_NODE_INFLUXDB) + list(APPEND NODE_SRC influxdb.c) +endif() + +if(WITH_NODE_STATS) + list(APPEND NODE_SRC stats.c) +endif() + +if(WITH_NODE_SIGNAL_GENERATOR) + list(APPEND NODE_SRC signal_generator.c) +endif() + +if(WITH_NODE_LOOPBACK) + list(APPEND NODE_SRC loopback.c) +endif() + +if(WITH_NODE_TEST_RTT) + list(APPEND NODE_SRC test_rtt.c) +endif() + +if(WITH_NODE_SOCKET) + list(APPEND NODE_SRC socket.c) +endif() + +if(WITH_NODE_FILE) + list(APPEND NODE_SRC file.c) endif() # Enable Universal Library for Linux DAQ devices (libuldaq) -if(LIBULDAQ_FOUND) +if(WITH_NODE_ULDAQ) list(APPEND NODE_SRC uldaq.c) list(APPEND INCLUDE_DIRS ${LIBULDAQ_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::LIBULDAQ uldaq) endif() # Enable shared memory node-type -if(HAS_SEMAPHORE AND HAS_MMAN) +if(WITH_NODE_SHMEM AND HAS_SEMAPHORE AND HAS_MMAN) list(APPEND NODE_SRC shmem.c) if(CMAKE_SUSTEM_NAME STREQUAL Linux) @@ -57,75 +72,77 @@ if(HAS_SEMAPHORE AND HAS_MMAN) endif() # Enable IEC61850 node-types when libiec61850 is available -if(LIBIEC61850_FOUND) +if(WITH_NODE_IEC61850) list(APPEND NODE_SRC iec61850_sv.c iec61850.c) list(APPEND INCLUDE_DIRS ${LIBIEC61850_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::LIBIEC61850 ${LIBIEC61850_LIBRARIES}) endif() # Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) -if(OPAL_FOUND AND BUILD32) +if(WITH_NODE_OPAL 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) +if(WITH_NODE_NANOMSG) 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) +if(WITH_NODE_ZEROMQ) list(APPEND NODE_SRC zeromq.c) list(APPEND INCLUDE_DIRS ${LIBZMQ_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::LIBZMQ) endif() # Enable NGSI support -list(APPEND NODE_SRC ngsi.c) -list(APPEND INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) -list(APPEND LIBRARIES ${CURL_LIBRARIES}) +if(WITH_NGSI) + 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) +if(WITH_NODE_WEBSOCKET AND WITH_WEB) list(APPEND NODE_SRC websocket.c) list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS}) list(APPEND LIBRARIES ${LIBWEBSOCKETS_LDLIBS}) endif() # Enable AMQP support -if(RABBITMQ_C_FOUND AND WITH_IO) +if(WITH_NODE_AMQP) 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) +if(WITH_NODE_MQTT) 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) +if(WITH_NODE_COMEDI) list(APPEND NODE_SRC comedi.c) list(APPEND INCLUDE_DIRS ${COMEDILIB_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::COMEDILIB) endif() -# Enable infiniband support -if(IBVERBS_FOUND AND RDMACM_FOUND) +# Enable Infiniband support +if(WITH_NODE_INFINIBAND) list(APPEND NODE_SRC infiniband.c) list(APPEND INCLUDE_DIRS ${IBVERBS_INCLUDE_DIRS} ${RDMACM_INCLUDE_DIRS}) list(APPEND LIBRARIES ${IBVERBS_LIBRARIES} ${RDMACM_LIBRARIES}) endif() # Enable RTP node type when libre is available -if(RE_FOUND AND WITH_IO) +if(WITH_NODE_RE) list(APPEND NODE_SRC rtp.cpp) list(APPEND INCLUDE_DIRS ${RE_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::RE) diff --git a/lib/super_node.cpp b/lib/super_node.cpp index 0790f166c..0dee3e80e 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -52,7 +52,11 @@ SuperNode::SuperNode() : api(this), #endif #ifdef WITH_WEB + #ifdef WITH_API web(&api), + #else + web(), + #endif #endif priority(0), affinity(0), diff --git a/lib/web.cpp b/lib/web.cpp index 036670d8e..a799906c6 100644 --- a/lib/web.cpp +++ b/lib/web.cpp @@ -61,14 +61,12 @@ lws_protocols protocols[] = { .rx_buffer_size = 0 }, #endif /* WITH_API */ -#ifdef LIBWEBSOCKETS_FOUND { .name = "live", .callback = websocket_protocol_cb, .per_session_data_size = sizeof(websocket_connection), .rx_buffer_size = 0 }, -#endif /* LIBWEBSOCKETS_FOUND */ { .name = nullptr /* terminator */ } diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index bb69146ad..0d8ebfa0e 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -374,7 +374,7 @@ check: if (optarg == endptr) if (!node) throw RuntimeError("Node {} does not exist!", nodestr); -#if defined(LIBWEBSOCKETS_FOUND) && defined(WITH_WEB) +#ifdef WITH_NODE_WEBSOCKET /* Only start web subsystem if villas-pipe is used with a websocket node */ if (node_type(node)->start == websocket_start) { Web *w = sn.getWeb(); @@ -383,7 +383,7 @@ check: if (optarg == endptr) w->start(); a->start(); } -#endif /* defined(LIBWEBSOCKETS_FOUND) && defined(WITH_WEB) */ +#endif /* WITH_NODE_WEBSOCKET */ if (reverse) node_reverse(node);