diff options
Diffstat (limited to 'sources/shiboken6')
| -rw-r--r-- | sources/shiboken6/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | sources/shiboken6/cmake/ShibokenHelpers.cmake | 78 | ||||
| -rw-r--r-- | sources/shiboken6/cmake/ShibokenSetup.cmake | 4 | ||||
| -rw-r--r-- | sources/shiboken6/data/Shiboken6ToolsMacros.cmake | 187 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 6 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 12 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 2 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/sbkfeature_base.cpp | 7 | ||||
| -rw-r--r-- | sources/shiboken6/tests/CMakeLists.txt | 12 |
10 files changed, 27 insertions, 296 deletions
diff --git a/sources/shiboken6/CMakeLists.txt b/sources/shiboken6/CMakeLists.txt index efc2ec7cf..5efa9633e 100644 --- a/sources/shiboken6/CMakeLists.txt +++ b/sources/shiboken6/CMakeLists.txt @@ -10,22 +10,16 @@ set(CMAKE_BUILD_TYPE Release CACHE STRING "Build Type") include(".cmake.conf") project(shiboken6) + include(cmake/ShibokenSetup.cmake) get_rpath_base_token(base) set(CMAKE_INSTALL_RPATH ${base}/) -if(SHIBOKEN_BUILD_TOOLS) - add_subdirectory(ApiExtractor) # Uses libclang - add_subdirectory(generator) # Uses ApiExtractor And QtCore -endif() - -if(SHIBOKEN_BUILD_LIBS) - add_subdirectory(libshiboken) # Uses Python - add_subdirectory(shibokenmodule) # Uses libshiboken - add_subdirectory(data) -endif() +add_subdirectory(libshiboken) # Uses Python +add_subdirectory(shibokenmodule) # Uses libshiboken +add_subdirectory(data) add_subdirectory(doc) diff --git a/sources/shiboken6/cmake/ShibokenHelpers.cmake b/sources/shiboken6/cmake/ShibokenHelpers.cmake index 0e993fadb..571ae6656 100644 --- a/sources/shiboken6/cmake/ShibokenHelpers.cmake +++ b/sources/shiboken6/cmake/ShibokenHelpers.cmake @@ -180,41 +180,6 @@ macro(set_python_config_suffix) endif() endmacro() -macro(setup_clang) - # Find libclang using the environment variables LLVM_INSTALL_DIR, - # CLANG_INSTALL_DIR using standard cmake. - # Use CLANG_INCLUDE_DIRS and link to libclang. - if(DEFINED ENV{LLVM_INSTALL_DIR}) - list(PREPEND CMAKE_PREFIX_PATH "$ENV{LLVM_INSTALL_DIR}") - list(PREPEND CMAKE_FIND_ROOT_PATH "$ENV{LLVM_INSTALL_DIR}") - elseif(DEFINED ENV{CLANG_INSTALL_DIR}) - list(PREPEND CMAKE_PREFIX_PATH "$ENV{CLANG_INSTALL_DIR}") - list(PREPEND CMAKE_FIND_ROOT_PATH "$ENV{CLANG_INSTALL_DIR}") - endif() - - find_package(Clang CONFIG REQUIRED) - # Need to explicitly handle the version check, because the Clang package doesn't. - set(REQUIRED_LLVM "18.0") - - if (LLVM_PACKAGE_VERSION AND LLVM_PACKAGE_VERSION VERSION_LESS "${REQUIRED_LLVM}") - message(WARNING "You need LLVM version ${REQUIRED_LLVM} or greater to build PySide " - "without issues, and ${LLVM_PACKAGE_VERSION} was found. " - "A lower version might case problems, specially on Windows.") - # Exception to enable Yocto builds (Kirkstone) - 6.8.x - set(REQUIRED_LLVM "14.0") - if (LLVM_PACKAGE_VERSION AND LLVM_PACKAGE_VERSION VERSION_LESS "${REQUIRED_LLVM}") - message(FATAL_ERROR "Using a LLVM version ${REQUIRED_LLVM} is the minimum allowed " - "to work pyside in some systems, however ${LLVM_PACKAGE_VERSION} was found.") - endif() - endif() - - # CLANG_LIBRARY is read out from the cmake cache to deploy libclang - get_target_property(CLANG_BUILD_TYPE libclang IMPORTED_CONFIGURATIONS) - get_target_property(CLANG_LIBRARY_NAME libclang IMPORTED_LOCATION_${CLANG_BUILD_TYPE}) - set(CLANG_LIBRARY "${CLANG_LIBRARY_NAME}" CACHE FILEPATH "libclang") - message(STATUS "CLANG: ${Clang_DIR}, ${CLANG_LIBRARY} detected") -endmacro() - macro(set_quiet_build) # Don't display "up-to-date / install" messages when installing, to reduce visual clutter. set(CMAKE_INSTALL_MESSAGE NEVER) @@ -551,18 +516,6 @@ function(shiboken_internal_detect_if_cross_building) endfunction() function(shiboken_internal_decide_parts_to_build) - set(build_libs_default ON) - option(SHIBOKEN_BUILD_LIBS "Build shiboken libraries" ${build_libs_default}) - message(STATUS "SHIBOKEN_BUILD_LIBS: ${SHIBOKEN_BUILD_LIBS}") - - if(SHIBOKEN_IS_CROSS_BUILD) - set(build_tools_default OFF) - else() - set(build_tools_default ON) - endif() - option(SHIBOKEN_BUILD_TOOLS "Build shiboken tools" ${build_tools_default}) - message(STATUS "SHIBOKEN_BUILD_TOOLS: ${SHIBOKEN_BUILD_TOOLS}") - if(SHIBOKEN_IS_CROSS_BUILD) set(_shiboken_build_tests_default OFF) elseif(SHIBOKEN_BUILD_LIBS) @@ -573,23 +526,22 @@ function(shiboken_internal_decide_parts_to_build) endfunction() function(shiboken_internal_find_host_shiboken_tools) - if(SHIBOKEN_IS_CROSS_BUILD) - set(find_package_extra_args) - if(QFP_SHIBOKEN_HOST_PATH) - list(APPEND find_package_extra_args PATHS "${QFP_SHIBOKEN_HOST_PATH}/lib/cmake") - list(PREPEND CMAKE_FIND_ROOT_PATH "${QFP_SHIBOKEN_HOST_PATH}") - endif() - find_package( - Shiboken6Tools 6 CONFIG - ${find_package_extra_args} - ) + set(find_package_extra_args) + if(QFP_SHIBOKEN_HOST_PATH) + list(APPEND find_package_extra_args PATHS "${QFP_SHIBOKEN_HOST_PATH}/lib/cmake") + list(PREPEND CMAKE_FIND_ROOT_PATH "${QFP_SHIBOKEN_HOST_PATH}") + endif() + set(SHIBOKEN6TOOLS_SKIP_FIND_DEPENDENCIES TRUE) + find_package( + Shiboken6Tools 6 CONFIG + ${find_package_extra_args} + ) - if(NOT Shiboken6Tools_DIR) - message(FATAL_ERROR - "Shiboken6Tools package was not found. " - "Please set QFP_SHIBOKEN_HOST_PATH to the location where the Shiboken6Tools CMake " - "package is installed.") - endif() + if(NOT Shiboken6Tools_DIR AND QFP_SHIBOKEN_HOST_PATH) + message(FATAL_ERROR + "Shiboken6Tools package was not found. " + "Please set QFP_SHIBOKEN_HOST_PATH to the location where the Shiboken6Tools CMake " + "package is installed.") endif() endfunction() diff --git a/sources/shiboken6/cmake/ShibokenSetup.cmake b/sources/shiboken6/cmake/ShibokenSetup.cmake index 32823d9fa..73030bc90 100644 --- a/sources/shiboken6/cmake/ShibokenSetup.cmake +++ b/sources/shiboken6/cmake/ShibokenSetup.cmake @@ -33,10 +33,6 @@ else() shiboken_find_required_python() endif() -if(SHIBOKEN_BUILD_TOOLS) - setup_clang() -endif() - set(shiboken6_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") set(shiboken6_library_so_version "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}") diff --git a/sources/shiboken6/data/Shiboken6ToolsMacros.cmake b/sources/shiboken6/data/Shiboken6ToolsMacros.cmake deleted file mode 100644 index 2c1a8c786..000000000 --- a/sources/shiboken6/data/Shiboken6ToolsMacros.cmake +++ /dev/null @@ -1,187 +0,0 @@ -# Function to configure a binding project -function(shiboken_generator_create_binding) - set(options FORCE_LIMITED_API) - set(one_value_args - EXTENSION_TARGET - TYPESYSTEM_FILE - LIBRARY_TARGET) - set(multi_value_args - GENERATED_SOURCES - HEADERS - QT_MODULES - SHIBOKEN_EXTRA_OPTIONS) - - cmake_parse_arguments(PARSE_ARGV 0 arg - "${options}" - "${one_value_args}" - "${multi_value_args}") - - # Validate required arguments - foreach(req EXTENSION_TARGET GENERATED_SOURCES HEADERS TYPESYSTEM_FILE LIBRARY_TARGET) - if(NOT DEFINED arg_${req}) - message(FATAL_ERROR "shiboken_generator_create_binding: ${req} is required") - endif() - endforeach() - - get_target_property(shiboken_include_dirs Shiboken6::libshiboken INTERFACE_INCLUDE_DIRECTORIES) - - # Get Shiboken path based on build type - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - get_target_property(shiboken_path Shiboken6::shiboken6 IMPORTED_LOCATION_DEBUG) - else() - get_target_property(shiboken_path Shiboken6::shiboken6 IMPORTED_LOCATION_RELEASE) - endif() - - # Basic shiboken options - set(shiboken_options - --generator-set=shiboken - --enable-parent-ctor-heuristic - --enable-return-value-heuristic - --use-isnull-as-nb_nonzero - --avoid-protected-hack - -I${CMAKE_CURRENT_SOURCE_DIR} - -T${CMAKE_CURRENT_SOURCE_DIR} - --output-directory=${CMAKE_CURRENT_BINARY_DIR}) - - # Add extra options if specified - if(arg_SHIBOKEN_EXTRA_OPTIONS) - list(APPEND shiboken_options ${arg_SHIBOKEN_EXTRA_OPTIONS}) - endif() - - # Add Qt/PySide specific configurations only if Qt modules are specified - if(arg_QT_MODULES) - # Get Qt include directories - set(qt_include_dirs "") - foreach(module ${arg_QT_MODULES}) - get_property(module_includes TARGET Qt6::${module} PROPERTY - INTERFACE_INCLUDE_DIRECTORIES) - list(APPEND qt_include_dirs ${module_includes}) - - # Check each module for framework on macOS - if(APPLE) - get_target_property(is_framework Qt6::${module} FRAMEWORK) - if(is_framework) - get_target_property(lib_location Qt6::${module} LOCATION) - get_filename_component(lib_dir "${lib_location}" DIRECTORY) - get_filename_component(framework_dir "${lib_dir}/../" ABSOLUTE) - list(APPEND shiboken_options "--framework-include-paths=${framework_dir}") - endif() - endif() - - # Add include paths to shiboken options - foreach(include_dir ${module_includes}) - list(APPEND shiboken_options "-I${include_dir}") - endforeach() - endforeach() - - get_target_property(pyside_include_dir PySide6::pyside6 INTERFACE_INCLUDE_DIRECTORIES) - - # Add PySide typesystems path - list(APPEND shiboken_options "-T${PYSIDE_TYPESYSTEMS}") - - # Enable PySide extensions - list(APPEND shiboken_options "--enable-pyside-extensions") - endif() - - # Generate binding sources - add_custom_command( - OUTPUT ${arg_GENERATED_SOURCES} - COMMAND "${shiboken_path}" - ${shiboken_options} ${arg_HEADERS} "${arg_TYPESYSTEM_FILE}" - DEPENDS ${arg_HEADERS} ${arg_TYPESYSTEM_FILE} - IMPLICIT_DEPENDS CXX ${arg_HEADERS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - COMMENT "Generating bindings for ${arg_EXTENSION_TARGET}" - ) - - # Create binding library - add_library(${arg_EXTENSION_TARGET} MODULE ${arg_GENERATED_SOURCES}) - - # set limited API - if(arg_FORCE_LIMITED_API OR FORCE_LIMITED_API) - target_compile_definitions(${arg_EXTENSION_TARGET} PRIVATE -DPy_LIMITED_API=0x030A0000) - endif() - - - # Configure include paths - target_include_directories( - ${arg_EXTENSION_TARGET} PRIVATE - ${SHIBOKEN_PYTHON_INCLUDE_DIRS} - ${shiboken_include_dirs} - ${CMAKE_CURRENT_SOURCE_DIR} - ) - - # Link with Python, Shiboken and C++ library - target_link_libraries( - ${arg_EXTENSION_TARGET} PRIVATE - Shiboken6::libshiboken - ${arg_LIBRARY_TARGET} - ) - - if(arg_QT_MODULES) - # Add Qt and PySide includes - target_include_directories( - ${arg_EXTENSION_TARGET} PRIVATE ${qt_include_dirs} - ) - target_include_directories( - ${arg_EXTENSION_TARGET} PRIVATE ${pyside_include_dir} - ) - - # Add PySide Qt module-specific includes and link libraries - foreach(module ${arg_QT_MODULES}) - target_include_directories( - ${arg_EXTENSION_TARGET} PRIVATE "${pyside_include_dir}/Qt${module}" - ) - target_link_libraries( - ${arg_EXTENSION_TARGET} PRIVATE Qt6::${module} - ) - endforeach() - - # Link base PySide6 library - target_link_libraries( - ${arg_EXTENSION_TARGET} PRIVATE PySide6::pyside6 - ) - - # Link PySide6 QML library if Qml module is used - if("Qml" IN_LIST arg_QT_MODULES) - target_link_libraries( - ${arg_EXTENSION_TARGET} PRIVATE PySide6::pyside6qml - ) - endif() - endif() - - # Configure target properties - set_target_properties( - ${arg_EXTENSION_TARGET} PROPERTIES - PREFIX "" - OUTPUT_NAME "${arg_EXTENSION_TARGET}${SHIBOKEN_PYTHON_EXTENSION_SUFFIX}" - ) - - # Platform specific settings - if(WIN32) - # Add Python libraries only on Windows - get_property(SHIBOKEN_PYTHON_LIBRARIES GLOBAL PROPERTY shiboken_python_libraries) - - target_link_libraries( - ${arg_EXTENSION_TARGET} PRIVATE "${SHIBOKEN_PYTHON_LIBRARIES}" - ) - - # Set Windows-specific suffix - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set_property( - TARGET ${arg_EXTENSION_TARGET} PROPERTY SUFFIX "_d.pyd" - ) - else() - set_property( - TARGET ${arg_EXTENSION_TARGET} PROPERTY SUFFIX ".pyd" - ) - endif() - endif() - - if(APPLE) - set_target_properties( - ${arg_EXTENSION_TARGET} PROPERTIES - LINK_FLAGS "-undefined dynamic_lookup" - ) - endif() -endfunction() diff --git a/sources/shiboken6/libshiboken/CMakeLists.txt b/sources/shiboken6/libshiboken/CMakeLists.txt index dc8a73156..9290256f8 100644 --- a/sources/shiboken6/libshiboken/CMakeLists.txt +++ b/sources/shiboken6/libshiboken/CMakeLists.txt @@ -106,7 +106,6 @@ signature/signature_helper.cpp set_property(SOURCE "pep384impl.cpp" PROPERTY SKIP_UNITY_BUILD_INCLUSION ON) add_library(libshiboken SHARED ${libshiboken_SRC}) -add_library(Shiboken6::libshiboken ALIAS libshiboken) target_include_directories(libshiboken PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 4b69abd4d..1bcc27218 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -869,10 +869,10 @@ static std::string msgFailedToInitializeType(const char *description) { std::ostringstream stream; stream << "libshiboken: Failed to initialize " << description; - if (auto *error = PepErr_GetRaisedException()) { - if (auto *str = PyObject_Str(error)) + if (PyErr_Occurred() != nullptr) { + Shiboken::Errors::Stash stash; + if (auto *str = PyObject_Str(stash.getException())) stream << ": " << Shiboken::String::toCString(str); - Py_DECREF(error); } stream << '.'; return stream.str(); diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 4afdcdc8b..e274b4a62 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -391,18 +391,6 @@ Pep_GetVerboseFlag() // Support for pyerrors.h #ifdef PEP_OLD_ERR_API -// Emulate PyErr_GetRaisedException() using the deprecated PyErr_Fetch()/PyErr_Store() -PyObject *PepErr_GetRaisedException() -{ - PyObject *type{}; - PyObject *value{}; - PyObject *traceback{}; - PyErr_Fetch(&type, &value, &traceback); - Py_XINCREF(value); - PyErr_Restore(type, value, traceback); - return value; -} - struct PepException_HEAD { PyObject_HEAD diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index 0e32ec0c8..8552a1e40 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -192,11 +192,9 @@ LIBSHIBOKEN_API int Pep_GetVerboseFlag(void); // pyerrors.h #ifdef PEP_OLD_ERR_API -LIBSHIBOKEN_API PyObject *PepErr_GetRaisedException(); LIBSHIBOKEN_API PyObject *PepException_GetArgs(PyObject *ex); LIBSHIBOKEN_API void PepException_SetArgs(PyObject *ex, PyObject *args); #else -inline PyObject *PepErr_GetRaisedException() { return PyErr_GetRaisedException(); } inline PyObject *PepException_GetArgs(PyObject *ex) { return PyException_GetArgs(ex); } inline void PepException_SetArgs(PyObject *ex, PyObject *args) { PyException_SetArgs(ex, args); } diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp index a705cdb40..fc29442ce 100644 --- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp +++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp @@ -269,6 +269,11 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name) // MRO has been observed to be 0 in case of errors with QML decorators if (type == nullptr || type->tp_mro == nullptr) return nullptr; + // Quick Check: Disabled? + const bool useFakeRenames = (Enum::enumOption & Enum::ENOPT_NO_FAKERENAMES) == 0; + const bool useFakeShortcuts = (Enum::enumOption & Enum::ENOPT_NO_FAKESHORTCUT) == 0; + if (!useFakeRenames && !useFakeShortcuts) + return nullptr; // Quick Check: Avoid "__..", "_slots", etc. if (std::isalpha(Shiboken::String::toCString(name)[0]) == 0) return nullptr; @@ -291,7 +296,6 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name) continue; if (!sotp->enumFlagsDict) initEnumFlagsDict(type_base); - bool useFakeRenames = !(Enum::enumOption & Enum::ENOPT_NO_FAKERENAMES); if (useFakeRenames) { auto *rename = PyDict_GetItem(sotp->enumFlagsDict, name); if (rename) { @@ -322,7 +326,6 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name) return flagType; } } - bool useFakeShortcuts = !(Enum::enumOption & Enum::ENOPT_NO_FAKESHORTCUT); if (useFakeShortcuts) { AutoDecRef tpDict(PepType_GetDict(type_base)); auto *dict = tpDict.object(); diff --git a/sources/shiboken6/tests/CMakeLists.txt b/sources/shiboken6/tests/CMakeLists.txt index 6de8199ef..c9277d0dc 100644 --- a/sources/shiboken6/tests/CMakeLists.txt +++ b/sources/shiboken6/tests/CMakeLists.txt @@ -83,15 +83,3 @@ foreach(test_file ${TEST_FILES}) set_tests_properties(${test_name} PROPERTIES WILL_FAIL TRUE) endif() endforeach() - -# dumpcodemodel depends on apiextractor which is not cross-built. -if(SHIBOKEN_BUILD_TOOLS) - add_subdirectory(dumpcodemodel) -endif() - -# FIXME Skipped until add an option to choose the generator -# add_subdirectory(test_generator) - -if (NOT APIEXTRACTOR_DOCSTRINGS_DISABLED) - add_subdirectory(qtxmltosphinxtest) -endif() |
