Skip to content

Commit

Permalink
sync KDPySide2ModuleBuild.py and KDFixupShiboken2.py to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Winter committed Apr 9, 2024
1 parent 71c9437 commit 05bfd8b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cmake/KDAB/modules/KDFixupShiboken2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Renato Araujo Oliveira Filho <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
#

"""
Script to fix bugs in code generated by shiboken-generator vr2
"""

import sys
import re


def removeExtraNamespaceForDefaultEnumValue(filename):
"""
Remove namespace from default flag value
this is a shiboken2 bug fixed on shiboken6
"""
regex = re.compile(r"\s=\s[^\s]+::{}")
newContent = ""
with open(filename, encoding='utf-8') as f:
for line in f:
newContent += re.sub(regex, ' = {}', line)

with open(filename, "w", encoding='utf-8') as f:
f.write(newContent)


# Usage: <script> <list-of-files>
# It will fix the file inplace
if __name__ == '__main__':
for fileToFix in sys.argv[1:]:
print("Fixup: {}".format(fileToFix))
removeExtraNamespaceForDefaultEnumValue(fileToFix)
1 change: 1 addition & 0 deletions cmake/KDAB/modules/KDPySide2ModuleBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ macro(
$<TARGET_PROPERTY:Shiboken2::shiboken,LOCATION> ${GENERATOR_EXTRA_FLAGS} ${globalInclude}
--include-paths=${shiboken_include_dirs} --typesystem-paths=${shiboken_typesystem_dirs}
${shiboken_framework_include_dirs_option} --output-directory=${CMAKE_CURRENT_BINARY_DIR} ${typesystemXML}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/KDFixupShiboken2.py ${outputSource}
DEPENDS ${typesystemXML} ${dependsArg}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running generator for ${libraryName} binding..."
Expand Down

0 comments on commit 05bfd8b

Please sign in to comment.