Clang: Move clang paths helper functions to Core plugin

These functions require core plugin so they can't go
to utils library. At the same time to use them in
ProjectExplorer plugin there are not too many choices
where to put them without introducing new dependencies.

Change-Id: I3cccccffaae8ac4bbce924fd809b5423da5dc503
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-08-06 11:32:32 +02:00
parent 960fccc763
commit 344cbb3a1b
7 changed files with 42 additions and 41 deletions

View File

@@ -510,6 +510,16 @@ void CompilerOptionsBuilder::addPredefinedHeaderPathsOptions()
addClangIncludeFolder();
}
static QString clangIncludeDirectory(const QString &clangVersion,
const QString &clangResourceDirectory)
{
#ifndef UNIT_TESTS
return Core::ICore::clangIncludeDirectory(clangVersion, clangResourceDirectory);
#else
return QString();
#endif
}
void CompilerOptionsBuilder::addClangIncludeFolder()
{
QTC_CHECK(!m_clangVersion.isEmpty());
@@ -525,32 +535,6 @@ void CompilerOptionsBuilder::addProjectConfigFileInclude()
}
}
static QString creatorLibexecPath()
{
#ifndef UNIT_TESTS
return Core::ICore::instance()->libexecPath();
#else
return QString();
#endif
}
QString clangIncludeDirectory(const QString &clangVersion, const QString &clangResourceDirectory)
{
QDir dir(creatorLibexecPath() + "/clang" + clangIncludePath(clangVersion));
if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists())
dir = QDir(clangResourceDirectory);
return QDir::toNativeSeparators(dir.canonicalPath());
}
QString clangExecutable(const QString &clangBinDirectory)
{
const QString hostExeSuffix(QTC_HOST_EXE_SUFFIX);
QFileInfo executable(creatorLibexecPath() + "/clang/bin/clang" + hostExeSuffix);
if (!executable.exists())
executable = QFileInfo(clangBinDirectory + "/clang" + hostExeSuffix);
return QDir::toNativeSeparators(executable.canonicalFilePath());
}
void CompilerOptionsBuilder::undefineClangVersionMacrosForMsvc()
{
if (m_projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID) {

View File

@@ -97,15 +97,4 @@ private:
QString m_clangResourceDirectory;
};
QString CPPTOOLS_EXPORT clangExecutable(const QString &clangBinDirectory);
QString CPPTOOLS_EXPORT clangIncludeDirectory(const QString &clangVersion,
const QString &clangResourceDirectory);
template<class T>
T clangIncludePath(const T &clangVersion)
{
return "/lib/clang/" + clangVersion + "/include";
}
} // namespace CppTools