cmake: Dependency refactoring for includes and libs

This commit attempts to use a more cmake-friendly approach when
handling inter-target dependencies.  A combination of macros and
include_directories usage provided overzealous compile -I/blah
entries which equates to large catch-all build commands.  For
example, the last CXX target contains include directories for nearly
all preceeding targets (~190).  Library dependencies were also often
wrong or missing.

    * Removed nearly all used of include_directories (swig cmake
      commands still appear to need these for generating the swig
      command line)
    * Updated usage of target_link_libraries in upm_module_init,
      also changed to using target_include_directories per target.
      This greatly simplifies upm/mixed_module_init usage for libraries
      which depend on other libraries (in this project).

        example (src/tb7300/CMakeLists.txt)
            old:
                 # upm-libbacnetmstp will bring in libbacnet, I hope
                 set (reqlibname "upm-bacnetmstp")
                 include_directories(${BACNET_INCLUDE_DIRS})
                 include_directories("../bacnetmstp")
                 upm_module_init()
                 upm_target_link_libraries(${libname} bacnetmstp)
            new:
                 upm_module_init(bacnetmstp)

      The reason here, is that tb7300 depends on bacnetmstp, which
      depends on BACNET includes/libs, so tb7300 gets the headers and
      libraries transitively via its dependency on bacnetmstp.
    * Updated pkg-config .pc file generation flow to reflect changes
      with dependencies.
    * Create a real target for the interfaces (CXX abstract sensor
      classes).  Renamed the directory from 'upm/src/upm' to
      'upm/src/interfaces'  Also changed the install location of the
      interface headers to include/upm/interfaces.  Updated interface
      header usage to reflect this.
    * Updated a few sensor libs to use fwd declarations for mraa.
      Ideally the UPM libs would do more of this which eases the
      burden on anyone building on top of the sensor libraries since
      they would not need to know about mraa headers.
    * Fixed examples which use symbols not defined in local includes

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2017-01-30 18:14:48 -08:00
parent 7f0e03b0e3
commit d345006c03
97 changed files with 326 additions and 202 deletions

View File

@ -30,6 +30,8 @@
#include <fstream>
#include <string>
#include <thread>
#include <unistd.h>
#include "ads1015.hpp"
using namespace std;

View File

@ -316,5 +316,5 @@ int main()
delete ads;
return MRAA_SUCCESS;
return 0;
}

View File

@ -159,5 +159,5 @@ int main()
}while (command != -1 );
//! [Interesting]
return MRAA_SUCCESS;
return 0;
}

View File

@ -74,5 +74,5 @@ int main()
delete sensor;
//! [Interesting]
return MRAA_SUCCESS;
return 0;
}

View File

