mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
api(Deprecated): Generate always /Deprecated/ annotation with text
Use cmake to remove text when SIP version is less than 6.9.0
This commit is contained in:
parent
ed64834106
commit
51dc2ec2ac
@ -63,6 +63,14 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP SIP_FILES CPP_FILES
|
|||||||
FILE(RELATIVE_PATH _sip_file_relpath ${BINDING_FILES_ROOT_DIR} "${_sip_file_path}/${_sip_file_name_we}")
|
FILE(RELATIVE_PATH _sip_file_relpath ${BINDING_FILES_ROOT_DIR} "${_sip_file_path}/${_sip_file_name_we}")
|
||||||
SET(_out_sip_file "${CMAKE_CURRENT_BINARY_DIR}/${_sip_file_relpath}.sip")
|
SET(_out_sip_file "${CMAKE_CURRENT_BINARY_DIR}/${_sip_file_relpath}.sip")
|
||||||
CONFIGURE_FILE(${_sip_file} ${_out_sip_file})
|
CONFIGURE_FILE(${_sip_file} ${_out_sip_file})
|
||||||
|
|
||||||
|
# Deprecated annotation supports message only since version 6.9.0
|
||||||
|
if(${SIP_VERSION_STR} VERSION_LESS 6.9.0)
|
||||||
|
file(READ ${_out_sip_file} _content)
|
||||||
|
string(REGEX REPLACE "([/,])Deprecated=\"[^\"]*\"([/,])" "\\1Deprecated\\2" _content "${_content}")
|
||||||
|
file(GENERATE OUTPUT ${_out_sip_file} CONTENT "${_content}")
|
||||||
|
endif()
|
||||||
|
|
||||||
ENDFOREACH (_sip_file)
|
ENDFOREACH (_sip_file)
|
||||||
|
|
||||||
SET(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
|
SET(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
|
||||||
|
@ -42,7 +42,6 @@ class MultiLineType(Enum):
|
|||||||
parser = argparse.ArgumentParser(description="Convert header file to SIP and Python")
|
parser = argparse.ArgumentParser(description="Convert header file to SIP and Python")
|
||||||
parser.add_argument("-debug", action="store_true", help="Enable debug mode")
|
parser.add_argument("-debug", action="store_true", help="Enable debug mode")
|
||||||
parser.add_argument("-qt6", action="store_true", help="Enable Qt6 mode")
|
parser.add_argument("-qt6", action="store_true", help="Enable Qt6 mode")
|
||||||
parser.add_argument("-generate_deprecated_message", action="store_true", help="Generate sip files with deprecated messages (supported only in SIP > 6.9.0)")
|
|
||||||
parser.add_argument("-sip_output", help="SIP output file")
|
parser.add_argument("-sip_output", help="SIP output file")
|
||||||
parser.add_argument("-python_output", help="Python output file")
|
parser.add_argument("-python_output", help="Python output file")
|
||||||
parser.add_argument("-class_map", help="Class map file")
|
parser.add_argument("-class_map", help="Class map file")
|
||||||
@ -80,7 +79,6 @@ class Context:
|
|||||||
self.debug: bool = False
|
self.debug: bool = False
|
||||||
self.is_qt6: bool = False
|
self.is_qt6: bool = False
|
||||||
self.header_file: str = ""
|
self.header_file: str = ""
|
||||||
self.generate_deprecated_message = False
|
|
||||||
self.current_line: str = ""
|
self.current_line: str = ""
|
||||||
self.sip_run: bool = False
|
self.sip_run: bool = False
|
||||||
self.header_code: bool = False
|
self.header_code: bool = False
|
||||||
@ -147,7 +145,6 @@ class Context:
|
|||||||
CONTEXT = Context()
|
CONTEXT = Context()
|
||||||
CONTEXT.debug = args.debug
|
CONTEXT.debug = args.debug
|
||||||
CONTEXT.is_qt6 = args.qt6
|
CONTEXT.is_qt6 = args.qt6
|
||||||
CONTEXT.generate_deprecated_message = args.generate_deprecated_message
|
|
||||||
CONTEXT.header_file = args.headerfile
|
CONTEXT.header_file = args.headerfile
|
||||||
CONTEXT.input_lines = input_lines
|
CONTEXT.input_lines = input_lines
|
||||||
CONTEXT.line_count = len(input_lines)
|
CONTEXT.line_count = len(input_lines)
|
||||||
@ -891,7 +888,9 @@ def process_doxygen_line(line: str) -> str:
|
|||||||
version = version[:-1]
|
version = version[:-1]
|
||||||
depr_line = f"\n.. deprecated:: {version}"
|
depr_line = f"\n.. deprecated:: {version}"
|
||||||
message = deprecated_match.group("DEPR_MESSAGE")
|
message = deprecated_match.group("DEPR_MESSAGE")
|
||||||
CONTEXT.deprecated_message = f"Since {version}. {process_deprecated_message(message)}"
|
CONTEXT.deprecated_message = (
|
||||||
|
f"Since {version}. {process_deprecated_message(message)}"
|
||||||
|
)
|
||||||
if message:
|
if message:
|
||||||
depr_line += "\n"
|
depr_line += "\n"
|
||||||
depr_line += "\n".join(f"\n {_m}" for _m in message.split("\n"))
|
depr_line += "\n".join(f"\n {_m}" for _m in message.split("\n"))
|
||||||
@ -1169,11 +1168,6 @@ def fix_annotations(line):
|
|||||||
CONTEXT.skipped_params_out.append(param)
|
CONTEXT.skipped_params_out.append(param)
|
||||||
dbg_info(f"caught removed param: {CONTEXT.skipped_params_out[-1]}")
|
dbg_info(f"caught removed param: {CONTEXT.skipped_params_out[-1]}")
|
||||||
|
|
||||||
if "SIP_DEPRECATED" in line:
|
|
||||||
|
|
||||||
if CONTEXT.deprecated_message is None:
|
|
||||||
exit_with_error(f"Error in file {CONTEXT.header_file}: missing deprecated message for SIP_DEPRECATED instruction on line {CONTEXT.line_idx}. Please add \\deprecated instruction")
|
|
||||||
|
|
||||||
# Printed annotations
|
# Printed annotations
|
||||||
replacements = {
|
replacements = {
|
||||||
r"//\s*SIP_ABSTRACT\b": "/Abstract/",
|
r"//\s*SIP_ABSTRACT\b": "/Abstract/",
|
||||||
@ -1206,11 +1200,7 @@ def fix_annotations(line):
|
|||||||
# these have no effect (and aren't required) on sip >= 6
|
# these have no effect (and aren't required) on sip >= 6
|
||||||
replacements[r"SIP_THROW\(\s*([\w\s,]+?)\s*\)"] = ""
|
replacements[r"SIP_THROW\(\s*([\w\s,]+?)\s*\)"] = ""
|
||||||
|
|
||||||
if CONTEXT.generate_deprecated_message:
|
replacements[r"\bSIP_DEPRECATED\b"] = f'/Deprecated="{CONTEXT.deprecated_message}"/'
|
||||||
# check deprecated message is not empty
|
|
||||||
replacements[r"\bSIP_DEPRECATED\b"] = f'/Deprecated="{CONTEXT.deprecated_message}"/'
|
|
||||||
else:
|
|
||||||
replacements[r"\bSIP_DEPRECATED\b"] = f"/Deprecated/"
|
|
||||||
|
|
||||||
for _pattern, replacement in replacements.items():
|
for _pattern, replacement in replacements.items():
|
||||||
line = re.sub(_pattern, replacement, line)
|
line = re.sub(_pattern, replacement, line)
|
||||||
@ -1218,9 +1208,8 @@ def fix_annotations(line):
|
|||||||
# Combine multiple annotations
|
# Combine multiple annotations
|
||||||
while True:
|
while True:
|
||||||
new_line = re.sub(
|
new_line = re.sub(
|
||||||
r'/([\w,]+(="?[^"]+"?)?)/\s*/([\w,]+(="?[^"]+"?)?]?)/',
|
r'/([\w,]+(="?[^"]+"?)?)/\s*/([\w,]+(="?[^"]+"?)?]?)/', r"/\1,\3/", line
|
||||||
r"/\1,\3/",
|
)
|
||||||
line)
|
|
||||||
if new_line == line:
|
if new_line == line:
|
||||||
break
|
break
|
||||||
line = new_line
|
line = new_line
|
||||||
|
@ -16,15 +16,11 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
CLASS_MAP=0
|
CLASS_MAP=0
|
||||||
DEPRECATED_MESSAGE=0
|
while getopts "m" opt; do
|
||||||
while getopts "md" opt; do
|
|
||||||
case $opt in
|
case $opt in
|
||||||
m)
|
m)
|
||||||
CLASS_MAP=1
|
CLASS_MAP=1
|
||||||
;;
|
;;
|
||||||
d)
|
|
||||||
DEPRECATED_MESSAGE=1
|
|
||||||
;;
|
|
||||||
\?)
|
\?)
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -54,11 +50,6 @@ fi
|
|||||||
pids=()
|
pids=()
|
||||||
iPid=0
|
iPid=0
|
||||||
|
|
||||||
GENERATE_DEPRECATED_MESSAGE=""
|
|
||||||
if [[ ${DEPRECATED_MESSAGE} -eq 1 ]]; then
|
|
||||||
GENERATE_DEPRECATED_MESSAGE="-generate_deprecated_message"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for root_dir in python python/PyQt6; do
|
for root_dir in python python/PyQt6; do
|
||||||
|
|
||||||
if [[ $root_dir == "python/PyQt6" ]]; then
|
if [[ $root_dir == "python/PyQt6" ]]; then
|
||||||
@ -95,7 +86,7 @@ It is not aimed to be manually edited
|
|||||||
if [[ ${CLASS_MAP} -eq 1 ]]; then
|
if [[ ${CLASS_MAP} -eq 1 ]]; then
|
||||||
CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml"
|
CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml"
|
||||||
fi
|
fi
|
||||||
./scripts/sipify.py $IS_QT6 $GENERATE_DEPRECATED_MESSAGE -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} &
|
./scripts/sipify.py $IS_QT6 -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} &
|
||||||
pids[iPid]=$!
|
pids[iPid]=$!
|
||||||
iPid=$((iPid+1))
|
iPid=$((iPid+1))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user