forked from qt-creator/qt-creator
ClangTools: Add UI for specifying executables
Add a new group box "Executables" for this. Hide the UI for clazy-standalone unless QTC_USE_CLAZY_STANDALONE_PATH is set as there is no released version with the needed -export-fixes option. Rename the previous group box from "General" to "Run Options". Change-Id: Ia9daf66c40d3a7eea98b31d9c086886d29466490 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "clangtoolsutils.h"
|
||||
|
||||
#include "clangtool.h"
|
||||
#include "clangtoolsconstants.h"
|
||||
#include "clangtoolsdiagnostic.h"
|
||||
#include "clangtoolssettings.h"
|
||||
|
||||
@@ -70,5 +71,88 @@ void showHintAboutBuildBeforeAnalysis()
|
||||
"ClangToolsDisablingBuildBeforeAnalysisHint");
|
||||
}
|
||||
|
||||
bool isFileExecutable(const QString &filePath)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
return false;
|
||||
|
||||
const QFileInfo fileInfo(filePath);
|
||||
return fileInfo.isFile() && fileInfo.isExecutable();
|
||||
}
|
||||
|
||||
QString shippedClangTidyExecutable()
|
||||
{
|
||||
const QString shippedExecutable = Core::ICore::clangTidyExecutable(CLANG_BINDIR);
|
||||
if (isFileExecutable(shippedExecutable))
|
||||
return shippedExecutable;
|
||||
return {};
|
||||
}
|
||||
|
||||
QString shippedClazyStandaloneExecutable()
|
||||
{
|
||||
const QString shippedExecutable = Core::ICore::clazyStandaloneExecutable(CLANG_BINDIR);
|
||||
if (isFileExecutable(shippedExecutable))
|
||||
return shippedExecutable;
|
||||
return {};
|
||||
}
|
||||
|
||||
static QString fullPath(const QString &executable)
|
||||
{
|
||||
const QString hostExeSuffix = QLatin1String(QTC_HOST_EXE_SUFFIX);
|
||||
const Qt::CaseSensitivity caseSensitivity = Utils::HostOsInfo::fileNameCaseSensitivity();
|
||||
|
||||
QString candidate = executable;
|
||||
const bool hasSuffix = candidate.endsWith(hostExeSuffix, caseSensitivity);
|
||||
|
||||
const QFileInfo fileInfo = QFileInfo(candidate);
|
||||
if (fileInfo.isAbsolute()) {
|
||||
if (!hasSuffix)
|
||||
candidate.append(hostExeSuffix);
|
||||
} else {
|
||||
const Utils::Environment environment = Utils::Environment::systemEnvironment();
|
||||
const QString expandedPath = environment.searchInPath(candidate).toString();
|
||||
if (!expandedPath.isEmpty())
|
||||
candidate = expandedPath;
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
static QString findValidExecutable(const QStringList &candidates)
|
||||
{
|
||||
for (QString candidate : candidates) {
|
||||
const QString expandedPath = fullPath(candidate);
|
||||
if (isFileExecutable(expandedPath))
|
||||
return expandedPath;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QString clangTidyExecutable()
|
||||
{
|
||||
const QString fromSettings = ClangToolsSettings::instance()->clangTidyExecutable();
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
|
||||
return findValidExecutable({
|
||||
shippedClangTidyExecutable(),
|
||||
Constants::CLANG_TIDY_EXECUTABLE_NAME,
|
||||
});
|
||||
}
|
||||
|
||||
QString clazyStandaloneExecutable()
|
||||
{
|
||||
const QString fromSettings = ClangToolsSettings::instance()->clazyStandaloneExecutable();
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
|
||||
return findValidExecutable({
|
||||
shippedClazyStandaloneExecutable(),
|
||||
qEnvironmentVariable("QTC_USE_CLAZY_STANDALONE_PATH"),
|
||||
Constants::CLAZY_STANDALONE_EXECUTABLE_NAME,
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangTools
|
||||
|
||||
Reference in New Issue
Block a user