Docker: validate clangd version

Do not automatically setup a clangd that is too old and mark them as
invalid if they are manually selected.

Change-Id: Ie9662a8821df8fc678eabc4b8a08375723b4d1c3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2023-01-10 10:21:56 +01:00
parent 2e98acfdfd
commit 5516188290
8 changed files with 104 additions and 47 deletions

View File

@@ -332,38 +332,6 @@ void ClangdSettings::setData(const Data &data)
}
}
static QVersionNumber getClangdVersion(const FilePath &clangdFilePath)
{
Utils::QtcProcess clangdProc;
clangdProc.setCommand({clangdFilePath, {"--version"}});
clangdProc.start();
if (!clangdProc.waitForFinished())
return{};
const QString output = clangdProc.allOutput();
static const QString versionPrefix = "clangd version ";
const int prefixOffset = output.indexOf(versionPrefix);
if (prefixOffset == -1)
return {};
return QVersionNumber::fromString(output.mid(prefixOffset + versionPrefix.length()));
}
QVersionNumber ClangdSettings::clangdVersion(const FilePath &clangdFilePath)
{
static QHash<Utils::FilePath, QPair<QDateTime, QVersionNumber>> versionCache;
const QDateTime timeStamp = clangdFilePath.lastModified();
const auto it = versionCache.find(clangdFilePath);
if (it == versionCache.end()) {
const QVersionNumber version = getClangdVersion(clangdFilePath);
versionCache.insert(clangdFilePath, {timeStamp, version});
return version;
}
if (it->first != timeStamp) {
it->first = timeStamp;
it->second = getClangdVersion(clangdFilePath);
}
return it->second;
}
static FilePath getClangHeadersPathFromClang(const FilePath &clangdFilePath)
{
const FilePath clangFilePath = clangdFilePath.absolutePath().pathAppended("clang")
@@ -391,7 +359,7 @@ static FilePath getClangHeadersPath(const FilePath &clangdFilePath)
if (!headersPath.isEmpty())
return headersPath;
const QVersionNumber version = ClangdSettings::clangdVersion(clangdFilePath);
const QVersionNumber version = Utils::clangdVersion(clangdFilePath);
QTC_ASSERT(!version.isNull(), return {});
static const QStringList libDirs{"lib", "lib64"};
for (const QString &libDir : libDirs) {