From 2313b5247def794216acb1afde93f2c33c2b7aa0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 Jul 2018 11:38:01 +0200 Subject: shiboken: Provide g++ internal headers for CentOS, too Extend the check introduced by 4725008aeea407ae55cfd66de802dd9e06412efc to CentOS. Task-number: PYSIDE-733 Change-Id: Iaaf2b8af0fa03684d4a3cbd5c5e70e141d125139 Reviewed-by: Alexandru Croitor --- .../ApiExtractor/clangparser/compilersupport.cpp | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'sources') diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp index 0d98999b1..74cad05ae 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp @@ -182,12 +182,36 @@ static void detectVulkan(HeaderPaths *headerPaths) } #if defined(Q_CC_GNU) -static inline bool isRedHat74() +enum class LinuxDistribution { RedHat, CentOs, Other }; + +static LinuxDistribution linuxDistribution() +{ + const QString &productType = QSysInfo::productType(); + if (productType == QLatin1String("rhel")) + return LinuxDistribution::RedHat; + if (productType == QLatin1String("centos")) + return LinuxDistribution::CentOs; + return LinuxDistribution::Other; +} + +static bool checkProductVersion(const QVersionNumber &minimum, + const QVersionNumber &excludedMaximum) { - if (QSysInfo::productType() != QLatin1String("rhel")) - return false; const QVersionNumber osVersion = QVersionNumber::fromString(QSysInfo::productVersion()); - return osVersion.isNull() || osVersion >= QVersionNumber(7, 4); + return osVersion.isNull() || (osVersion >= minimum && osVersion < excludedMaximum); +} + +static inline bool needsGppInternalHeaders() +{ + const LinuxDistribution distro = linuxDistribution(); + switch (distro) { + case LinuxDistribution::RedHat: + case LinuxDistribution::CentOs: + return checkProductVersion(QVersionNumber(7), QVersionNumber(8)); + case LinuxDistribution::Other: + break; + } + return false; } #endif // Q_CC_GNU @@ -294,9 +318,10 @@ QByteArrayList emulatedCompilerOptions() #endif // NEED_CLANG_BUILTIN_INCLUDES // Append the c++ include paths since Clang is unable to find etc - // on RHEL 7.4 with g++ 6.3. A fix for this has been added to Clang 5.0, - // so, the code can be removed once Clang 5.0 is the minimum version. - if (isRedHat74()) { + // on RHEL 7 with g++ 6.3 or CentOS 7.2. + // A fix for this has been added to Clang 5.0, so, the code can be removed + // once Clang 5.0 is the minimum version. + if (needsGppInternalHeaders()) { const HeaderPaths gppPaths = gppInternalIncludePaths(QStringLiteral("g++")); for (const HeaderPath &h : gppPaths) { if (h.path.contains("c++")) -- cgit v1.2.3