Skip to content

Commit

Permalink
Fix generation of IDL files
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Sep 29, 2023
1 parent 1edb229 commit 6dece04
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 6 deletions.
215 changes: 215 additions & 0 deletions fastdds_python/test/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,113 @@ if(POLICY CMP0086)
cmake_policy(SET CMP0086 NEW)
endif()

###############################################################################
# Library for types defined in test_included_modules IDL
###############################################################################

message(STATUS "Configuring python wrapper for types in test_included_modules...")

###############################################################################
# Type library on C++

project(test_included_modules)

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
test_included_modules.cxx
test_included_modulesPubSubTypes.cxx
)

include_directories()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#Create library for C++ types
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES})
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)
endif(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps)

###############################################################################
# Python bindings for type

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS "")

find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS})
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})

include_directories(${PYTHON_INCLUDE_PATH})

set(${PROJECT_NAME}_MODULE
test_included_modulesWrapper
)

set(${PROJECT_NAME}_MODULE_FILES
${PROJECT_NAME}.i
)

SET_SOURCE_FILES_PROPERTIES(
${${PROJECT_NAME}_MODULE_FILES}
PROPERTIES CPLUSPLUS ON
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)

include_directories(
${PROJECT_SOURCE_DIR}
)

set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test2")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
LANGUAGE python
SOURCES ${${PROJECT_NAME}_MODULE_FILES})

if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64)
endif()

target_link_libraries(${${PROJECT_NAME}_MODULE}
Python3::Module
fastrtps
${PROJECT_NAME}
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/eprosima/test2"
)


# Find the installation path
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
SET (PYTHON_MODULE_PATH
${_REL_PYTHON_MODULE_PATH}
)

# Install
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin/
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test2)
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test2)

###############################################################################
# Library for types defined in test_modules IDL
###############################################################################
Expand Down Expand Up @@ -118,3 +225,111 @@ install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/epro
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/eprosima/test)

###############################################################################
# Library for types defined in test_complete IDL
###############################################################################

message(STATUS "Configuring python wrapper for types in test_complete...")

###############################################################################
# Type library on C++

project(test_complete)

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
test_complete.cxx
test_completePubSubTypes.cxx
)

include_directories()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#Create library for C++ types
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES})
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)
endif(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps)

###############################################################################
# Python bindings for type

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS "")

find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS})
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})

include_directories(${PYTHON_INCLUDE_PATH})

set(${PROJECT_NAME}_MODULE
test_completeWrapper
)

set(${PROJECT_NAME}_MODULE_FILES
${PROJECT_NAME}.i
)

SET_SOURCE_FILES_PROPERTIES(
${${PROJECT_NAME}_MODULE_FILES}
PROPERTIES CPLUSPLUS ON
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)

include_directories(
${PROJECT_SOURCE_DIR}
)

set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
LANGUAGE python
SOURCES ${${PROJECT_NAME}_MODULE_FILES})

if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64)
endif()

target_link_libraries(${${PROJECT_NAME}_MODULE}
Python3::Module
fastrtps
${PROJECT_NAME}
test_included_modules
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
)


# Find the installation path
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
SET (PYTHON_MODULE_PATH
${_REL_PYTHON_MODULE_PATH}
)

# Install
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin/
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}/)
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/)

7 changes: 7 additions & 0 deletions fastdds_python/test/types/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [[ -z "$(which fastddsgen)" ]]; then
echo "Cannot find fastddsgen. Please, include it in PATH environment variable"
exit -1
fi

fastddsgen -python -replace test_complete.idl test_modules.idl
3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_completeCdrAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ eProsima_user_DllExport void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_HPP_
#endif // _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_HPP_

3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_completeCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,4 +1346,5 @@ void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_IPP_
#endif // _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_IPP_

3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_included_modulesCdrAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ eProsima_user_DllExport void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_HPP_
#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_HPP_

3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_included_modulesCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,5 @@ void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_IPP_
#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_IPP_

3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_modulesCdrAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ eProsima_user_DllExport void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_HPP_
#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_HPP_

3 changes: 2 additions & 1 deletion fastdds_python/test/types/test_modulesCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,4 +1340,5 @@ void serialize_key(
} // namespace fastcdr
} // namespace eprosima

#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_IPP_
#endif // _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_IPP_

0 comments on commit 6dece04

Please sign in to comment.