Clang: Make some functions available

Change-Id: I1d2d898e5ab197eb3e5c95e82b6668a00affce7d
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-10-09 15:16:46 +02:00
committed by Nikolai Kosjar
parent 96af4e3c8e
commit 1754dbf6ff
2 changed files with 45 additions and 23 deletions

View File

@@ -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:";