From 57db6d9799e1a104b46e925a080a00607bc2520d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Fri, 24 May 2024 09:23:24 +0200 Subject: [PATCH] Change python files installation (#348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../fastcdr/idl/templates/TypesSwigInterface.stg | 10 +++++++++- .../eprosima/fastdds/idl/templates/SwigCMake.stg | 13 +++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 0283549f..cbd12bda 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -19,7 +19,15 @@ import "com/eprosima/fastdds/idl/templates/eprosima.stg" main(ctx, definitions) ::= << $fileHeader(ctx=ctx, file=[ctx.filename, ".i"], description=["This header file contains the SWIG interface of the described types in the IDL file."])$ -%module $ctx.filename$ +%module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('$ctx.filename$.dll')\nif __package__ or '.' in __name__:\n from . import _$ctx.filename$Wrapper\nelse:\n import _$ctx.filename$Wrapper") $ctx.filename$ + +// If using windows in debug, it would try to use python_d, which would not be found. +%begin %{ +#ifdef _MSC_VER +#define SWIG_PYTHON_INTERPRETER_NO_DEBUG +#endif +#include +%} // SWIG helper modules %include "stdint.i" diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg index 6de3bd8d..644720de 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg @@ -96,8 +96,6 @@ SET_SOURCE_FILES_PROPERTIES( USE_TARGET_INCLUDE_DIRECTORIES TRUE ) -set_property(SOURCE \${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "\${CMAKE_CURRENT_BINARY_DIR}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$") - SWIG_ADD_LIBRARY(\${\${PROJECT_NAME}_MODULE} TYPE SHARED LANGUAGE python @@ -114,11 +112,6 @@ target_link_libraries(\${\${PROJECT_NAME}_MODULE} \${PROJECT_NAME} ) -set_target_properties(\${\${PROJECT_NAME}_MODULE} - PROPERTIES LIBRARY_OUTPUT_DIRECTORY "\${CMAKE_CURRENT_BINARY_DIR}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$" - ) - - # 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 @@ -128,7 +121,7 @@ execute_process(COMMAND \${PYTHON_EXECUTABLE} -c "from distutils import sysconfi 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} + \${_REL_PYTHON_MODULE_PATH}$project.context.lastStructure.typeCode.namespaces : { ns | /$ns$}$/\${PROJECT_NAME} ) # Install @@ -137,8 +130,8 @@ install(TARGETS \${PROJECT_NAME} LIBRARY DESTINATION lib/ ARCHIVE DESTINATION lib/ ) -install(TARGETS \${\${PROJECT_NAME}_MODULE} DESTINATION \${PYTHON_MODULE_PATH}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$) +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}/$project.context.lastStructure.typeCode.namespaces : { ns | $ns$}; separator="/"$) +install(FILES \${support_files} DESTINATION \${PYTHON_MODULE_PATH} RENAME __init__.py) >>