diff options
Diffstat (limited to 'sources')
24 files changed, 212 insertions, 128 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 0256821d4..acf9202cb 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -336,7 +336,8 @@ <add-conversion type="SbkObject" file="../glue/qtcore.cpp" snippet="conversion-sbkobject"/> <add-conversion type="PyDict" check="PyDict_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-pydict"/> <add-conversion type="PyList" check="PyList_Check(%in)" file="../glue/qtcore.cpp" snippet="conversion-pylist"/> - <add-conversion type="PyTuple" check="PyTuple_Check(%in)" file="../glue/qtcore.cpp" snippet="conversion-pylist"/> + <add-conversion type="PyTuple" check="PyTuple_CheckExact(%in)" + file="../glue/qtcore.cpp" snippet="conversion-pylist"/> <add-conversion type="PyObject" file="../glue/qtcore.cpp" snippet="conversion-pyobject"/> </target-to-native> </conversion-rule> @@ -3414,6 +3415,9 @@ <add-function signature="__repr__" return-type="str"> <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qmetaobject-repr"/> </add-function> + <modify-function signature="className()const"> + <modify-argument index="return" pyi-type="str"/> + </modify-function> <modify-function signature="indexOfClassInfo(const char *)const"> <modify-argument index="1" pyi-type="str"/> </modify-function> diff --git a/sources/pyside6/doc/developer/add_port_example.rst b/sources/pyside6/doc/developer/add_port_example.rst index 909986e79..e65c3c9c8 100644 --- a/sources/pyside6/doc/developer/add_port_example.rst +++ b/sources/pyside6/doc/developer/add_port_example.rst @@ -67,11 +67,17 @@ Port a Qt example - Note that our examples need to have unique names due to the doc build. - Verify that all slots are decorated using ``@Slot``. - Enumerations should be fully qualified (PYSIDE-1735). +- Check the above by running the example with the environment variables: + + .. code-block:: bash + + export PYSIDE6_OPTION_PYTHON_ENUM=0x71 + export QT_LOGGING_RULES=qt.pyside.libpyside.warning=true + - Add a ``.pyproject`` file (verify later on that docs build). -- Add a ``doc`` directory and descriptive ``.rst`` file, +- Add a ``doc`` directory and descriptive ``.md`` or ``.rst`` file, and a screenshot if suitable (use ``optipng`` to reduce file size). - Add the ``"""Port of the ... example from Qt 6"""`` doc string. -- Try to port variable and function names to snake case convention. - Remove C++ documentation from ``sources/pyside6/doc/additionaldocs.lst``. .. note:: Example screenshots in ``.png`` should be optimized by diff --git a/sources/pyside6/plugins/designer/designercustomwidgets.cpp b/sources/pyside6/plugins/designer/designercustomwidgets.cpp index d13539859..c43af1f6d 100644 --- a/sources/pyside6/plugins/designer/designercustomwidgets.cpp +++ b/sources/pyside6/plugins/designer/designercustomwidgets.cpp @@ -68,7 +68,7 @@ static QString pyErrorMessage() #else // <3.11 if (PyObject *pvalue = PyErr_GetRaisedException()) { result = pyStr(pvalue); - Py_DECREF(pvalue); + PyErr_SetRaisedException(pvalue); } #endif return result; diff --git a/sources/pyside6/tests/QtCore/qobject_property_test.py b/sources/pyside6/tests/QtCore/qobject_property_test.py index 80387ec77..9d2bd2c56 100644 --- a/sources/pyside6/tests/QtCore/qobject_property_test.py +++ b/sources/pyside6/tests/QtCore/qobject_property_test.py @@ -9,6 +9,7 @@ import sys import unittest from pathlib import Path +from typing import NamedTuple sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) @@ -16,6 +17,9 @@ init_test_paths(False) from PySide6.QtCore import QObject, Property, Signal +Point = NamedTuple("Point", [("x", float), ("y", float)]) + + class MyObjectWithNotifyProperty(QObject): def __init__(self, parent=None): QObject.__init__(self, parent) @@ -52,6 +56,23 @@ class MyObjectWithOtherClassProperty(QObject): otherclass = Property(OtherClass, fget=_get_otherclass, fset=_set_otherclass) +class TestVariantPropertyObject(QObject): + """Helper for testing QVariant conversion in properties and signals + (PYSIDE-3206, PYSIDE-3244). It uses a property of list type that + can passed a QVariant list with various element types.""" + def __init__(self, parent=None): + super().__init__(parent) + self._property = None + + def set_property(self, v): + self._property = v + + def get_property(self): + return self._property + + testProperty = Property(list, fget=get_property, fset=set_property) + + class PropertyWithNotify(unittest.TestCase): def called(self): self.called_ = True @@ -84,5 +105,32 @@ class QObjectWithOtherClassPropertyTest(unittest.TestCase): self.assertTrue(type(pv) is OtherClass) +class VariantPropertyTest(unittest.TestCase): + """Test QVariant conversion in properties and signals (PYSIDE-3206, PYSIDE-3244). + It uses a property of list type that is passed a QVariantList + with various element types when using QObject.setProperty().""" + + def testIt(self): + to = TestVariantPropertyObject() + idx = to.metaObject().indexOfProperty("testProperty") + self.assertTrue(idx != -1) + + # List + to.setProperty("testProperty", [[1, 2]]) + self.assertEqual(type(to.get_property()[0]), list) + + # Dict + to.setProperty("testProperty", [{"key": 42}]) + self.assertEqual(type(to.get_property()[0]), dict) + + # PYSIDE-3206 (DBus): Convert a tuple to a list + to.setProperty("testProperty", [(1, 2)]) + self.assertEqual(type(to.get_property()[0]), list) + + # PYSIDE-324: The tuple conversion must not occur for named tuples + to.setProperty("testProperty", [Point(1, 2)]) + self.assertEqual(type(to.get_property()[0]), Point) + + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt b/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt index ace1a00fa..72e7d3cea 100644 --- a/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt +++ b/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt @@ -1,11 +1,8 @@ # Copyright (C) 2025 Ford Motor Company # SPDX-License-Identifier: BSD-3-Clause -# FIXME: TypeError: Failed to generate default value. Error: name 'int' is not defined. Problematic code: int(2) -if(NOT APPLE) PYSIDE_TEST(repfile_test.py) PYSIDE_TEST(dynamic_types_test.py) PYSIDE_TEST(integration_test.py) add_subdirectory(cpp_interop) -endif() 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/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() diff --git a/sources/shiboken6_generator/ApiExtractor/CMakeLists.txt b/sources/shiboken6_generator/ApiExtractor/CMakeLists.txt index 5385eccf1..b0ce14bef 100644 --- a/sources/shiboken6_generator/ApiExtractor/CMakeLists.txt +++ b/sources/shiboken6_generator/ApiExtractor/CMakeLists.txt @@ -131,8 +131,6 @@ target_compile_definitions(apiextractor PRIVATE CMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" PRIVATE QT_LEAN_HEADERS=1) -set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) - if (BUILD_TESTS) find_package(Qt6 REQUIRED COMPONENTS Test) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tests) diff --git a/sources/shiboken6_generator/CMakeLists.txt b/sources/shiboken6_generator/CMakeLists.txt new file mode 100644 index 000000000..24fb91c57 --- /dev/null +++ b/sources/shiboken6_generator/CMakeLists.txt @@ -0,0 +1,23 @@ +include(../shiboken6/icecc.cmake) +include(../shiboken6/.cmake.conf) + +cmake_minimum_required(VERSION 3.18) +cmake_policy(VERSION 3.18) + +project(shiboken_generator) + +include(cmake/ShibokenGeneratorSetup.cmake) + +get_rpath_base_token(base) + +set(CMAKE_INSTALL_RPATH ${base}/) + +set(CMAKE_BUILD_TYPE Release CACHE STRING "Build Type") + +add_subdirectory(ApiExtractor) # Uses libclang +add_subdirectory(generator) # Uses ApiExtractor And QtCore + +if(BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/sources/shiboken6_generator/cmake/ShibokenGeneratorHelpers.cmake b/sources/shiboken6_generator/cmake/ShibokenGeneratorHelpers.cmake new file mode 100644 index 000000000..90d43c15e --- /dev/null +++ b/sources/shiboken6_generator/cmake/ShibokenGeneratorHelpers.cmake @@ -0,0 +1,26 @@ +option(BUILD_TESTS "Build tests." ON) + +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. + if (LLVM_PACKAGE_VERSION AND LLVM_PACKAGE_VERSION VERSION_LESS "9.0") + message(FATAL_ERROR "You need LLVM version 9.0 or greater to build.") + 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() diff --git a/sources/shiboken6_generator/cmake/ShibokenGeneratorSetup.cmake b/sources/shiboken6_generator/cmake/ShibokenGeneratorSetup.cmake new file mode 100644 index 000000000..137824d15 --- /dev/null +++ b/sources/shiboken6_generator/cmake/ShibokenGeneratorSetup.cmake @@ -0,0 +1,50 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" + "${CMAKE_CURRENT_LIST_DIR}/../../shiboken6/cmake") + +include(ShibokenHelpers) +include(ShibokenGeneratorHelpers) + +shiboken_internal_disable_pkg_config_if_needed() +shiboken_internal_detect_if_cross_building() + +# Note: For cross building, we rely on FindPython shipped with CMake 3.17+ to +# provide the value of Python_SOABI. + +shiboken_internal_decide_parts_to_build() +shiboken_internal_set_up_extra_dependency_paths() + +set(QT_MAJOR_VERSION 6) +message(STATUS "Using Qt ${QT_MAJOR_VERSION}") +find_package(Qt6 REQUIRED COMPONENTS Core) + +if(QUIET_BUILD) + set_quiet_build() +endif() + +if(USE_PYTHON_VERSION) + shiboken_find_required_python(${USE_PYTHON_VERSION}) +else() + shiboken_find_required_python() +endif() + +setup_clang() + +# from cmake.conf +set(shiboken6_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") + +compute_config_py_values(shiboken6_VERSION) + +shiboken_internal_set_python_site_packages() + +set_cmake_cxx_flags() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII") + +# Force usage of the C++17 standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install \ + prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) +set(BIN_INSTALL_DIR "bin" CACHE PATH "The subdirectory relative to the install prefix where \ + dlls will be installed (default is /bin)" FORCE) diff --git a/sources/shiboken6/data/Shiboken6ToolsMacros.cmake b/sources/shiboken6_generator/data/Shiboken6ToolsMacros.cmake index 2c1a8c786..2c1a8c786 100644 --- a/sources/shiboken6/data/Shiboken6ToolsMacros.cmake +++ b/sources/shiboken6_generator/data/Shiboken6ToolsMacros.cmake diff --git a/sources/shiboken6_generator/generator/CMakeLists.txt b/sources/shiboken6_generator/generator/CMakeLists.txt index 997468f02..33bb41321 100644 --- a/sources/shiboken6_generator/generator/CMakeLists.txt +++ b/sources/shiboken6_generator/generator/CMakeLists.txt @@ -6,11 +6,6 @@ set(package_name "Shiboken6Tools") set(CMAKE_AUTOMOC ON) -if(NOT (Qt${QT_MAJOR_VERSION}Core_FOUND AND Python_Interpreter_FOUND)) - message(WARNING "Some dependencies were not found: shiboken6 generator compilation disabled!") - return() -endif() - set(shiboken6_SRC defaultvalue.cpp defaultvalue.h generator.cpp generator.h @@ -60,6 +55,10 @@ if (NOT DISABLE_DOCSTRINGS) target_compile_definitions(shiboken6 PUBLIC DOCSTRINGS_ENABLED QT_LEAN_HEADERS=1) endif() +# TODO: We are not actually using the tool_wrapper, but we need to make sure +# the properties for the tool are properly set +shiboken_get_tool_shell_wrapper(shiboken tool_wrapper) + configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY) install(TARGETS shiboken6 @@ -103,7 +102,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../shiboken_tool.py # Use absolute path instead of relative path, to avoid ninja build errors due to # duplicate file dependency inconsistency. -set(shiboken_version_relative_path "${CMAKE_CURRENT_SOURCE_DIR}/../shiboken_version.py") +set(shiboken_version_relative_path "${CMAKE_CURRENT_SOURCE_DIR}/../../shiboken6/shiboken_version.py") get_filename_component(shiboken_version_path ${shiboken_version_relative_path} ABSOLUTE) configure_file("${shiboken_version_path}" "${CMAKE_CURRENT_BINARY_DIR}/_git_shiboken_generator_version.py" @ONLY) diff --git a/sources/shiboken6_generator/tests/CMakeLists.txt b/sources/shiboken6_generator/tests/CMakeLists.txt new file mode 100644 index 000000000..f71467c87 --- /dev/null +++ b/sources/shiboken6_generator/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.18) + +# dumpcodemodel depends on apiextractor which is not cross-built. +add_subdirectory(dumpcodemodel) + +# FIXME Skipped until add an option to choose the generator +# add_subdirectory(test_generator) + +if (NOT APIEXTRACTOR_DOCSTRINGS_DISABLED) + add_subdirectory(qtxmltosphinxtest) +endif() diff --git a/sources/shiboken6_generator/tests/dumpcodemodel/CMakeLists.txt b/sources/shiboken6_generator/tests/dumpcodemodel/CMakeLists.txt index e7dbef961..8b71389f1 100644 --- a/sources/shiboken6_generator/tests/dumpcodemodel/CMakeLists.txt +++ b/sources/shiboken6_generator/tests/dumpcodemodel/CMakeLists.txt @@ -3,6 +3,8 @@ add_executable(dumpcodemodel main.cpp) +find_package(Qt6 COMPONENTS Core) + target_include_directories(dumpcodemodel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/sources/shiboken6_generator/tests/qtxmltosphinx/CMakeLists.txt b/sources/shiboken6_generator/tests/qtxmltosphinx/CMakeLists.txt index 4a200becd..489fbebfa 100644 --- a/sources/shiboken6_generator/tests/qtxmltosphinx/CMakeLists.txt +++ b/sources/shiboken6_generator/tests/qtxmltosphinx/CMakeLists.txt @@ -11,8 +11,9 @@ set(CMAKE_AUTOMOC ON) find_package(Qt6 COMPONENTS Core) -set(generator_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../generator) -set(api_extractor_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../ApiExtractor) +set(shiboken_generator_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../shiboken6_generator) +set(generator_src_dir ${shiboken_generator_src_dir}/generator) +set(api_extractor_src_dir ${shiboken_generator_src_dir}/ApiExtractor) set(qtxmltosphinx_SRC ${generator_src_dir}/qtdoc/qtxmltosphinx.cpp diff --git a/sources/shiboken6_generator/tests/qtxmltosphinxtest/CMakeLists.txt b/sources/shiboken6_generator/tests/qtxmltosphinxtest/CMakeLists.txt index 109ab288e..cb170efe6 100644 --- a/sources/shiboken6_generator/tests/qtxmltosphinxtest/CMakeLists.txt +++ b/sources/shiboken6_generator/tests/qtxmltosphinxtest/CMakeLists.txt @@ -10,8 +10,9 @@ set(CMAKE_AUTOMOC ON) find_package(Qt6 COMPONENTS Core) find_package(Qt6 COMPONENTS Test) -set(generator_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../generator) -set(api_extractor_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../ApiExtractor) +set(shiboken_generator_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../shiboken6_generator) +set(generator_src_dir ${shiboken_generator_src_dir}/generator) +set(api_extractor_src_dir ${shiboken_generator_src_dir}/ApiExtractor) set(qtxmltosphinxtest_SRC ${generator_src_dir}/qtdoc/qtxmltosphinx.cpp |