@ -37,18 +37,88 @@ macro (upm_create_install_pkgconfig generated_file install_location)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro(upm_create_install_pkgconfig)
# Provide a wrapper to call target_link_libraries AND add any additional
# functionality necessary for upm modules. This was being used to add
# link dependencies for the swig wrappers (swig_link_libraries). This has
# been removed. Leaving the wrapper call to minimize changes.
macro (upm_target_link_libraries target_name)
# Add the dependencies
target_link_libraries(${target_name} ${ARGN})
endmacro (upm_target_link_libraries target_name)
# This function iterates over all target names stored in CACHE variable
# UPM_LIBRARY_TARGETS and writes a .pc file to each build directory
function (_gen_pkg_config_per_target)
list(LENGTH UPM_LIBRARY_TARGETS n_targets)
message(STATUS "Generating pkg-config files for ${n_targets} libraries...")
set (n_ctargets 0)
set (n_cxxtargets 0)
# Iterate over the targets an build package config (.pc) files
foreach (target ${UPM_LIBRARY_TARGETS})
if (TARGET ${target})
get_target_property(libname ${target} PKG_CONFIG_NAME)
get_target_property(libdescription ${target} PKG_CONFIG_DESCRIPTION)
get_target_property(reqlibname ${target} PKG_EXT_REQ_LIBS)
get_target_property(BINARY_DIR ${target} BINARY_DIR)
get_target_property(DEPLIBS ${target} LINK_LIBRARIES)
# Remove this libname from the DEPLIBS (if it's there)
list(REMOVE_ITEM DEPLIBS ${libname})
# Check if any of the LINK_LIBRARIES are targets in this project,
# if so, add them to reqlibname
foreach (deplib ${DEPLIBS})
# If this target exists, get the actual library name (which equates
# to it's .pc filename, example: target dfrph = <upm-dfrph>.pc
if (TARGET ${deplib})
get_target_property(deplibname ${deplib} PKG_CONFIG_NAME)
list(APPEND reqlibname ${deplibname})
# If the deplib is mraa, add that verbatim (mraa's .pc file is mraa.pc)
elseif (${deplib} MATCHES mraa)
list(APPEND reqlibname mraa)
endif (TARGET ${deplib})
endforeach (deplib ${DEPLIBS})
# Make sure no dups exist
separate_arguments(reqlibname)
list(REMOVE_DUPLICATES reqlibname)
# Switch to comma separated Requires: field (per pkg-config docs)
string(REPLACE ";" "," reqlibname "${reqlibname}")
# Keep some stats
string(REGEX MATCH "-c$" _isC ${target})
if (_isC)
MATH(EXPR n_ctargets "${n_ctargets}+1")
else ()
MATH(EXPR n_cxxtargets "${n_cxxtargets}+1")
endif()
upm_create_install_pkgconfig (${libname}.pc ${LIB_INSTALL_DIR}/pkgconfig)
endif (TARGET ${target})
endforeach (target ${UPM_LIBRARY_TARGETS})
message(STATUS "\tFound C libraries: ${n_ctargets}")
message(STATUS "\tFound CXX libraries: ${n_cxxtargets}")
message(STATUS "Generating pkg-config files for ${n_targets} libraries... Complete")
endfunction (_gen_pkg_config_per_target)
function (_get_target_dependency_interface_include_dirs target varIncludeDirs)
set (${varIncludeDirs} "")
# For each LINK_LIBRARIES of target
get_property(_targets TARGET ${target} PROPERTY LINK_LIBRARIES)
foreach (_target ${_targets})
# If the target currently exists, use its include directories
if (TARGET ${_target})
get_property(_tmp_prop_val TARGET ${_target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
list(APPEND ${varIncludeDirs} ${_tmp_prop_val})
# It's possible that the target does NOT exist yet, attempt to build an include directory
else ()
# Guess at a src dir name
file (TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/src/${_target}" _dirname)
if (EXISTS ${_dirname})
list(APPEND ${varIncludeDirs} ${_dirname})
else ()
endif (EXISTS ${_dirname})
endif (TARGET ${_target})
endforeach (_target ${_targets})
set(${varIncludeDirs} "${${varIncludeDirs}}" PARENT_SCOPE)
endfunction (_get_target_dependency_interface_include_dirs target varIncludeDirs)
# Create a single swig target for python
macro(_upm_swig_python)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..)
# Transitive headers don't appear to get picked up by swig_add_module call for
# wrapper generation. Get them manually and add them here.
_get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..
${DEPEND_DIRS})
set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (pyupm_${libname}.i PROPERTIES SWIG_FLAGS "-I${CMAKE_CURRENT_BINARY_DIR}/..")
@ -74,7 +144,8 @@ macro(_upm_swig_python)
target_include_directories (${python_wrapper_target}
PUBLIC
"${PYTHON_INCLUDE_PATH}"
"${PYTHON_INCLUDE_DIRS}")
"${PYTHON_INCLUDE_DIRS}"
${DEPEND_DIRS})
# Turn off flags for wrapper
foreach(flag ${SWIG_CXX_DISABLE_WARNINGS})
@ -154,8 +225,13 @@ macro(upm_swig_node)
string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length)
endwhile ()
# Transitive headers don't appear to get picked up by swig_add_module call for
# wrapper generation. Get them manually and add them here.
_get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS)
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/..
${DEPEND_DIRS}
)
set_property (SOURCE jsupm_${libname}.i PROPERTY SWIG_FLAGS "-node" "-DV8_VERSION=${V8_VERSION_HEX}")
@ -165,6 +241,7 @@ macro(upm_swig_node)
target_include_directories ( ${SWIG_MODULE_jsupm_${libname}_REAL_NAME}
PUBLIC
"${NODE_INCLUDE_DIRS}"
${DEPEND_DIRS}
)
# Turn off flags for wrapper
@ -205,10 +282,15 @@ endmacro(upm_swig_node)
macro(upm_swig_java)
# Skip if the libname is in the blacklist
if (NOT ";${JAVASWIG_BLACKLIST};" MATCHES ";${libname};")
# Transitive headers don't appear to get picked up by swig_add_module call for
# wrapper generation. Get them manually and add them here.
_get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS)
include_directories (
${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2}
${CMAKE_CURRENT_SOURCE_DIR}/..
${DEPEND_DIRS}
)
set_source_files_properties (javaupm_${libname}.i PROPERTIES CPLUSPLUS ON)
@ -220,11 +302,12 @@ macro(upm_swig_java)
# See issue #518
# TODO: Fix this somehow
swig_add_module (javaupm_${libname} java javaupm_${libname}.i ${module_src})
swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARIES} ${MRAA_LIBRARIES} ${JAVA_LIBRARIES} ${libname})
swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARIES} ${MRAA_LIBRARIES} ${JAVA_LIBRARIES} ${libname} interfaces)
target_include_directories ( ${SWIG_MODULE_javaupm_${libname}_REAL_NAME}
PUBLIC
"${JAVA_INCLUDE_DIRS}"
"${JAVA_INCLUDE_PATH}"
${DEPEND_DIRS}
)
set_target_properties (javaupm_${libname} PROPERTIES
COMPILE_FLAGS "-fpermissive -DJAVACALLBACK"
@ -332,10 +415,10 @@ if (BUILDSWIGNODE)
# Utilities and interfaces
file (COPY ${CMAKE_SOURCE_DIR}/src/utilities DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
file (COPY ${CMAKE_SOURCE_DIR}/src/upm DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
file (COPY ${CMAKE_SOURCE_DIR}/src/interfaces DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
set (upm_LIB_SRCS_GYP "'utilities/upm_utilities.c',\n${upm_LIB_SRCS_GYP}")
set (upm_LIB_INCLUDE_DIRS_GYP "'utilities',\n${upm_LIB_INCLUDE_DIRS_GYP}")
set (upm_LIB_INCLUDE_DIRS_GYP "'upm',\n${upm_LIB_INCLUDE_DIRS_GYP}")
set (upm_LIB_INCLUDE_DIRS_GYP "'interfaces',\n${upm_LIB_INCLUDE_DIRS_GYP}")
# Add readme, package.json for NPM and node-gyp config file
configure_file (${PROJECT_SOURCE_DIR}/src/binding.gyp.in ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}/binding.gyp @ONLY)
@ -390,6 +473,9 @@ function (UPM_MIXED_MODULE_INIT)
# Set the description
set (libdescription ${UPM_MIXED_MODULE_INIT_DESCRIPTION})
# Make sure REQUIRES is a list
separate_arguments(UPM_MIXED_MODULE_INIT_REQUIRES)
# Always build C libs first
if (UPM_MIXED_MODULE_INIT_C_SRC)
set (libname ${UPM_MIXED_MODULE_INIT_NAME})
@ -397,11 +483,9 @@ function (UPM_MIXED_MODULE_INIT)
set (module_src ${UPM_MIXED_MODULE_INIT_C_SRC})
set (module_hpp ${UPM_MIXED_MODULE_INIT_C_HDR})
# Create the reqlibname list
string(REPLACE ";" " " reqlibname "${UPM_MIXED_MODULE_INIT_REQUIRES}")
# Append upmc-utilities to the reqlibs (but not on upm-utilities itself)
# Append the utilities-c target to each c target
if (NOT ${libname} MATCHES "utilities")
set (reqlibname "${reqlibname} upmc-utilities")
list (APPEND UPM_MIXED_MODULE_INIT_REQUIRES utilities-c)
endif()
# If building FTI, and FTI src exists, add it in
@ -416,7 +500,7 @@ function (UPM_MIXED_MODULE_INIT)
# Set a flag to tell upm_module_init that it's building a C library
set (IS_C_LIBRARY TRUE)
upm_module_init()
upm_module_init(${UPM_MIXED_MODULE_INIT_REQUIRES})
# add upmc-utilities as a dependancy to all C libs (but NOT to the
# utilities lib itself)
@ -436,13 +520,10 @@ function (UPM_MIXED_MODULE_INIT)
set (module_src ${UPM_MIXED_MODULE_INIT_CPP_SRC})
set (module_hpp ${UPM_MIXED_MODULE_INIT_CPP_HDR})
# Create the reqlibname list
string(REPLACE ";" " " reqlibname "${UPM_MIXED_MODULE_INIT_REQUIRES}")
# Reset the libname (upm_module_init can change it)
set (libname ${UPM_MIXED_MODULE_INIT_NAME})
unset (IS_C_LIBRARY)
upm_module_init()
upm_module_init(${UPM_MIXED_MODULE_INIT_REQUIRES})
# If the C++ wraps the C target, add the C target as a dependency
if (UPM_MIXED_MODULE_INIT_CPP_WRAPS_C)
@ -466,19 +547,30 @@ function(upm_module_init)
# If this is a C library, export C library target name to parent's libname
set (libname ${libname} PARENT_SCOPE)
set (libprefix upmc-)
set (pcname upmc-${basename}.pc)
else ()
set (libprefix upm-)
set (pcname upm-${basename}.pc)
endif (IS_C_LIBRARY)
link_directories (${MRAA_LIBDIR})
# Create the target library from src/hdrs
add_library (${libname} SHARED ${module_src} ${module_hpp})
# Specify the current source directory as an INTERFACE include dir.
# This allows for transitive header dependencies via target_link_libraries
target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Iterate over all arguments passed to upm_module_init.
# 1. Add them via target_link_libraries
# 2. If the argument is a target,
foreach (linkflag ${ARGN})
target_link_libraries (${libname} ${linkflag})
endforeach ()
include_directories (${MRAA_INCLUDE_DIRS} . ..)
target_link_libraries (${libname} ${MRAA_LIBRARIES})
# Always add a dependency to MRAA libs
target_link_libraries (${libname} ${MRAA_LDFLAGS})
# Always add a dependency to MRAA include dirs
target_include_directories (${libname} PUBLIC ${MRAA_INCLUDE_DIRS})
set_target_properties(
${libname}
PROPERTIES PREFIX lib${libprefix}
@ -486,7 +578,6 @@ function(upm_module_init)
SOVERSION ${upm_VERSION_MAJOR}
VERSION ${upm_VERSION_STRING}
)
upm_create_install_pkgconfig (${pcname} ${LIB_INSTALL_DIR}/pkgconfig)
# Don't SWIG C
if (NOT IS_C_LIBRARY)
@ -501,12 +592,21 @@ function(upm_module_init)
endif (BUILDSWIGJAVA)
endif (NOT IS_C_LIBRARY)
# Add this target to the list of library target names
set(UPM_LIBRARY_TARGETS ${UPM_LIBRARY_TARGETS} ${libname} CACHE INTERNAL "List of ALL target names")
set_target_properties(${libname} PROPERTIES PKG_CONFIG_NAME "${libprefix}${basename}")
set_target_properties(${libname} PROPERTIES PKG_CONFIG_DESCRIPTION "${libdescription}")
set_target_properties(${libname} PROPERTIES PKG_EXT_REQ_LIBS "${reqlibname}")
# Skip doxygen run on C (for now)
if (BUILDDOC AND NOT IS_C_LIBRARY)
upm_doxygen()
endif()
# Install target library to lib dir
install (TARGETS ${libname} DESTINATION ${LIB_INSTALL_DIR})
# Install header files to include/upm/
install (FILES ${module_hpp} DESTINATION include/upm COMPONENT ${libname})
if (IPK)
@ -545,11 +645,15 @@ elseif (BUILDSWIGPYTHON)
file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/pyupm_doxy2swig.i "// Empty doxy2swig stub")
endif (BUILDDOC AND BUILDSWIGPYTHON)
# Provide a cached variable to save a list of library target names
set(UPM_LIBRARY_TARGETS "" CACHE INTERNAL "List of ALL target names")
# Add subdirectories from MODULE_LIST if defined
# Example -DMODULE_LIST="dfrph;rotaryencoder"
if (MODULE_LIST)
set(SUBDIRS ${MODULE_LIST})
set(SUBDIRS ${SUBDIRS} upm)
# Add interfaces directory
set(SUBDIRS ${SUBDIRS} interfaces)
else()
# Otherwise, add all subdirectories
subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
@ -567,3 +671,6 @@ foreach(subdir ${SUBDIRS})
add_subdirectory(${subdir})
endif()
endforeach()
# Generate a pkg-config file (.pc) per target
_gen_pkg_config_per_target()

View File

@ -2,8 +2,4 @@ set (libname "adafruitms1438")
set (libdescription "Module for the Adafruit Motor Shield 1438")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (reqlibname "upm-pca9685")
include_directories("../pca9685")
upm_module_init()
add_dependencies(${libname} pca9685)
upm_target_link_libraries(${libname} pca9685)
upm_module_init(pca9685)

View File

@ -2,7 +2,7 @@ set (libname "ads1x15")
set (libdescription "Analog to digital converter")
set (module_src ${libname}.cxx ads1115.cxx ads1015.cxx)
set (module_hpp ${libname}.hpp ads1115.hpp ads1015.hpp)
upm_module_init()
upm_module_init(interfaces)
compiler_flag_supported(CXX is_supported -Wno-overloaded-virtual)
if (is_supported)
target_compile_options(${libname} PUBLIC -Wno-overloaded-virtual)

View File

@ -21,7 +21,11 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include "ads1015.hpp"
#include "mraa/i2c.hpp"
using namespace upm;

View File

@ -26,7 +26,7 @@
#pragma once
#include "ads1x15.hpp"
#include "upm/iADC.hpp"
#include "interfaces/iADC.hpp"
#define ADS1015_VREF 2.048

View File

@ -24,6 +24,7 @@
#include "ads1x15.hpp"
#include "mraa/i2c.hpp"
#include <unistd.h>
#include <syslog.h>

View File

@ -26,8 +26,8 @@
#include <iostream>
#include <string>
#include "mraa.hpp"
#include "mraa/i2c.hpp"
namespace mraa {class I2c;}
/*=========================================================================
I2C ADDRESS/BITS
@ -419,6 +419,6 @@ namespace upm {
void updateConfigRegister(uint16_t update, bool read = false);
uint16_t swapWord(uint16_t value);
mraa::I2c* i2c;
mraa::I2c* i2c;
};}

View File

@ -8,6 +8,8 @@
#include "ads1115.hpp"
%}
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%include "ads1015.hpp"
%include "ads1115.hpp"
@ -23,4 +25,4 @@
System.exit(1);
}
}
%}
%}

View File

@ -1,6 +1,9 @@
%module jsupm_ads1x15
%include "../upm.i"
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%{
#include "ads1x15.hpp"
@ -14,4 +17,4 @@
%include "ads1115.hpp"
%{
#include "ads1115.hpp"
%}
%}

View File

@ -5,6 +5,9 @@
%feature("autodoc", "3");
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%{
#include "ads1x15.hpp"
@ -18,4 +21,4 @@
%include "ads1115.hpp"
%{
#include "ads1115.hpp"
%}
%}

View File

@ -5,4 +5,4 @@ upm_mixed_module_init (NAME apa102
CPP_HDR apa102.hpp
CPP_SRC apa102.cxx
FTI_SRC apa102_fti.c
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -1,11 +1,11 @@
set (libname "bacnetmstp")
set (libdescription "Driver module for BACnet MS/TP devices")
set (module_src ${libname}.cxx device-client.c bacnetutil.cxx)
set (module_hpp ${libname}.hpp bacnetutil.hpp)
if (BACNET_FOUND)
set (libname "bacnetmstp")
set (libdescription "Driver module for BACnet MS/TP devices")
set (module_src ${libname}.cxx device-client.c bacnetutil.cxx)
set (module_hpp ${libname}.hpp bacnetutil.hpp device.h)
set (reqlibname "libbacnet")
include_directories(${BACNET_INCLUDE_DIRS})
upm_module_init()
upm_target_link_libraries(${libname} ${BACNET_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
upm_module_init(${BACNET_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
# Add the bacnet include dirs to this target
target_include_directories(${libname} PUBLIC ${BACNET_INCLUDE_DIRS})
endif ()

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME bh1750
CPP_SRC bh1750.cxx
FTI_SRC bh1750_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -2,4 +2,4 @@ set (libname "bmp280")
set (libdescription "Bosch bmp280 Pressure sensor and bme280 humidity sensor")
set (module_src ${libname}.cxx bme280.cxx)
set (module_hpp ${libname}.hpp bme280.hpp)
upm_module_init()
upm_module_init(interfaces)

View File

@ -28,7 +28,7 @@
#include <mraa/spi.hpp>
#include <mraa/gpio.hpp>
#include "upm/iHumiditySensor.hpp"
#include "interfaces/iHumiditySensor.hpp"
#include "bmp280.hpp"

View File

@ -28,8 +28,8 @@
#include <mraa/spi.hpp>
#include <mraa/gpio.hpp>
#include "upm/iPressureSensor.hpp"
#include "upm/iTemperatureSensor.hpp"
#include "interfaces/iPressureSensor.hpp"
#include "interfaces/iTemperatureSensor.hpp"
#define BMP280_DEFAULT_I2C_BUS 0
#define BMP280_DEFAULT_SPI_BUS 0

View File

@ -5,6 +5,10 @@
%include "arrays_java.i";
%include "../java_buffer.i"
%include "iModuleStatus.hpp"
%include "iHumiditySensor.hpp"
%include "iPressureSensor.hpp"
%include "iTemperatureSensor.hpp"
%include "bmp280.hpp"
%{
#include "bmp280.hpp"

View File

@ -2,6 +2,10 @@
%include "../upm.i"
%include "cpointer.i"
%include "iModuleStatus.hpp"
%include "iHumiditySensor.hpp"
%include "iPressureSensor.hpp"
%include "iTemperatureSensor.hpp"
%include "bmp280.hpp"
%{
#include "bmp280.hpp"

View File

@ -12,6 +12,10 @@
%include "bmp280_doc.i"
#endif
%include "iModuleStatus.hpp"
%include "iHumiditySensor.hpp"
%include "iPressureSensor.hpp"
%include "iTemperatureSensor.hpp"
%include "bmp280.hpp"
%{
#include "bmp280.hpp"

View File

@ -30,8 +30,8 @@
#include <string>
#include <mraa/i2c.hpp>
#include <math.h>
#include "upm/iPressureSensor.hpp"
#include "upm/iTemperatureSensor.hpp"
#include "interfaces/iPressureSensor.hpp"
#include "interfaces/iTemperatureSensor.hpp"
#define ADDR 0x77 // device address

View File

@ -32,7 +32,7 @@
#include <upm.h>
#include <mraa/pwm.h>
#include <buzzer_tones.h>
#include "buzzer_tones.h"
#ifdef __cplusplus
extern "C" {

View File

@ -5,4 +5,4 @@ upm_mixed_module_init (NAME cjq4435
CPP_HDR cjq4435.hpp
CPP_SRC cjq4435.cxx
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -1,6 +1,3 @@
# we need includes from ds18b20
include_directories("../ds18b20")
upm_mixed_module_init (NAME dfrec
DESCRIPTION "DFRobot analog electrical conductivity (EC) sensor"
C_HDR dfrec.h
@ -9,9 +6,8 @@ upm_mixed_module_init (NAME dfrec
CPP_SRC dfrec.cxx
FTI_SRC dfrec_fti.c
CPP_WRAPS_C
REQUIRES upmc-ds18b20 mraa)
REQUIRES ds18b20 mraa)
# make sure the C library has the appropriate dependency on the UPM
# DS18B20 C library
add_dependencies(${libnamec} ds18b20-c)
target_link_libraries(${libnamec} ds18b20-c)

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME dfrorp
CPP_SRC dfrorp.cxx
FTI_SRC dfrorp_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -1,6 +1,5 @@
include_directories(..)
set (libname "ds1808lc")
set (libdescription "DS1808 lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()
upm_module_init(interfaces)

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "upm/iLightController.hpp"
#include "iLightController.hpp"
#include "mraa/i2c.hpp"
namespace upm

View File

@ -9,6 +9,8 @@
#include "ds1808lc.hpp"
%}
%include "iModuleStatus.hpp"
%include "iLightController.hpp"
%include "ds1808lc.hpp"
%pragma(java) jniclasscode=%{

View File

@ -5,4 +5,6 @@
#include "ds1808lc.hpp"
%}
%include "iModuleStatus.hpp"
%include "iLightController.hpp"
%include "ds1808lc.hpp"

View File

@ -6,6 +6,8 @@
%feature("autodoc", "3");
%include "iModuleStatus.hpp"
%include "iLightController.hpp"
%include "ds1808lc.hpp"
%{
#include "ds1808lc.hpp"

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME ds18b20
CPP_SRC ds18b20.cxx
FTI_SRC ds18b20_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -1,13 +1,8 @@
set (libname "e50hx")
set (libdescription "Module for the Veris E50HX (E50H2/E50H5)Energy Meters")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (BACNET_FOUND)
# upm-libbacnetmstp will bring in libbacnet, I hope
set (reqlibname "upm-bacnetmstp")
include_directories(${BACNET_INCLUDE_DIRS})
include_directories("../bacnetmstp")
upm_module_init()
upm_target_link_libraries(${libname} bacnetmstp)
set (libname "e50hx")
set (libdescription "Module for the Veris E50HX (E50H2/E50H5)Energy Meters")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(bacnetmstp)
endif ()

View File

@ -6,7 +6,7 @@
// We need to use this method for enum wrapping since the enum typedefs used
// by the derived classes (like ANALOG_VALUES_T) are passed to methods
// in the base class which expect a uint32_t. This is fine, and
// works everywhere except Java. It's type safety is a little too
// works everywhere except Java. Its type safety is a little too
// stringent in these cases. %javaconst(1) is generally recommended
// as it avoids JNI calls to determine the enumerant values at
// runtime.

View File

@ -1,11 +1,10 @@
set (libname "h803x")
set (libdescription "Module for the Veris H803X (H8035/H8036)")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (MODBUS_FOUND)
set (libname "h803x")
set (libdescription "Module for the Veris H803X (H8035/H8036)")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (reqlibname "libmodbus")
include_directories(${MODBUS_INCLUDE_DIRS})
upm_module_init()
upm_target_link_libraries(${libname} ${MODBUS_LIBRARIES})
upm_module_init(${MODBUS_LIBRARIES})
target_include_directories(${libname} PUBLIC ${MODBUS_INCLUDE_DIRS})
endif ()

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "hlg150h")
set (libdescription "Lighting power supply")
set (module_src ${libname}.cxx mraa-utils.cxx)

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "upm/iLightController.hpp"
#include "interfaces/iLightController.hpp"
// #include "mraa/gpio.hpp"
#include "mraa/pwm.hpp"

View File

@ -1,11 +1,10 @@
set (libname "hwxpxx")
set (libdescription "Module for the Veris HWXPXX (HWXPHTX)")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (MODBUS_FOUND)
set (libname "hwxpxx")
set (libdescription "Module for the Veris HWXPXX (HWXPHTX)")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (reqlibname "libmodbus")
include_directories(${MODBUS_INCLUDE_DIRS})
upm_module_init()
upm_target_link_libraries(${libname} ${MODBUS_LIBRARIES})
upm_module_init(${MODBUS_LIBRARIES})
target_include_directories(${libname} PUBLIC ${MODBUS_INCLUDE_DIRS})
endif ()

View File

@ -25,6 +25,7 @@
*/
#include "ili9341_gfx.hpp"
#include "mraa.hpp"
using namespace upm;
@ -746,4 +747,4 @@ const unsigned char GFX::font[] = {
0x00, 0x19, 0x1D, 0x17, 0x12,
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
};
};

View File

@ -26,7 +26,8 @@
#pragma once
#include <mraa.hpp>
#include <cstdint>
#include <string>
#define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }

View File

@ -0,0 +1,18 @@
set (libname "interfaces")
set (libdescription "CXX interface library")
set (module_src ${libname}.cxx)
upm_module_init()
# Don't add the hpp files with upm_module_init, this allows
# them to be installed separately
set (module_hpp iADC.hpp
iCO2Sensor.hpp
iHumiditySensor.hpp
iLightController.hpp
iLightSensor.hpp
iModuleStatus.hpp
iPressureSensor.hpp
iTemperatureSensor.hpp)
# Install interfaces headers a bit differently
install (FILES ${module_hpp} DESTINATION include/upm/${libname} COMPONENT ${libname})

View File

@ -0,0 +1 @@
#include "iLightSensor.hpp"

View File

@ -6,8 +6,9 @@
%{
#include "../upm/iLightSensor.hpp"
#include "../upm/iLightController.hpp"
#include "iModuleStatus.hpp"
#include "iLightSensor.hpp"
#include "iLightController.hpp"
%}
%include "iModuleStatus.hpp"

View File

@ -5,7 +5,7 @@
%}
/*
%include "../upm/iModuleStatus.hpp"
%include "../iModuleStatus.hpp"
*/
%include "iLightSensor.hpp"

