Commit 1754dbf6 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Nikolai Kosjar

Clang: Make some functions available

Change-Id: I1d2d898e5ab197eb3e5c95e82b6668a00affce7d
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
parent 96af4e3c
......@@ -108,7 +108,35 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fil
return createClangOptions(pPart, fileKind);
}
static QStringList buildDefines(const QByteArray &defines, bool toolchainDefines)
QStringList createHeaderPathOptions(const QList<ProjectPart::HeaderPath> &headerPaths)
{
typedef ProjectPart::HeaderPath HeaderPath;
QStringList result;
foreach (const HeaderPath &headerPath , headerPaths) {
if (headerPath.path.isEmpty() || isBlacklisted(headerPath.path))
continue;
QString prefix;
switch (headerPath.type) {
case HeaderPath::FrameworkPath:
prefix = QLatin1String("-F");
break;
default: // This shouldn't happen, but let's be nice..:
// intentional fall-through:
case HeaderPath::IncludePath:
prefix = QLatin1String("-I");
break;
}
result.append(prefix + headerPath.path);
}
return result;
}
QStringList createDefineOptions(const QByteArray &defines, bool toolchainDefines)
{
QStringList result;
......@@ -149,6 +177,15 @@ static QStringList buildDefines(const QByteArray &defines, bool toolchainDefines
return result;
}
QStringList definesAndHeaderPathsOptions(const ProjectPart::Ptr &pPart)
{
QStringList result;
result << createDefineOptions(pPart->toolchainDefines, false);
result << createDefineOptions(pPart->projectDefines, false);
result << createHeaderPathOptions(pPart->headerPaths);
return result;
}
static QString getResourceDir()
{
QDir dir(Core::ICore::instance()->resourcePath() + QLatin1String("/cplusplus/clang/") +
......@@ -194,28 +231,9 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
if (!pPart->projectConfigFile.isEmpty())
result << QLatin1String("-include") << pPart->projectConfigFile;
result << buildDefines(pPart->toolchainDefines, false);
result << buildDefines(pPart->projectDefines, false);
typedef ProjectPart::HeaderPath HeaderPath;
foreach (const HeaderPath &headerPath , pPart->headerPaths) {
if (headerPath.path.isEmpty() || isBlacklisted(headerPath.path))
continue;
QString prefix;
switch (headerPath.type) {
case HeaderPath::FrameworkPath:
prefix = QLatin1String("-F");
break;
default: // This shouldn't happen, but let's be nice..:
// intentional fall-through:
case HeaderPath::IncludePath:
prefix = QLatin1String("-I");
break;
}
result.append(prefix + headerPath.path);
}
result << createDefineOptions(pPart->toolchainDefines, false);
result << createDefineOptions(pPart->projectDefines, false);
result << createHeaderPathOptions(pPart->headerPaths);
#if 0
qDebug() << "--- m_args:";
......
......@@ -31,6 +31,7 @@
#ifndef CPPTOOLS_CLANGUTILS_H
#define CPPTOOLS_CLANGUTILS_H
#include "clang_global.h"
#include "utils.h"
#include <cpptools/cppmodelmanager.h>
......@@ -46,6 +47,9 @@ QStringList clangNonProjectFileOptions(CppTools::ProjectFile::Kind kind);
QStringList createPCHInclusionOptions(const QStringList &pchFiles);
QStringList createPCHInclusionOptions(const QString &pchFile);
QStringList CLANG_EXPORT createHeaderPathOptions(const QList<CppTools::ProjectPart::HeaderPath> &headerPaths);
QStringList CLANG_EXPORT createDefineOptions(const QByteArray &defines, bool toolchainDefines);
QStringList clangLanguageOption(CppTools::ProjectFile::Kind fileKind, bool objcExt);
QStringList clangOptionsForLanguage(CppTools::ProjectPart::QtVersion qtVersion,
CppTools::ProjectPart::LanguageVersion languageVersion,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment