-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'kropatschek/develop' into develop
- Loading branch information
Showing
27 changed files
with
1,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# vi | ||
*.swp | ||
|
||
# MacOS Finder | ||
.DS_Store | ||
._* | ||
|
||
# build | ||
build | ||
|
||
# IDE | ||
*idea | ||
|
||
*.so | ||
*.so.1 | ||
CMakeCache.txt | ||
CMakeFiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
cmake_minimum_required(VERSION 2.4.0) | ||
|
||
# Set the plugin name to build | ||
project(Delta) | ||
|
||
# Supported options: | ||
# -DFLEDGE_INCLUDE | ||
# -DFLEDGE_LIB | ||
# -DFLEDGE_SRC | ||
# -DFLEDGE_INSTALL | ||
# | ||
# If no -D options are given and FLEDGE_ROOT environment variable is set | ||
# then Fledge libraries and header files are pulled from FLEDGE_ROOT path. | ||
# The NOTIFICATION_SERVICE_INCLUDE_DIRS environment variable must point | ||
# to Fledge Notification server include files, example | ||
# export NOTIFICATION_SERVICE_INCLUDE_DIRS=/home/ubuntu/source/fledge-service-notification/C/services/common/include | ||
|
||
set(CMAKE_CXX_FLAGS "-std=c++11 -O3") | ||
|
||
# Set plugin type (south, north, filter, notificationDelivery, notificationRule) | ||
set(PLUGIN_TYPE "notificationRule") | ||
|
||
set_source_files_properties(version.h PROPERTIES GENERATED TRUE) | ||
add_custom_command( | ||
OUTPUT version.h | ||
DEPENDS ${CMAKE_SOURCE_DIR}/VERSION | ||
COMMAND ${CMAKE_SOURCE_DIR}/mkversion ${CMAKE_SOURCE_DIR} | ||
COMMENT "Generating version header" | ||
VERBATIM | ||
) | ||
include_directories(${CMAKE_BINARY_DIR}) | ||
|
||
# Add here all needed Fledge libraries as list | ||
set(NEEDED_FLEDGE_LIBS common-lib plugins-common-lib) | ||
|
||
# Find source files | ||
file(GLOB SOURCES *.cpp) | ||
|
||
# Find Fledge includes and libs, by including FindFledge.cmak file | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) | ||
find_package(Fledge) | ||
# If errors: make clean and remove Makefile | ||
if (NOT FLEDGE_FOUND) | ||
if (EXISTS "${CMAKE_BINARY_DIR}/Makefile") | ||
execute_process(COMMAND make clean WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
file(REMOVE "${CMAKE_BINARY_DIR}/Makefile") | ||
endif() | ||
# Stop the build process | ||
message(FATAL_ERROR "Fledge plugin '${PROJECT_NAME}' build error.") | ||
endif() | ||
# On success, FLEDGE_INCLUDE_DIRS and FLEDGE_LIB_DIRS variables are set | ||
|
||
# Add ./include | ||
include_directories(include) | ||
|
||
# Add Fledge include dir(s) | ||
include_directories(${FLEDGE_INCLUDE_DIRS}) | ||
|
||
# Add Notification server includes from NOTIFICATION_SERVICE_INCLUDE_DIRS env variable | ||
if (NOT DEFINED ENV{NOTIFICATION_SERVICE_INCLUDE_DIRS}) | ||
# Stop the build process | ||
message(FATAL_ERROR "Fledge plugin '${PROJECT_NAME}' build error. " | ||
"Notification server includes dir not set. Use NOTIFICATION_SERVICE_INCLUDE_DIRS env variable") | ||
else() | ||
message(STATUS "Notification server includes dir set to $ENV{NOTIFICATION_SERVICE_INCLUDE_DIRS}") | ||
endif() | ||
|
||
include_directories($ENV{NOTIFICATION_SERVICE_INCLUDE_DIRS}) | ||
|
||
# Add other include paths this plugin needs | ||
if (FLEDGE_SRC) | ||
message(STATUS "Using third-party includes " ${FLEDGE_SRC}/C/thirdparty/Simple-Web-Server) | ||
include_directories(${FLEDGE_SRC}/C/thirdparty/Simple-Web-Server) | ||
else() | ||
include_directories(${FLEDGE_INCLUDE_DIRS}/Simple-Web-Server) | ||
endif() | ||
|
||
# Add Fledge lib path | ||
link_directories(${FLEDGE_LIB_DIRS}) | ||
|
||
# Create shared library | ||
add_library(${PROJECT_NAME} SHARED ${SOURCES} version.h) | ||
|
||
# Add Fledge library names | ||
target_link_libraries(${PROJECT_NAME} ${NEEDED_FLEDGE_LIBS}) | ||
# Add additional libraries | ||
|
||
# Set the build version | ||
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1) | ||
|
||
set(FLEDGE_INSTALL "" CACHE INTERNAL "") | ||
# Install library | ||
if (FLEDGE_INSTALL) | ||
message(STATUS "Installing ${PROJECT_NAME} in ${FLEDGE_INSTALL}/plugins/${PLUGIN_TYPE}/${PROJECT_NAME}") | ||
install(TARGETS ${PROJECT_NAME} DESTINATION ${FLEDGE_INSTALL}/plugins/${PLUGIN_TYPE}/${PROJECT_NAME}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributing to Fledge | ||
|
||
The Fledge project welcomes contributions of any kind, please see [CONTRIBUTING.md](https://github.com/fledge-iot/fledge/blob/develop/CONTRIBUTING.md) in the main Fledge repository for details and guidance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Delta notification rule plugin package for Fledge. Sends notifications when values differ from the delta by more than a prescribed percentage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# This CMake file locates the Fledge header files and libraries | ||
# | ||
# The following variables are set: | ||
# FLEDGE_INCLUDE_DIRS - Path(s) to Fledge headers files found | ||
# FLEDGE_LIB_DIRS - Path to Fledge shared libraries | ||
# FLEDGE_SUCCESS - Set on succes | ||
# | ||
# In case of error use SEND_ERROR and return() | ||
# | ||
|
||
# Set defaults paths of installed Fledge SDK package | ||
set(FLEDGE_DEFAULT_INCLUDE_DIR "/usr/include/fledge" CACHE INTERNAL "") | ||
set(FLEDGE_DEFAULT_LIB_DIR "/usr/lib/fledge" CACHE INTERNAL "") | ||
|
||
# CMakeLists.txt options | ||
set(FLEDGE_SRC "" CACHE INTERNAL "") | ||
set(FLEDGE_INCLUDE "" CACHE INTERNAL "") | ||
set(FLEDGE_LIB "" CACHE INTERNAL "") | ||
|
||
# Return variables | ||
set(FLEDGE_INCLUDE_DIRS "" CACHE INTERNAL "") | ||
set(FLEDGE_LIB_DIRS "" CACHE INTERNAL "") | ||
set(FLEDGE_FOUND "" CACHE INTERNAL "") | ||
|
||
# No options set | ||
# If FLEDGE_ROOT env var is set, use it | ||
if (NOT FLEDGE_SRC AND NOT FLEDGE_INCLUDE AND NOT FLEDGE_LIB) | ||
if (DEFINED ENV{FLEDGE_ROOT}) | ||
message(STATUS "No options set.\n" | ||
" +Using found FLEDGE_ROOT $ENV{FLEDGE_ROOT}") | ||
set(FLEDGE_SRC $ENV{FLEDGE_ROOT}) | ||
endif() | ||
endif() | ||
|
||
# -DFLEDGE_SRC=/some_path or FLEDGE_ROOT path | ||
# Set return variable FLEDGE_INCLUDE_DIRS | ||
if (FLEDGE_SRC) | ||
unset(_INCLUDE_LIST CACHE) | ||
file(GLOB_RECURSE _INCLUDE_COMMON "${FLEDGE_SRC}/C/common/*.h") | ||
file(GLOB_RECURSE _INCLUDE_SERVICES "${FLEDGE_SRC}/C/services/common/*.h") | ||
file(GLOB_RECURSE _INCLUDE_PLUGINS_FILTER_COMMON "${FLEDGE_SRC}/C/plugins/filter/common/*.h") | ||
list(APPEND _INCLUDE_LIST ${_INCLUDE_COMMON} ${_INCLUDE_SERVICES} ${_INCLUDE_PLUGINS_FILTER_COMMON}) | ||
foreach(_ITEM ${_INCLUDE_LIST}) | ||
get_filename_component(_ITEM_PATH ${_ITEM} DIRECTORY) | ||
list(APPEND FLEDGE_INCLUDE_DIRS ${_ITEM_PATH}) | ||
endforeach() | ||
# Add rapidjson header files | ||
list(APPEND FLEDGE_INCLUDE_DIRS "${FLEDGE_SRC}/C/thirdparty/rapidjson/include") | ||
unset(INCLUDE_LIST CACHE) | ||
|
||
list(REMOVE_DUPLICATES FLEDGE_INCLUDE_DIRS) | ||
|
||
string (REPLACE ";" "\n +" DISPLAY_PATHS "${FLEDGE_INCLUDE_DIRS}") | ||
if (NOT DEFINED ENV{FLEDGE_ROOT}) | ||
message(STATUS "Using -DFLEDGE_SRC option for includes\n +" "${DISPLAY_PATHS}") | ||
else() | ||
message(STATUS "Using FLEDGE_ROOT for includes\n +" "${DISPLAY_PATHS}") | ||
endif() | ||
|
||
if (NOT FLEDGE_INCLUDE_DIRS) | ||
message(SEND_ERROR "Needed Fledge header files not found in path ${FLEDGE_SRC}/C") | ||
return() | ||
endif() | ||
else() | ||
# -DFLEDGE_INCLUDE=/some_path | ||
if (NOT FLEDGE_INCLUDE) | ||
set(FLEDGE_INCLUDE ${FLEDGE_DEFAULT_INCLUDE_DIR}) | ||
message(STATUS "Using Fledge dev package includes " ${FLEDGE_INCLUDE}) | ||
else() | ||
message(STATUS "Using -DFLEDGE_INCLUDE option " ${FLEDGE_INCLUDE}) | ||
endif() | ||
# Remove current value from cache | ||
unset(_FIND_INCLUDES CACHE) | ||
# Get up to date var from find_path | ||
find_path(_FIND_INCLUDES NAMES plugin_api.h PATHS ${FLEDGE_INCLUDE}) | ||
if (_FIND_INCLUDES) | ||
list(APPEND FLEDGE_INCLUDE_DIRS ${_FIND_INCLUDES}) | ||
endif() | ||
# Remove current value from cache | ||
unset(_FIND_INCLUDES CACHE) | ||
|
||
if (NOT FLEDGE_INCLUDE_DIRS) | ||
message(SEND_ERROR "Needed Fledge header files not found in path ${FLEDGE_INCLUDE}") | ||
return() | ||
endif() | ||
endif() | ||
|
||
# | ||
# Fledge Libraries | ||
# | ||
# Check -DFLEDGE_LIB=/some path is valid | ||
# or use FLEDGE_SRC/cmake_build/C/lib | ||
# FLEDGE_SRC might have been set to FLEDGE_ROOT above | ||
# | ||
if (FLEDGE_SRC) | ||
# Set return variable FLEDGE_LIB_DIRS | ||
set(FLEDGE_LIB "${FLEDGE_SRC}/cmake_build/C/lib") | ||
|
||
if (NOT DEFINED ENV{FLEDGE_ROOT}) | ||
message(STATUS "Using -DFLEDGE_SRC option for libs \n +" "${FLEDGE_SRC}/cmake_build/C/lib") | ||
else() | ||
message(STATUS "Using FLEDGE_ROOT for libs \n +" "${FLEDGE_SRC}/cmake_build/C/lib") | ||
endif() | ||
|
||
if (NOT EXISTS "${FLEDGE_SRC}/cmake_build") | ||
message(SEND_ERROR "Fledge has not been built yet in ${FLEDGE_SRC} Compile it first.") | ||
return() | ||
endif() | ||
|
||
# Set return variable FLEDGE_LIB_DIRS | ||
set(FLEDGE_LIB_DIRS "${FLEDGE_SRC}/cmake_build/C/lib") | ||
else() | ||
if (NOT FLEDGE_LIB) | ||
set(FLEDGE_LIB ${FLEDGE_DEFAULT_LIB_DIR}) | ||
message(STATUS "Using Fledge dev package libs " ${FLEDGE_LIB}) | ||
else() | ||
message(STATUS "Using -DFLEDGE_LIB option " ${FLEDGE_LIB}) | ||
endif() | ||
# Set return variable FLEDGE_LIB_DIRS | ||
set(FLEDGE_LIB_DIRS ${FLEDGE_LIB}) | ||
endif() | ||
|
||
# Check NEEDED_FLEDGE_LIBS in libraries in FLEDGE_LIB_DIRS | ||
# NEEDED_FLEDGE_LIBS variables comes from CMakeLists.txt | ||
foreach(_LIB ${NEEDED_FLEDGE_LIBS}) | ||
# Remove current value from cache | ||
unset(_FOUND_LIB CACHE) | ||
# Get up to date var from find_library | ||
find_library(_FOUND_LIB NAME ${_LIB} PATHS ${FLEDGE_LIB_DIRS}) | ||
if (_FOUND_LIB) | ||
# Extract path form founf library file | ||
get_filename_component(_DIR_LIB ${_FOUND_LIB} DIRECTORY) | ||
else() | ||
message(SEND_ERROR "Needed Fledge library ${_LIB} not found in ${FLEDGE_LIB_DIRS}") | ||
return() | ||
endif() | ||
# Remove current value from cache | ||
unset(_FOUND_LIB CACHE) | ||
endforeach() | ||
|
||
# Set return variable FLEDGE_FOUND | ||
set(FLEDGE_FOUND "true") |
Oops, something went wrong.