View File

@ -2,8 +2,8 @@
%include "../upm.i"
%{
#include "../upm/iLightSensor.hpp"
#include "../upm/iLightController.hpp"
#include "iLightSensor.hpp"
#include "iLightController.hpp"
%}
%include "iModuleStatus.hpp"

View File

@ -6,8 +6,8 @@
%feature("autodoc", "3");
%{
#include "../upm/iLightSensor.hpp"
#include "../upm/iLightController.hpp"
#include "iLightSensor.hpp"
#include "iLightController.hpp"
%}
%include "iModuleStatus.hpp"

View File

@ -6,6 +6,4 @@ upm_mixed_module_init (NAME jhd1313m1
CPP_SRC jhd1313m1.cxx
# FTI_SRC jhd1313m1_fti.c
CPP_WRAPS_C
REQUIRES mraa)
# We need hd44780_bits.h from lcm1602
include_directories("../lcm1602")
REQUIRES mraa lcm1602)

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME loudness
CPP_HDR loudness.hpp
FTI_SRC loudness_fti.c
CPP_WRAPS_C
REQUIRES libmraa)
REQUIRES mraa)

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "lp8860")
set (libdescription "LED lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "upm/iLightController.hpp"
#include "interfaces/iLightController.hpp"
#include "mraa/i2c.hpp"
namespace upm

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "max44009")
set (libdescription "MAX44009")
set (module_src ${libname}.cxx)

