aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-16 12:53:13 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-17 12:38:59 +0100
commit7662cb8a8329bfe160a3b885d403ec59764f399f (patch)
treea0aec74cd0522f401c12fcfe2a42bf8a251f24e2 /sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
parent46458ff09dc3db347e1b79914e874a3f49e2ec32 (diff)
shiboken6: Fix locating the Clang include dir on NixOS
Add a fallback to query llvm-config. Pick-to: 6.4 Fixes: PYSIDE-2232 Change-Id: I145808509dec8ee26368f6a4e4cb621832e6ac4f Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
index 8c3eeb592..439c2fec3 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
@@ -239,6 +239,23 @@ static bool needsClangBuiltinIncludes()
return platform() != Platform::macOS;
}
+static QString queryLlvmConfigDir(const QString &arg)
+{
+ static const QString llvmConfig = QStandardPaths::findExecutable(u"llvm-config"_s);
+ if (llvmConfig.isEmpty())
+ return {};
+ QByteArray stdOut;
+ if (!runProcess(llvmConfig, QStringList{arg}, &stdOut))
+ return {};
+ const QString path = QFile::decodeName(stdOut.trimmed());
+ if (!QFileInfo::exists(path)) {
+ qWarning(R"(%s: "%s" as returned by llvm-config "%s" does not exist.)",
+ __FUNCTION__, qPrintable(QDir::toNativeSeparators(path)), qPrintable(arg));
+ return {};
+ }
+ return path;
+}
+
static QString findClangLibDir()
{
for (const char *envVar : {"LLVM_INSTALL_DIR", "CLANG_INSTALL_DIR"}) {
@@ -249,18 +266,7 @@ static QString findClangLibDir()
qWarning("%s: %s as pointed to by %s does not exist.", __FUNCTION__, qPrintable(path), envVar);
}
}
- const QString llvmConfig =
- QStandardPaths::findExecutable(u"llvm-config"_s);
- if (!llvmConfig.isEmpty()) {
- QByteArray stdOut;
- if (runProcess(llvmConfig, QStringList{u"--libdir"_s}, &stdOut)) {
- const QString path = QFile::decodeName(stdOut.trimmed());
- if (QFileInfo::exists(path))
- return path;
- qWarning("%s: %s as returned by llvm-config does not exist.", __FUNCTION__, qPrintable(path));
- }
- }
- return QString();
+ return queryLlvmConfigDir(u"--libdir"_s);
}
static QString findClangBuiltInIncludesDir()
@@ -289,7 +295,7 @@ static QString findClangBuiltInIncludesDir()
if (!candidate.isEmpty())
return candidate + QStringLiteral("/include");
}
- return QString();
+ return queryLlvmConfigDir(u"--includedir"_s);
}
static QString compilerFromCMake(const QString &defaultCompiler)