Added modifications to cmake to create a separate lib for the new interfaces using SWIG.

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Serban Waltter 2018-06-21 16:33:01 +03:00 committed by Mihai Tudor Panu
parent 8312e1d18f
commit efd36e57b0
5 changed files with 25 additions and 4 deletions

View File

@ -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()

View File

@ -10,5 +10,6 @@ JAVA_JNI_LOADLIBRARY(javaupm_abp)
%{
#include "abp.hpp"
%}
%include "interfaces/iTemperature.hpp"
%include "abp.hpp"
/* END Common SWIG syntax */

View File

@ -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)

View File

@ -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)

View File

@ -1,3 +1,6 @@
%module (package="pyupm_new_interfaces") sht1x
%import "interfaces/new_interfaces.i"
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */