From 02d38db577593f40f5a2d37ec5e7874d4f6e333a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 21 Oct 2022 16:32:03 +0200 Subject: [PATCH] Fix about fix_swig_imports.py, useless or not working with swig 4, but needed by swig 3 fix_swig_imports.py cleans pcbnew.py, but the section to clean does not exist in swig 4, only in swig 3. --- pcbnew/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index c57e4dbfad..6c6be92f2f 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -437,6 +437,13 @@ if( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/doxygen-xml ) set( SWIG_OPTS ${SWIG_OPTS} -I${CMAKE_CURRENT_BINARY_DIR}/docstrings ) endif() +# This command is needed only with SWIG version < 4 to disable a python section "def swig_import_helper()" +# found at the beginning of pcbnew.py, but not longer existing in SWIG version >= 4 +if( ${SWIG_VERSION} VERSION_LESS 4.0.0 ) + set( OPT_CMD COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py ) +endif() + + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py @@ -487,12 +494,8 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx ${CMAKE_SOURCE_DIR}/pcbnew/python/swig/pcbnew.i - # was needed only with SWIG version < 4 to disable a python section "def swig_import_helper()" - # found in pcbnew.py but not existing in SWIG version >= 4 - # So it is left here for documentation purpose - #COMMAND ${PYTHON_EXECUTABLE} - # ${CMAKE_SOURCE_DIR}/tools/build/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py - + # Optional command for SWIG version < 4 to disable a python section "def swig_import_helper()" + ${OPT_CMD} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )