mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[sipify] use configuration file for SIP sources (*.sip.in)
to allow preprocessing the files to handle version specific features such as template based classes documentation in 4.19.7+
This commit is contained in:
parent
5327978ecf
commit
1d4e6a820a
@ -704,7 +704,7 @@ IF (WITH_CORE AND WITH_BINDINGS)
|
||||
INCLUDE(PyQtMacros)
|
||||
INCLUDE(SIPMacros)
|
||||
|
||||
SET(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/python/core)
|
||||
SET(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
|
||||
SET(SIP_CONCAT_PARTS 4)
|
||||
|
||||
IF (NOT BINDINGS_GLOBAL_INSTALL)
|
||||
|
@ -42,7 +42,7 @@ SET(SIP_DISABLE_FEATURES)
|
||||
SET(SIP_EXTRA_OPTIONS)
|
||||
SET(SIP_EXTRA_OBJECTS)
|
||||
|
||||
MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
|
||||
MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP SIP_FILES CPP_FILES)
|
||||
STRING(REPLACE "." "/" _x ${MODULE_NAME})
|
||||
GET_FILENAME_COMPONENT(_parent_module_path ${_x} PATH)
|
||||
GET_FILENAME_COMPONENT(_child_module_name ${_x} NAME)
|
||||
@ -52,13 +52,19 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
|
||||
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}) # Output goes in this dir.
|
||||
|
||||
# If this is not need anymore (using input configuration file for SIP modules)
|
||||
# Then SIP could build against the file in the source rather than in CMake current directory
|
||||
# and thus remove the 2 extras includes:
|
||||
# - hereafter in the custom command: -I ${CMAKE_CURRENT_SOURCE_DIR}/${_module_path}
|
||||
# - in top CMakeLists.txt in SIP_INCLUDES declaraiton the core part
|
||||
# If this is not need anymore (using input configuration file for SIP files)
|
||||
# SIP could be run in the source rather than in binary directory
|
||||
SET(_configured_module_sip ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}/${_module_path}.sip)
|
||||
CONFIGURE_FILE(${_abs_module_sip}.in ${_configured_module_sip})
|
||||
FOREACH (_sip_file ${SIP_FILES})
|
||||
GET_FILENAME_COMPONENT(_sip_file_path ${_sip_file} PATH)
|
||||
GET_FILENAME_COMPONENT(_sip_file_name_we ${_sip_file} NAME_WE)
|
||||
FILE(RELATIVE_PATH _sip_file_relpath ${CMAKE_CURRENT_SOURCE_DIR} "${_sip_file_path}/${_sip_file_name_we}")
|
||||
SET(_out_sip_file "${CMAKE_CURRENT_BINARY_DIR}/${_sip_file_relpath}.sip")
|
||||
CONFIGURE_FILE(${_sip_file} ${_out_sip_file})
|
||||
MESSAGE(${_sip_file})
|
||||
MESSAGE(${_out_sip_file})
|
||||
ENDFOREACH (_sip_file)
|
||||
|
||||
|
||||
SET(_sip_includes)
|
||||
FOREACH (_inc ${SIP_INCLUDES})
|
||||
@ -107,7 +113,7 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP CPP_FILES)
|
||||
ADD_DEFINITIONS( /bigobj )
|
||||
ENDIF(MSVC)
|
||||
|
||||
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})
|
||||
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_BINARY_SOURCE_DIR}/${_module_path} ${_sip_includes} ${_configured_module_sip})
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${_sip_output_files}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo ${message}
|
||||
|
@ -171,16 +171,20 @@ IF(NOT QT_MOBILITY_LOCATION_FOUND)
|
||||
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION)
|
||||
ENDIF(NOT QT_MOBILITY_LOCATION_FOUND)
|
||||
|
||||
# SIP 4.19.7+ can prepend auto-generated Python signature to existing Docstrings
|
||||
# SIP 4.19.7+ can:
|
||||
# * prepend auto-generated Python signature to existing Docstrings
|
||||
# * document template based classes
|
||||
SET(DOCSTRINGSTEMPLATE "//")
|
||||
IF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
|
||||
SET(DEFAULTDOCSTRINGSIGNATURE "%DefaultDocstringSignature \"prepended\"")
|
||||
SET(DOCSTRINGSTEMPLATE "")
|
||||
ENDIF(${SIP_VERSION_STR} VERSION_GREATER 4.19.6)
|
||||
|
||||
# core module
|
||||
FILE(GLOB_RECURSE sip_files_core core/*.sip)
|
||||
FILE(GLOB_RECURSE sip_files_core core/*.sip core/*.sip.in)
|
||||
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})
|
||||
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.core.api)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip cpp_files)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip "${sip_files_core}" cpp_files)
|
||||
BUILD_SIP_PYTHON_MODULE(qgis._core core/core.sip ${cpp_files} "" qgis_core)
|
||||
SET(SIP_CORE_CPP_FILES ${cpp_files})
|
||||
|
||||
@ -195,7 +199,7 @@ SET(PY_MODULES core analysis)
|
||||
IF (WITH_GUI)
|
||||
SET(PY_MODULES ${PY_MODULES} gui)
|
||||
|
||||
FILE(GLOB_RECURSE sip_files_gui gui/*.sip)
|
||||
FILE(GLOB_RECURSE sip_files_gui gui/*.sip gui/*.sip.in)
|
||||
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_gui})
|
||||
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.gui.api)
|
||||
|
||||
@ -206,7 +210,7 @@ IF (WITH_GUI)
|
||||
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QSCI_SIP)
|
||||
ENDIF(QSCI_SIP_DIR)
|
||||
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._gui gui/gui.sip cpp_files)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._gui gui/gui.sip "${sip_files_gui}" cpp_files)
|
||||
BUILD_SIP_PYTHON_MODULE(qgis._gui gui/gui.sip ${cpp_files} "" qgis_core qgis_gui)
|
||||
ENDIF (WITH_GUI)
|
||||
|
||||
@ -219,10 +223,10 @@ IF (WITH_SERVER AND WITH_SERVER_PLUGINS)
|
||||
|
||||
SET(PY_MODULES ${PY_MODULES} server)
|
||||
|
||||
FILE(GLOB_RECURSE sip_files_server server/*.sip)
|
||||
FILE(GLOB_RECURSE sip_files_server server/*.sip server/*.sip.in)
|
||||
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_server})
|
||||
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.server.api)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._server server/server.sip cpp_files)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._server server/server.sip "${sip_files_server}" cpp_files)
|
||||
BUILD_SIP_PYTHON_MODULE(qgis._server server/server.sip ${cpp_files} "" qgis_core qgis_server)
|
||||
ENDIF (WITH_SERVER AND WITH_SERVER_PLUGINS)
|
||||
|
||||
@ -243,17 +247,10 @@ INCLUDE_DIRECTORIES(BEFORE
|
||||
)
|
||||
|
||||
# analysis module
|
||||
FILE(GLOB sip_files_analysis
|
||||
analysis/*.sip
|
||||
analysis/raster/*.sip
|
||||
analysis/vector/*.sip
|
||||
analysis/network/*.sip
|
||||
analysis/interpolation/*.sip
|
||||
analysis/openstreetmap/*.sip
|
||||
)
|
||||
FILE(GLOB_RECURSE sip_files_analysis analysis/*.sip analysis/*.sip.in)
|
||||
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_analysis})
|
||||
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -o -a ${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._analysis analysis/analysis.sip cpp_files)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._analysis analysis/analysis.sip "${sip_files_analysis}" cpp_files)
|
||||
BUILD_SIP_PYTHON_MODULE(qgis._analysis analysis/analysis.sip ${cpp_files} "" qgis_core qgis_analysis)
|
||||
|
||||
SET(QGIS_PYTHON_DIR ${PYTHON_SITE_PACKAGES_DIR}/qgis)
|
||||
|
@ -23,8 +23,9 @@ use constant CODE_SNIPPET_CPP => 31;
|
||||
|
||||
# read arguments
|
||||
my $debug = 0;
|
||||
my $SUPPORT_TEMPLATE_DOCSTRING = 0;
|
||||
die("usage: $0 [-debug] [-template-doc] headerfile\n") unless GetOptions ("debug" => \$debug, "template-doc" => \$SUPPORT_TEMPLATE_DOCSTRING) && @ARGV == 1;
|
||||
#my $SUPPORT_TEMPLATE_DOCSTRING = 0;
|
||||
#die("usage: $0 [-debug] [-template-doc] headerfile\n") unless GetOptions ("debug" => \$debug, "template-doc" => \$SUPPORT_TEMPLATE_DOCSTRING) && @ARGV == 1;
|
||||
die("usage: $0 [-debug] headerfile\n") unless GetOptions ("debug" => \$debug) && @ARGV == 1;
|
||||
my $headerfile = $ARGV[0];
|
||||
|
||||
# read file
|
||||
@ -967,9 +968,10 @@ while ($LINE_IDX < $LINE_COUNT){
|
||||
$LINE =~ s/^(\s*struct )\w+_EXPORT (.+)$/$1$2/;
|
||||
|
||||
# Skip comments
|
||||
if ( $SUPPORT_TEMPLATE_DOCSTRING == 1 &&
|
||||
$LINE =~ m/^\s*typedef\s+\w+\s*<\s*\w+\s*>\s+\w+\s+.*SIP_DOC_TEMPLATE/ ) {
|
||||
$COMMENT_TEMPLATE_DOCSTRING = 0;
|
||||
if ( $LINE =~ m/^\s*typedef\s+\w+\s*<\s*\w+\s*>\s+\w+\s+.*SIP_DOC_TEMPLATE/ ) {
|
||||
# support Docstring for template based classes in SIP 4.19.7+
|
||||
$COMMENT_TEMPLATE_DOCSTRING = 1;
|
||||
}
|
||||
elsif ( $LINE =~ m/\/\// ||
|
||||
$LINE =~ m/^\s*typedef / ||
|
||||
@ -1049,7 +1051,9 @@ while ($LINE_IDX < $LINE_COUNT){
|
||||
else {
|
||||
dbg_info('writing comment');
|
||||
if ( $COMMENT !~ m/^\s*$/ ){
|
||||
write_output("CM1", "%Docstring\n");
|
||||
my $doc_prepend = "";
|
||||
$doc_prepend = "\@TEMPLATE_DOCSTRING\@" if $COMMENT_TEMPLATE_DOCSTRING == 1;
|
||||
write_output("CM1", "$doc_prepend%Docstring\n");
|
||||
my @comment_lines = split /\n/, $COMMENT;
|
||||
foreach my $comment_line (@comment_lines) {
|
||||
# if ( $RETURN_TYPE ne '' && $comment_line =~ m/^\s*\.\. \w/ ){
|
||||
@ -1057,14 +1061,14 @@ while ($LINE_IDX < $LINE_COUNT){
|
||||
# write_output("CM5", ":rtype: $RETURN_TYPE\n\n");
|
||||
# $RETURN_TYPE = '';
|
||||
# }
|
||||
write_output("CM2", "$comment_line\n");
|
||||
write_output("CM2", "$doc_prepend$comment_line\n");
|
||||
# if ( $RETURN_TYPE ne '' && $comment_line =~ m/:return:/ ){
|
||||
# # return type must be added before any other paragraph-level markup
|
||||
# write_output("CM5", ":rtype: $RETURN_TYPE\n\n");
|
||||
# $RETURN_TYPE = '';
|
||||
# }
|
||||
}
|
||||
write_output("CM4", "%End\n");
|
||||
write_output("CM4", "$doc_prepend%End\n");
|
||||
}
|
||||
# if ( $RETURN_TYPE ne '' ){
|
||||
# write_output("CM3", "\n:rtype: $RETURN_TYPE\n");
|
||||
|
@ -15,15 +15,15 @@
|
||||
###########################################################################
|
||||
set -e
|
||||
|
||||
TEMPLATE_DOC=""
|
||||
while :; do
|
||||
case $1 in
|
||||
-t|--template-doc) TEMPLATE_DOC="-template-doc"
|
||||
;;
|
||||
*) break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
# TEMPLATE_DOC=""
|
||||
# while :; do
|
||||
# case $1 in
|
||||
# -t|--template-doc) TEMPLATE_DOC="-template-doc"
|
||||
# ;;
|
||||
# *) break
|
||||
# esac
|
||||
# shift
|
||||
# done
|
||||
|
||||
DIR=$(git rev-parse --show-toplevel)
|
||||
|
||||
@ -40,14 +40,14 @@ count=0
|
||||
modules=(core gui analysis server)
|
||||
for module in "${modules[@]}"; do
|
||||
while read -r sipfile; do
|
||||
echo "$sipfile"
|
||||
echo "$sipfile.in"
|
||||
header=$(${GP}sed -E 's/(.*)\.sip/src\/\1.h/' <<< $sipfile)
|
||||
if [ ! -f $header ]; then
|
||||
echo "*** Missing header: $header for sipfile $sipfile"
|
||||
else
|
||||
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
|
||||
mkdir -p python/$path
|
||||
./scripts/sipify.pl $TEMPLATE_DOC $header > python/$sipfile
|
||||
./scripts/sipify.pl $header > python/$sipfile.in
|
||||
fi
|
||||
count=$((count+1))
|
||||
done < <( ${GP}sed -n -r "s/^%Include (.*\.sip)/${module}\/\1/p" python/${module}/${module}_auto.sip )
|
||||
|
Loading…
x
Reference in New Issue
Block a user