biome: 1.9.2 -> 1.9.3 (#349335)
[NixPkgs.git] / pkgs / development / python-modules / shiboken6 / fix-include-qt-headers.patch
blob4c6d7bdad3fd4d33dca30cb38c19218eeffa35e7
1 --- a/ApiExtractor/clangparser/compilersupport.cpp
2 +++ b/ApiExtractor/clangparser/compilersupport.cpp
3 @@ -16,6 +16,7 @@
4 #include <QtCore/QStandardPaths>
5 #include <QtCore/QStringList>
6 #include <QtCore/QVersionNumber>
7 +#include <QtCore/QRegularExpression>
9 #include <clang-c/Index.h>
11 @@ -341,6 +342,13 @@ QByteArrayList emulatedCompilerOptions()
13 QByteArrayList result;
14 HeaderPaths headerPaths;
16 + bool isNixDebug = qgetenv("NIX_DEBUG").toInt() > 0;
17 + // examples:
18 + // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtsensors-6.4.2-dev/include
19 + // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtbase-6.4.2-dev/include
20 + QRegularExpression qtHeaderRegex(uR"(/[0-9a-z]{32}-qt[a-z0-9]+-)"_s);
22 switch (compiler()) {
23 case Compiler::Msvc:
24 result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806"));
25 @@ -352,9 +360,30 @@ QByteArrayList emulatedCompilerOptions()
26 appendClangBuiltinIncludes(&headerPaths);
27 break;
28 case Compiler::Clang:
29 - headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
30 + // fix: error: cannot jump from switch statement to this case label: case Compiler::Gpp
31 + // note: jump bypasses variable initialization: const HeaderPaths clangPaths =
32 + {
33 + //headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
34 + // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
35 + // PySide requires that Qt headers are not -isystem
36 + // https://bugreports.qt.io/browse/PYSIDE-787
37 + const HeaderPaths clangPaths = gppInternalIncludePaths(compilerFromCMake(u"clang++"_qs));
38 + for (const HeaderPath &h : clangPaths) {
39 + auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
40 + if (!match.hasMatch()) {
41 + if (isNixDebug)
42 + qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
43 + // add using -isystem
44 + headerPaths.append(h);
45 + } else {
46 + if (isNixDebug)
47 + qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
48 + headerPaths.append({h.path, HeaderType::Standard});
49 + }
50 + }
51 result.append(noStandardIncludeOption());
52 break;
53 + }
54 case Compiler::Gpp:
55 if (needsClangBuiltinIncludes())
56 appendClangBuiltinIncludes(&headerPaths);
57 @@ -363,8 +392,20 @@ QByteArrayList emulatedCompilerOptions()
58 // <type_traits> etc (g++ 11.3).
59 const HeaderPaths gppPaths = gppInternalIncludePaths(compilerFromCMake(u"g++"_qs));
60 for (const HeaderPath &h : gppPaths) {
61 - if (h.path.contains("c++") || h.path.contains("sysroot"))
62 + // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
63 + // PySide requires that Qt headers are not -isystem
64 + // https://bugreports.qt.io/browse/PYSIDE-787
65 + auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
66 + if (!match.hasMatch()) {
67 + if (isNixDebug)
68 + qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
69 + // add using -isystem
70 headerPaths.append(h);
71 + } else {
72 + if (isNixDebug)
73 + qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
74 + headerPaths.append({h.path, HeaderType::Standard});
75 + }
77 break;
79 --
80 2.39.0