diff options
19 files changed, 130 insertions, 46 deletions
diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..2b813565c --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,12 @@ +# Security Policy + +This repository contains the source code for the PySide +, Shiboken, and Shiboken Generator packages, which are +under the Qt Project. + +The Qt Project has the security policy defined +in the [QUIP-15](https://contribute.qt-project.org/quips/15) + +For reporting a vulnerability, please follow the instructions +on [QUIP-15](https://contribute.qt-project.org/quips/15) +before sending an email to `security at qt-project dot org`. diff --git a/build_scripts/platforms/unix.py b/build_scripts/platforms/unix.py index 35d6dd1c3..d1729f77a 100644 --- a/build_scripts/platforms/unix.py +++ b/build_scripts/platforms/unix.py @@ -8,7 +8,7 @@ from pathlib import Path from ..log import log from ..config import config from ..options import OPTION -from ..utils import copydir, copyfile, copy_qt_metatypes, makefile +from ..utils import copydir, copyfile, copy_qt_metatypes, makefile, copy_cmake_config_dirs from .. import PYSIDE, SHIBOKEN from .linux import prepare_standalone_package_linux from .macos import prepare_standalone_package_macos @@ -90,6 +90,12 @@ def prepare_packages_posix(pyside_build, _vars, cross_build=False): ], recursive=False, _vars=_vars, force_copy_symlinks=True) + # Copy all CMake config directories matching the prefix + copy_cmake_config_dirs( + _vars["install_dir"], _vars["st_build_dir"], + _vars["st_package_name"], _vars["cmake_package_name"] + ) + if config.is_internal_shiboken_generator_build(): # <install>/bin/* -> {st_package_name}/ copydir( @@ -177,6 +183,12 @@ def prepare_packages_posix(pyside_build, _vars, cross_build=False): recursive=False, _vars=_vars)) + # Copy all CMake config directories matching the prefix + copy_cmake_config_dirs( + _vars["install_dir"], _vars["st_build_dir"], + _vars["st_package_name"], _vars["cmake_package_name"] + ) + # <install>/lib/lib* -> {st_package_name}/ copydir( "{install_dir}/lib", destination_dir, diff --git a/build_scripts/platforms/windows_desktop.py b/build_scripts/platforms/windows_desktop.py index 775095fa2..550f76f99 100644 --- a/build_scripts/platforms/windows_desktop.py +++ b/build_scripts/platforms/windows_desktop.py @@ -12,8 +12,8 @@ from pathlib import Path from ..log import log from ..config import config from ..options import OPTION -from ..utils import (copydir, copyfile, copy_qt_metatypes, - download_and_extract_7z, filter_match, makefile, in_coin) +from ..utils import (copydir, copyfile, copy_qt_metatypes, download_and_extract_7z, + filter_match, makefile, in_coin, copy_cmake_config_dirs) from .. import PYSIDE, SHIBOKEN, PYSIDE_WINDOWS_BIN_TOOLS, PYSIDE_MULTIMEDIA_LIBS @@ -70,6 +70,12 @@ def prepare_packages_win32(pyside_build, _vars): _filter=pdbs, recursive=False, _vars=_vars) + # Copy all CMake config directories matching the prefix + copy_cmake_config_dirs( + _vars["install_dir"], _vars["st_build_dir"], + _vars["st_package_name"], _vars["cmake_package_name"] + ) + if config.is_internal_shiboken_generator_build(): # <install>/bin/*.dll -> {st_package_name}/ copydir( @@ -192,6 +198,12 @@ def prepare_packages_win32(pyside_build, _vars): "ssleay32.dll"], force=False, _vars=_vars) + # Copy all CMake config directories matching the prefix + copy_cmake_config_dirs( + _vars["install_dir"], _vars["st_build_dir"], + _vars["st_package_name"], _vars["cmake_package_name"] + ) + if config.is_internal_shiboken_module_build(): # The C++ std library dlls need to be packaged with the # shiboken module, because libshiboken uses C++ code. diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 29f2545d0..be132bad8 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -1136,3 +1136,19 @@ def parse_modules(modules: str) -> str: module_sub_set += ';' module_sub_set += m return module_sub_set + + +def copy_cmake_config_dirs(install_dir, st_build_dir, st_package_name, cmake_package_name): + """ + Copy all CMake config directories from <install_dir>/lib/cmake whose names start with + <cmake_package_name> (case-insensitive) into <st_build_dir>/<st_package_name>/lib/cmake. + """ + src_cmake_dir = Path(install_dir) / "lib" / "cmake" + dst_cmake_dir = Path(st_build_dir) / st_package_name / "lib" / "cmake" + dst_cmake_dir.mkdir(parents=True, exist_ok=True) + for src_path in src_cmake_dir.iterdir(): + if src_path.is_dir() and src_path.name.lower().startswith(cmake_package_name.lower()): + dst_path = dst_cmake_dir / src_path.name + if dst_path.exists(): + shutil.rmtree(dst_path) + shutil.copytree(src_path, dst_path) diff --git a/create_wheels.py b/create_wheels.py index 55d02928b..df2680a49 100644 --- a/create_wheels.py +++ b/create_wheels.py @@ -92,6 +92,10 @@ def get_manifest(wheel_name: str, data: list[ModuleData], package_path: Path) -> # adding PySide6_Essentials.json and PySide6_Addons.json lines.append(f"include PySide6/{wheel_name}.json") + # Only include CMake configs for PySide6_Essentials + if wheel_name == "PySide6_Essentials": + lines.append("graft PySide6/lib/cmake") + return "\n".join(lines) diff --git a/sources/pyside6/PySide6/QtCore/CMakeLists.txt b/sources/pyside6/PySide6/QtCore/CMakeLists.txt index d559f9d96..fff6cc8b0 100644 --- a/sources/pyside6/PySide6/QtCore/CMakeLists.txt +++ b/sources/pyside6/PySide6/QtCore/CMakeLists.txt @@ -19,9 +19,6 @@ if(ENABLE_WIN) set(SPECIFIC_OS_FILES ${QtCore_GEN_DIR}/qwineventnotifier_wrapper.cpp ) -else() - set(SPECIFIC_OS_FILES - ${QtCore_GEN_DIR}/qprocess_unixprocessparameters_wrapper.cpp) endif() set(QtCore_SRC @@ -130,8 +127,6 @@ ${QtCore_GEN_DIR}/qpersistentmodelindex_wrapper.cpp ${QtCore_GEN_DIR}/qpluginloader_wrapper.cpp ${QtCore_GEN_DIR}/qpoint_wrapper.cpp ${QtCore_GEN_DIR}/qpointf_wrapper.cpp -${QtCore_GEN_DIR}/qprocess_wrapper.cpp -${QtCore_GEN_DIR}/qprocessenvironment_wrapper.cpp ${QtCore_GEN_DIR}/qpropertyanimation_wrapper.cpp ${QtCore_GEN_DIR}/qrandomgenerator64_wrapper.cpp ${QtCore_GEN_DIR}/qrandomgenerator_wrapper.cpp @@ -236,6 +231,23 @@ else() list(APPEND QtCore_SRC ${QtCore_GEN_DIR}/qsharedmemory_wrapper.cpp) endif() +if("process" IN_LIST QtCore_disabled_features) + list(APPEND QtCore_DROPPED_ENTRIES QProcess) + message(STATUS "Qt${QT_MAJOR_VERSION}Core: Dropping QProcess") +else() + list(APPEND QtCore_SRC ${QtCore_GEN_DIR}/qprocess_wrapper.cpp) + if(NOT ENABLE_WIN) + list(APPEND QtCore_SRC ${QtCore_GEN_DIR}/qprocess_unixprocessparameters_wrapper.cpp) + endif() +endif() + +if("processenvironment" IN_LIST QtCore_disabled_features) + list(APPEND QtCore_DROPPED_ENTRIES QProcessEnvironment) + message(STATUS "Qt${QT_MAJOR_VERSION}Core: Dropping QProcessEnvironment") +else() + list(APPEND QtCore_SRC ${QtCore_GEN_DIR}/qprocessenvironment_wrapper.cpp) +endif() + configure_file("${QtCore_SOURCE_DIR}/QtCore_global.post.h.in" "${QtCore_BINARY_DIR}/QtCore_global.post.h" @ONLY) diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index c3130ccb2..26c3ecab1 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -2669,7 +2669,9 @@ <?if !windows?> <enum-type name="UnixProcessFlag" flags="UnixProcessFlags" since="6.6"/> - <value-type name="UnixProcessParameters" since="6.6"/> + <value-type name="UnixProcessParameters"> + <configuration condition="QT_CONFIG(process)"/> + </value-type> <?endif?> <modify-function signature="waitForStarted(int)" allow-thread="yes"/> diff --git a/sources/pyside6/cmake/PySideSetup.cmake b/sources/pyside6/cmake/PySideSetup.cmake index 45a63a1a0..a3bc1c738 100644 --- a/sources/pyside6/cmake/PySideSetup.cmake +++ b/sources/pyside6/cmake/PySideSetup.cmake @@ -246,6 +246,7 @@ ENDIF() set(GENERATOR_EXTRA_FLAGS ${SHIBOKEN_GENERATOR_EXTRA_FLAGS} ${debug_level} + "--platform=${CMAKE_SYSTEM_NAME}" ${UNOPTIMIZE} --generator-set=shiboken --enable-parent-ctor-heuristic diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index 5188262de..81d7bd92f 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -827,6 +827,7 @@ BuilderPrivate::SpecialSystemHeader } switch (clang::platform()) { + case Platform::Linux: case Platform::Unix: if (fileName == u"/usr/include/stdlib.h" || baseName == u"types.h" diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index 4d93a084f..f8bcf1244 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -86,12 +86,18 @@ Platform platform() { return _platform; } bool setPlatform(const QString &name) { bool result = true; - if (name == u"windows") + if (name.compare("unix"_L1, Qt::CaseInsensitive) == 0) + _platform = Platform::Unix; + else if (name.compare("linux"_L1, Qt::CaseInsensitive) == 0) + _platform = Platform::Linux; + if (name.compare("windows"_L1, Qt::CaseInsensitive) == 0) _platform = Platform::Windows; - else if (name == u"darwin") + else if (name.compare("darwin"_L1, Qt::CaseInsensitive) == 0) _platform = Platform::macOS; - else if (name == u"unix") - _platform = Platform::Unix; + else if (name.compare("android"_L1, Qt::CaseInsensitive) == 0) + _platform = Platform::Android; + else if (name.compare("ios"_L1, Qt::CaseInsensitive) == 0) + _platform = Platform::iOS; else result = false; return result; diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h index 0e12ca137..2b1898a7e 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.h @@ -26,8 +26,11 @@ enum class Compiler { enum class Platform { Unix, + Linux, Windows, - macOS + macOS, + Android, + iOS }; namespace clang { diff --git a/sources/shiboken6/ApiExtractor/conditionalstreamreader.cpp b/sources/shiboken6/ApiExtractor/conditionalstreamreader.cpp index 6b9f0ae2e..88079a630 100644 --- a/sources/shiboken6/ApiExtractor/conditionalstreamreader.cpp +++ b/sources/shiboken6/ApiExtractor/conditionalstreamreader.cpp @@ -158,24 +158,7 @@ bool ConditionalStreamReader::conditionMatches() const void ConditionalStreamReader::setConditions(const QStringList &newConditions) { - m_conditions = newConditions + platformConditions(); -} - -QStringList ConditionalStreamReader::platformConditions() -{ - QStringList result; -#if defined (Q_OS_UNIX) - result << "unix"_L1; -#endif - -#if defined (Q_OS_LINUX) - result << "linux"_L1; -#elif defined (Q_OS_MACOS) - result << "darwin"_L1; -#elif defined (Q_OS_WINDOWS) - result << "windows"_L1; -#endif - return result; + m_conditions = newConditions; } ConditionalStreamReader::ExtendedToken ConditionalStreamReader::readNextInternal() diff --git a/sources/shiboken6/ApiExtractor/conditionalstreamreader.h b/sources/shiboken6/ApiExtractor/conditionalstreamreader.h index 36c4752a4..d9af5dc1e 100644 --- a/sources/shiboken6/ApiExtractor/conditionalstreamreader.h +++ b/sources/shiboken6/ApiExtractor/conditionalstreamreader.h @@ -69,8 +69,6 @@ public: const QStringList &conditions() const { return m_conditions; } void setConditions(const QStringList &newConditions); - static QStringList platformConditions(); - private: enum class PiTokens { None, If, Endif, EntityDefinition }; @@ -82,7 +80,7 @@ private: QXmlStreamReader m_reader; ProxyEntityResolver *m_proxyEntityResolver = nullptr; - QStringList m_conditions = ConditionalStreamReader::platformConditions(); + QStringList m_conditions; }; QDebug operator<<(QDebug dbg, const QXmlStreamAttributes &a); diff --git a/sources/shiboken6/ApiExtractor/docparser.cpp b/sources/shiboken6/ApiExtractor/docparser.cpp index 6fdabfa05..f3c51085a 100644 --- a/sources/shiboken6/ApiExtractor/docparser.cpp +++ b/sources/shiboken6/ApiExtractor/docparser.cpp @@ -22,10 +22,6 @@ #include "qtcompat.h" #include <cstdlib> -#ifdef HAVE_LIBXSLT -# include <libxslt/xsltutils.h> -# include <libxslt/transform.h> -#endif #include <algorithm> diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp index b598258a6..ed2ea3ca6 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp @@ -6,6 +6,7 @@ #include "addedfunction.h" #include "messages.h" #include "typesystemparser_p.h" +#include "clangparser/compilersupport.h" #include "complextypeentry.h" #include "constantvaluetypeentry.h" #include "containertypeentry.h" @@ -433,10 +434,32 @@ void TypeDatabase::addRequiredTargetImport(const QString& moduleName) d->m_requiredTargetImports << moduleName; } +static QStringList platformKeywords() +{ + static constexpr auto unixKeyword = "unix"_L1; + static constexpr auto linuxKeyword = "linux"_L1; + switch (clang::platform()) { + case Platform::Unix: + return {unixKeyword}; + case Platform::Linux: + return {unixKeyword, linuxKeyword}; + case Platform::Windows: + return {"windows"_L1}; + case Platform::macOS: + return {unixKeyword, "darwin"_L1}; + case Platform::Android: + return {unixKeyword, linuxKeyword, "android"_L1}; + case Platform::iOS: + return {unixKeyword, "ios"_L1}; + } + return {}; +} + QStringList TypeDatabase::typesystemKeywords() const { - QStringList result = d->m_typesystemKeywords; - for (const auto &d : d->m_dropTypeEntries) + QStringList result = d->m_typesystemKeywords + platformKeywords(); + + for (const auto &d : std::as_const(d->m_dropTypeEntries)) result.append("no_"_L1 + d); switch (clang::emulatedCompilerLanguageLevel()) { diff --git a/sources/shiboken6/generator/main.cpp b/sources/shiboken6/generator/main.cpp index fd395180c..892f1cf6b 100644 --- a/sources/shiboken6/generator/main.cpp +++ b/sources/shiboken6/generator/main.cpp @@ -193,8 +193,10 @@ bool CommonOptionsParser::handleOption(const QString &key, const QString &value, return true; } if (key == u"platform") { - if (!clang::setPlatform(value)) - throw Exception(u"Invalid value \""_s + value + u"\" passed to --platform"_s); + if (!clang::setPlatform(value)) { + qCWarning(lcShiboken, "Invalid value \"%s\" passed to --platform, defaulting to host.", + qPrintable(value)); + } return true; } diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp index 7616fa5c3..8c8f72241 100644 --- a/sources/shiboken6/generator/shiboken/headergenerator.cpp +++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp @@ -187,7 +187,7 @@ void HeaderGenerator::writeWrapperClass(TextStream &s, } s << "#include <sbkpython.h>\n\n#include <array>\n"; - s << "namespace Shiboken { class AutoDecRef; class GilState; }\n\n"; + s << "namespace Shiboken { struct AutoDecRef; class GilState; }\n\n"; if (usePySideExtensions() && isQObject(metaClass)) s << "namespace PySide { class DynamicQMetaObject; }\n\n"; diff --git a/sources/shiboken6/libshiboken/sbkbindingutils.h b/sources/shiboken6/libshiboken/sbkbindingutils.h index e40089ed2..4ed833dfa 100644 --- a/sources/shiboken6/libshiboken/sbkbindingutils.h +++ b/sources/shiboken6/libshiboken/sbkbindingutils.h @@ -8,7 +8,7 @@ #include "shibokenmacros.h" namespace Shiboken { -class AutoDecRef; +struct AutoDecRef; /// Maps a keyword argument by name to its parameter index struct ArgumentNameIndexMapping diff --git a/sources/shiboken6/tests/CMakeLists.txt b/sources/shiboken6/tests/CMakeLists.txt index 05f6e9e60..37b80238f 100644 --- a/sources/shiboken6/tests/CMakeLists.txt +++ b/sources/shiboken6/tests/CMakeLists.txt @@ -23,7 +23,8 @@ else() message(STATUS "Tests will be generated using the protected hack!") set(GENERATOR_EXTRA_FLAGS ) endif() -list(APPEND GENERATOR_EXTRA_FLAGS ${SHIBOKEN_GENERATOR_EXTRA_FLAGS} ${debug_level}) +list(APPEND GENERATOR_EXTRA_FLAGS ${SHIBOKEN_GENERATOR_EXTRA_FLAGS} ${debug_level} + "--platform=${CMAKE_SYSTEM_NAME}") add_subdirectory(minimalbinding) if(NOT DEFINED MINIMAL_TESTS) |