diff options
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
4 files changed, 33 insertions, 5 deletions
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt index 760cc6985..c55dba973 100644 --- a/sources/shiboken2/ApiExtractor/CMakeLists.txt +++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt @@ -63,6 +63,8 @@ if (NOT DISABLE_DOCSTRINGS) endif() endif() +target_compile_definitions(apiextractor PRIVATE CMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}") + set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/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) diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp index d3d5c8da8..3196c824e 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp @@ -189,7 +189,7 @@ static LinuxDistribution linuxDistribution() const QString &productType = QSysInfo::productType(); if (productType == QLatin1String("rhel")) return LinuxDistribution::RedHat; - if (productType == QLatin1String("centos")) + if (productType.compare(QLatin1String("centos"), Qt::CaseInsensitive) == 0) return LinuxDistribution::CentOs; return LinuxDistribution::Other; } @@ -207,7 +207,7 @@ static inline bool needsGppInternalHeaders() switch (distro) { case LinuxDistribution::RedHat: case LinuxDistribution::CentOs: - return checkProductVersion(QVersionNumber(7), QVersionNumber(8)); + return checkProductVersion(QVersionNumber(6, 10), QVersionNumber(8)); case LinuxDistribution::Other: break; } @@ -288,6 +288,18 @@ static QString findClangBuiltInIncludesDir() } #endif // NEED_CLANG_BUILTIN_INCLUDES +#if defined(Q_CC_CLANG) || defined(Q_CC_GNU) +static QString compilerFromCMake(const QString &defaultCompiler) +{ +# ifdef CMAKE_CXX_COMPILER + Q_UNUSED(defaultCompiler) + return QString::fromLocal8Bit(CMAKE_CXX_COMPILER); +#else + return defaultCompiler; +# endif +} +#endif // Q_CC_CLANG, Q_CC_GNU + // Returns clang options needed for emulating the host compiler QByteArrayList emulatedCompilerOptions() { @@ -297,7 +309,7 @@ QByteArrayList emulatedCompilerOptions() result.append(QByteArrayLiteral("-fms-compatibility-version=19")); result.append(QByteArrayLiteral("-Wno-microsoft-enum-value")); #elif defined(Q_CC_CLANG) - HeaderPaths headerPaths = gppInternalIncludePaths(QStringLiteral("clang++")); + HeaderPaths headerPaths = gppInternalIncludePaths(compilerFromCMake(QStringLiteral("clang++"))); result.append(noStandardIncludeOption()); #elif defined(Q_CC_GNU) HeaderPaths headerPaths; @@ -322,10 +334,12 @@ QByteArrayList emulatedCompilerOptions() // 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++")); + const HeaderPaths gppPaths = gppInternalIncludePaths(compilerFromCMake(QStringLiteral("g++"))); for (const HeaderPath &h : gppPaths) { - if (h.path.contains("c++")) + if (h.path.contains("c++") + || h.path.contains("sysroot")) { // centOS headerPaths.append(h); + } } } #else diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index eb0f44689..7bb7e0a83 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -353,6 +353,17 @@ bool TypeInfo::stripLeadingQualifier(const QString &qualifier, QString *s) return true; } +// Strip all const/volatile/*/& +void TypeInfo::stripQualifiers(QString *s) +{ + stripLeadingConst(s); + stripLeadingVolatile(s); + while (s->endsWith(QLatin1Char('&')) || s->endsWith(QLatin1Char('*')) + || s->endsWith(QLatin1Char(' '))) { + s->chop(1); + } +} + // Helper functionality to simplify a raw standard type as returned by // clang_getCanonicalType() for g++ standard containers from // "std::__cxx11::list<int, std::allocator<int> >" or diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h index 3bce5e216..6f3c17613 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h @@ -213,6 +213,7 @@ public: static bool stripLeadingConst(QString *s); static bool stripLeadingVolatile(QString *s); static bool stripLeadingQualifier(const QString &qualifier, QString *s); + static void stripQualifiers(QString *s); void simplifyStdType(); |