View File

@ -26,7 +26,7 @@
#include <string>
#include <mraa/i2c.hpp>
#include "upm/iLightSensor.hpp"
#include "interfaces/iLightSensor.hpp"
/* ADDRESS AND NOT_FOUND VALUE */
#define MAX44009_ADDRESS ( 0x4A )

View File

@ -32,7 +32,7 @@
#include <mraa/spi.h>
#include <mraa/gpio.h>
#include <mcp2515_regs.h>
#include "mcp2515_regs.h"
#ifdef __cplusplus
extern "C" {

View File

@ -26,6 +26,9 @@
#include <cmath>
#include <syslog.h>
#include "mraa.hpp"
#include "mraa/i2c.hpp"
using namespace upm;
MCP9808::MCP9808 (int bus, uint8_t address){

View File

@ -28,8 +28,6 @@
#include <iostream>
#include <string>
#include "mraa.hpp"
#include "mraa/i2c.hpp"
#define MCP9808_REG_CONFIG 0x01
#define MCP9808_REG_AMBIENT_TEMP 0x05
@ -41,6 +39,8 @@
#define MCP9808_CONFIG_WINLOCKED 0x4000
#define MCP9808_CONFIG_INTCLR 0x2000
namespace mraa { class I2c;}
namespace upm {
/**
* @brief MCP9808 precision temperature sensor library

View File

@ -22,8 +22,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include "micsv89.hpp"
#include "mraa/i2c.hpp"
using namespace upm;
MICSV89::MICSV89 (int bus, uint8_t address) {

View File

@ -26,8 +26,8 @@
#include <iostream>
#include <string>
#include "mraa.hpp"
#include "mraa/i2c.hpp"
namespace mraa { class I2c;}
namespace upm {
/**

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME mma7361
CPP_SRC mma7361.cxx
FTI_SRC mma7361_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -30,7 +30,7 @@
#include <mraa/i2c.h>
#include <mraa/gpio.h>
#include <mma7660_regs.h>
#include "mma7660_regs.h"
#ifdef __cplusplus
extern "C" {

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME moisture
CPP_SRC moisture.cxx
FTI_SRC moisture_fti.c
CPP_WRAPS_C
REQUIRES libmraa)
REQUIRES mraa)

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "ms5611")
set (libdescription "Pressure and temperature sensor")
set (module_src ${libname}.cxx)

View File

@ -22,8 +22,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "upm/iPressureSensor.hpp"
#include "upm/iTemperatureSensor.hpp"
#include "interfaces/iPressureSensor.hpp"
#include "interfaces/iTemperatureSensor.hpp"
#include "mraa/i2c.hpp"
namespace upm

View File

@ -32,7 +32,7 @@
#include <mraa/spi.h>
#include <mraa/gpio.h>
#include <ms5803_defs.h>
#include "ms5803_defs.h"
#ifdef __cplusplus
extern "C" {

View File

@ -22,7 +22,7 @@
#include "aci.h"
#include "hal_aci_tl.h"
#include <lib_aci.h>
#include "lib_aci.h"
#include "aci_setup.h"

View File

@ -55,8 +55,8 @@
#include <mraa/gpio.h>
#include <mraa/spi.h>
#include <lib_aci.h>
#include <aci_setup.h>
#include "lib_aci.h"
#include "aci_setup.h"
void init_local_interfaces (aci_state_t* aci, uint8_t reqn, uint8_t rdyn, uint8_t rst);
void close_local_interfaces (aci_state_t* aci);

View File

@ -28,7 +28,7 @@
#include <upm_utilities.h>
#include <upm_platform.h>
#include <otp538u.h>
#include "otp538u.h"
#include "thermopile_vt_table.h"
#include "thermister_rt_table.h"

View File

@ -1,13 +1,12 @@
set (libname "ozw")
set (libdescription "Module for the OpenZWave library interface")
set (module_src ${libname}.cxx zwNode.cxx ozwinterface.cxx ozwdump.cxx aeotecss6.cxx aeotecsdg2.cxx aeotecdw2e.cxx aeotecdsb09104.cxx tzemt400.cxx)
set (module_hpp ${libname}.hpp ozwinterface.hpp ozwdump.hpp aeotecss6.hpp aeotecsdg2.hpp aeotecdw2e.hpp aeotecdsb09104.hpp tzemt400.hpp)
if (OPENZWAVE_FOUND)
set (libname "ozw")
set (libdescription "Module for the OpenZWave library interface")
set (module_src ${libname}.cxx zwNode.cxx ozwinterface.cxx ozwdump.cxx aeotecss6.cxx aeotecsdg2.cxx aeotecdw2e.cxx aeotecdsb09104.cxx tzemt400.cxx)
set (module_hpp ${libname}.hpp ozwinterface.hpp ozwdump.hpp aeotecss6.hpp aeotecsdg2.hpp aeotecdw2e.hpp aeotecdsb09104.hpp tzemt400.hpp)
set (reqlibname "libopenzwave")
include_directories(${OPENZWAVE_INCLUDE_DIRS})
upm_module_init()
upm_target_link_libraries(${libname} ${OPENZWAVE_LIBRARIES})
upm_module_init(${OPENZWAVE_LIBRARIES})
target_include_directories(${libname} PUBLIC ${OPENZWAVE_INCLUDE_DIRS})
# openzwave/aes/aes.h has unknown pragmas, disable warning -Wunknown-pragmas
compiler_flag_supported(CXX is_supported -Wno-unknown-pragmas)

View File

@ -3,11 +3,11 @@ exec_prefix=${prefix}
libdir=${exec_prefix}/lib@LIB_SUFFIX@
includedir=${prefix}/include
Name: @libprefix@@basename@
Name: @libname@
Description: @libdescription@
Version: @upm_VERSION_STRING@
Libs: -L${libdir} -l@libprefix@@basename@
Libs: -L${libdir} -l@libname@
Cflags: -I${includedir}/upm
Requires: @reqlibname@

View File

@ -32,7 +32,7 @@
#include <upm.h>
#include <mraa/gpio.h>
#include <ppd42ns_data.h>
#include "ppd42ns_data.h"
#ifdef __cplusplus
extern "C" {

View File

@ -28,7 +28,7 @@
#include <cstring>
#include <cmath>
#include <sys/time.h>
#include <rf22.hpp>
#include "rf22.hpp"
using namespace upm;

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "si1132")
set (libdescription "UV and ambient light sensor")
set (module_src ${libname}.cxx)

View File

@ -1,6 +1,6 @@
%module(directors="1") javaupm_si1132
%include "../upm.i"
%include "../upm/javaupm_interfaces.i"
%include "../interfaces/javaupm_interfaces.i"
%pragma(java) jniclasscode=%{
static {
@ -18,8 +18,8 @@
%}
/*
%include "../upm/iModuleStatus.hpp"
%include "../upm/iLightSensor.hpp"
%include "../iModuleStatus.hpp"
%include "../iLightSensor.hpp"
%feature("director") IModuleStatus;
%feature("director") ILightSensor;

View File

@ -25,7 +25,7 @@
#include <string>
#include "mraa/i2c.hpp"
#include "upm/iLightSensor.hpp"
#include "interfaces/iLightSensor.hpp"
namespace upm {

View File

@ -1,4 +1,3 @@
include_directories(..)
set (libname "si7005")
set (libdescription "Digital I2C humidity and temperature sensor")
set (module_src ${libname}.cxx mraa-utils.cxx)

View File

@ -25,8 +25,8 @@
#include <mraa/i2c.hpp>
#include "upm/iTemperatureSensor.hpp"
#include "upm/iHumiditySensor.hpp"
#include "interfaces/iTemperatureSensor.hpp"
#include "interfaces/iHumiditySensor.hpp"
/* ADDRESS AND NOT_FOUND VALUE */
#define SI7005_ADDRESS ( 0x40 )

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME speaker
CPP_SRC speaker.cxx
# FTI_SRC speaker_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -1,11 +1,10 @@
set (libname "t3311")
set (libdescription "Module for the Comet System T3311")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (MODBUS_FOUND)
set (libname "t3311")
set (libdescription "Module for the Comet System T3311")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (reqlibname "libmodbus")
include_directories(${MODBUS_INCLUDE_DIRS})
upm_module_init()
upm_target_link_libraries(${libname} ${MODBUS_LIBRARIES})
upm_module_init(${MODBUS_LIBRARIES})
target_include_directories(${libname} PUBLIC ${MODBUS_INCLUDE_DIRS})
endif ()

View File

@ -29,7 +29,7 @@
#include <syslog.h>
#include <unistd.h>
#include <t6713.hpp>
#include "t6713.hpp"
#define T6713_ADDR 0x15

View File

@ -24,7 +24,7 @@
#include "mraa/i2c.hpp"
#include "upm/iCO2Sensor.hpp"
#include "interfaces/iCO2Sensor.hpp"
namespace upm {

View File

@ -1,13 +1,8 @@
set (libname "t8100")
set (libdescription "Module for the Telaire T8100 Ventostat")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (BACNET_FOUND)
# upm-libbacnetmstp will bring in libbacnet, I hope
set (reqlibname "upm-bacnetmstp")
include_directories(${BACNET_INCLUDE_DIRS})
include_directories("../bacnetmstp")
upm_module_init()
upm_target_link_libraries(${libname} bacnetmstp)
set (libname "t8100")
set (libdescription "Module for the Telaire T8100 Ventostat")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(bacnetmstp)
endif ()

View File

@ -1,13 +1,8 @@
set (libname "tb7300")
set (libdescription "Module for the TB7300 Fan Coil Thermostat")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
if (BACNET_FOUND)
# upm-libbacnetmstp will bring in libbacnet, I hope
set (reqlibname "upm-bacnetmstp")
include_directories(${BACNET_INCLUDE_DIRS})
include_directories("../bacnetmstp")
upm_module_init()
upm_target_link_libraries(${libname} bacnetmstp)
set (libname "tb7300")
set (libdescription "Module for the TB7300 Fan Coil Thermostat")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init(bacnetmstp)
endif ()

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME tsl2561
CPP_SRC tsl2561.cxx
FTI_SRC tsl2561_fti.c
CPP_WRAPS_C
REQUIRES libmraa)
REQUIRES mraa)

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME ttp223
CPP_SRC ttp223.cxx
FTI_SRC ttp223_fti.c
CPP_WRAPS_C
REQUIRES libmraa)
REQUIRES mraa)

View File

@ -1,8 +0,0 @@
install (DIRECTORY . DESTINATION include/upm FILES_MATCHING PATTERN "*.hpp")
if (BUILDSWIGJAVA)
set (libname "interfaces")
set (libdescription "CXX interface library")
set (module_src ${libname}.cxx)
# set (module_hpp ${libname}.hpp)
upm_module_init()
endif()

View File

@ -1 +0,0 @@
#include "upm/iLightSensor.hpp"

View File

@ -6,4 +6,4 @@ upm_mixed_module_init (NAME urm37
CPP_SRC urm37.cxx
FTI_SRC urm37_fti.c
CPP_WRAPS_C
REQUIRES upmc-utilities mraa)
REQUIRES mraa)

View File

@ -6,5 +6,5 @@ set (module_hpp ${libname}.hpp)
if (JPEG_FOUND)
set (reqlibname "jpeg")
upm_module_init()
upm_target_link_libraries(${libname} jpeg)
target_link_libraries(${libname} jpeg)
endif()