Skip to content

Commit 880d853

Browse files
authoredJan 10, 2018
detect SIP version to add DefaultDocstringSignature directive (#6030)
* detect SIP version to add DefaultDocstringSignature directive SIP doesn't handle any kind of preprocessing, so there's no better solution than configuring the SIP files from CMake. SIP 4.19.7+ supports %DefaultDocstringSignature to prepend auto-generated Python signature to existing Docstrings
1 parent d6b2749 commit 880d853

File tree

7 files changed

+24
-3
lines changed

7 files changed

+24
-3
lines changed
 

‎CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ IF (WITH_CORE AND WITH_BINDINGS)
704704
INCLUDE(PyQtMacros)
705705
INCLUDE(SIPMacros)
706706

707-
SET(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
707+
SET(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/python/core)
708708
SET(SIP_CONCAT_PARTS 4)
709709

710710
IF (NOT BINDINGS_GLOBAL_INSTALL)

‎cmake/SIPMacros.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
5252

5353
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}) # Output goes in this dir.
5454

55+
# If this is not need anymore (using input configuration file for SIP modules)
56+
# Then SIP could build against the file in the source rather than in CMake current directory
57+
# and thus remove the 2 extras includes:
58+
# - hereafter in the custom command: -I ${CMAKE_CURRENT_SOURCE_DIR}/${_module_path}
59+
# - in top CMakeLists.txt in SIP_INCLUDES declaraiton the core part
60+
SET(_configured_module_sip ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}/${_module_path}.sip)
61+
CONFIGURE_FILE(${_abs_module_sip}.in ${_configured_module_sip})
62+
5563
SET(_sip_includes)
5664
FOREACH (_inc ${SIP_INCLUDES})
5765
GET_FILENAME_COMPONENT(_abs_inc ${_inc} ABSOLUTE)
@@ -99,13 +107,14 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
99107
ADD_DEFINITIONS( /bigobj )
100108
ENDIF(MSVC)
101109

102-
SET(SIPCMD ${SIP_BINARY_PATH} ${_sip_tags} -w -e ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip})
110+
SET(SIPCMD ${SIP_BINARY_PATH} ${_sip_tags} -w -e ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} -I ${CMAKE_CURRENT_SOURCE_DIR}/${_module_path} ${_sip_includes} ${_configured_module_sip})
103111
ADD_CUSTOM_COMMAND(
104112
OUTPUT ${_sip_output_files}
105113
COMMAND ${CMAKE_COMMAND} -E echo ${message}
106114
COMMAND ${CMAKE_COMMAND} -E touch ${_sip_output_files}
107115
COMMAND ${SIPCMD}
108-
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
116+
MAIN_DEPENDENCY ${_configured_module_sip}
117+
DEPENDS ${SIP_EXTRA_FILES_DEPEND}
109118
VERBATIM
110119
)
111120

‎python/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ IF(NOT QT_MOBILITY_LOCATION_FOUND)
171171
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION)
172172
ENDIF(NOT QT_MOBILITY_LOCATION_FOUND)
173173

174+
# SIP 4.19.7+ can prepend auto-generated Python signature to existing Docstrings
175+
IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
176+
SET(DEFAULTDOCSTRINGSIGNATURE "%DefaultDocstringSignature \"prepended\"")
177+
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
178+
174179
# core module
175180
FILE(GLOB_RECURSE sip_files_core core/*.sip)
176181
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})

‎python/analysis/analysis.sip renamed to ‎python/analysis/analysis.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
%Module(name=qgis._analysis,
22
keyword_arguments="All")
33

4+
${DEFAULTDOCSTRINGSIGNATURE}
5+
46
%Import QtCore/QtCoremod.sip
57
%Import QtGui/QtGuimod.sip
68
%Import QtXml/QtXmlmod.sip

‎python/core/core.sip renamed to ‎python/core/core.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
%Module(name=qgis._core,
22
keyword_arguments="All")
33

4+
${DEFAULTDOCSTRINGSIGNATURE}
5+
46
%ModuleCode
57

68
#include "qgsexception.h"

‎python/gui/gui.sip renamed to ‎python/gui/gui.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
%Module(name=qgis._gui,
22
keyword_arguments="All")
33

4+
${DEFAULTDOCSTRINGSIGNATURE}
5+
46
%Feature HAVE_QSCI_SIP
57

68
%Import core/core.sip

‎python/server/server.sip renamed to ‎python/server/server.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
%Module(name=qgis._server,
22
keyword_arguments="All")
33

4+
${DEFAULTDOCSTRINGSIGNATURE}
45

56
%Import QtCore/QtCoremod.sip
67
%Import QtGui/QtGuimod.sip

0 commit comments

Comments
 (0)
Please sign in to comment.