From efd36e57b0bd3e7161a3f2bc10768e7b1f8d2904 Mon Sep 17 00:00:00 2001 From: Serban Waltter Date: Thu, 21 Jun 2018 16:33:01 +0300 Subject: [PATCH] Added modifications to cmake to create a separate lib for the new interfaces using SWIG. Signed-off-by: Serban Waltter Signed-off-by: Mihai Tudor Panu --- src/CMakeLists.txt | 23 +++++++++++++++++++---- src/abp/abp.i | 1 + src/am2315/CMakeLists.txt | 1 + src/sht1x/CMakeLists.txt | 1 + src/sht1x/sht1x.i | 3 +++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08ae461d..71d17505 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -253,7 +253,11 @@ function (_get_current_dot_i_file filePrefix varDotIFile) set(SWIG_HASH_INCLUDES "#include \"${SWIG_HASH_INCLUDES}\"") # And the SWIG import string string(REPLACE "#" "%" SWIG_PERCENT_INCLUDES "${SWIG_HASH_INCLUDES}") - + if(module_iface) + foreach(_iface ${module_iface}) + set(SWIG_PERCENT_INCLUDES "%import \"interfaces/${_iface}\"") + endforeach(_iface ${module_iface}) + endif() # Write the interface file configure_file (${PROJECT_SOURCE_DIR}/src/swigme.i.in "${${varDotIFile}}" @ONLY) endif() @@ -271,7 +275,8 @@ macro(_upm_swig_python) include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. - ${DEPEND_DIRS}) + ${DEPEND_DIRS} + ${UPM_COMMON_HEADER_DIRS}) # Decide between ${libname}.i or a language-specific .i _get_current_dot_i_file(pyupm SWIG_CURRENT_DOT_I_FILE) @@ -305,6 +310,11 @@ macro(_upm_swig_python) endif () # Get target library name (example _pyupm_a110x-python2) set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME}) + + if(module_iface) + add_dependencies(${python_wrapper_target} _pyupm_new_interfaces-python${PYTHON_VERSION_MAJOR}) + endif() + add_dependencies(${python_wrapper_target} ${libname}) swig_link_libraries (${python_wrapper_name} ${PYTHON_LIBRARIES} ${libname} -Wl,--unresolved-symbols=report-all) @@ -390,7 +400,7 @@ endfunction(upm_swig_python) function(upm_swig_node) # Skip if the libname is in the blacklist if (NOT ";${NODESWIG_BLACKLIST};" MATCHES ";${libname};") - # SWIG treats SWIG_FLAGS as a list and not a string so semicolon seperation is + # SWIG treats SWIG_FLAGS as a list and not a string so semicolon seperation is # required. This hardcodes V8_VERSION to be <10 but I assume that's not going # to be a problem for a little while! SWIG uses a padded SWIG_V8 version which # we hack together from our findnode module. @@ -866,7 +876,11 @@ function(upm_module_init) # Install interface file if it exists if(DEFINED module_iface) set(iface_path ${PROJECT_SOURCE_DIR}/include/interfaces) - install (FILES ${iface_path}/${module_iface} + set(iface_files "") + foreach(iface ${module_iface}) + LIST(APPEND iface_files "${iface_path}/${iface}") + endforeach(iface ${module_iface}) + install (FILES ${iface_files} DESTINATION include/upm/interfaces COMPONENT ${CMAKE_PROJECT_NAME}-dev) endif(DEFINED module_iface) @@ -941,6 +955,7 @@ foreach(subdir ${MODULE_LIST}) add_subdirectory(${subdir}) endif() endforeach() +add_subdirectory(${PROJECT_SOURCE_DIR}/include/interfaces ${CMAKE_BINARY_DIR}/interfaces) # Print stats for all targets _print_target_summary() diff --git a/src/abp/abp.i b/src/abp/abp.i index cc094b2c..2cd68f49 100644 --- a/src/abp/abp.i +++ b/src/abp/abp.i @@ -10,5 +10,6 @@ JAVA_JNI_LOADLIBRARY(javaupm_abp) %{ #include "abp.hpp" %} +%include "interfaces/iTemperature.hpp" %include "abp.hpp" /* END Common SWIG syntax */ diff --git a/src/am2315/CMakeLists.txt b/src/am2315/CMakeLists.txt index 0915f3c7..ca0b4e81 100644 --- a/src/am2315/CMakeLists.txt +++ b/src/am2315/CMakeLists.txt @@ -2,4 +2,5 @@ set (libname "am2315") set (libdescription "Digital Temperature and Humidity Sensor") set (module_src ${libname}.cpp) set (module_hpp ${libname}.hpp) +set (module_iface iTemperature.hpp iHumidity.hpp) upm_module_init(mraa) diff --git a/src/sht1x/CMakeLists.txt b/src/sht1x/CMakeLists.txt index 5b417976..6cdca6fd 100644 --- a/src/sht1x/CMakeLists.txt +++ b/src/sht1x/CMakeLists.txt @@ -5,5 +5,6 @@ upm_mixed_module_init (NAME sht1x CPP_HDR sht1x.hpp CPP_SRC sht1x.cxx FTI_SRC sht1x_fti.c + IFACE_HDR iTemperature.hpp iHumidity.hpp CPP_WRAPS_C REQUIRES mraa utilities-c) diff --git a/src/sht1x/sht1x.i b/src/sht1x/sht1x.i index 3dee709c..93f3d7fd 100644 --- a/src/sht1x/sht1x.i +++ b/src/sht1x/sht1x.i @@ -1,3 +1,6 @@ +%module (package="pyupm_new_interfaces") sht1x +%import "interfaces/new_interfaces.i" + %include "../common_top.i" /* BEGIN Java syntax ------------------------------------------------------- */