Commit 09b405d1 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Extract some functions in LibClangOptionsBuilder



...makes the high-level function build() less noisy.

Change-Id: Ib09fba315845a604166489fd400d0be14e16fc23
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent fa675362
......@@ -114,30 +114,54 @@ static bool maybeIncludeBorlandExtensions()
class LibClangOptionsBuilder : public CompilerOptionsBuilder
{
public:
static QStringList build(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind)
static QStringList build(const ProjectPart::Ptr &projectPart, ProjectFile::Kind fileKind)
{
if (pPart.isNull())
if (projectPart.isNull())
return QStringList();
LibClangOptionsBuilder optionsBuilder(pPart);
LibClangOptionsBuilder optionsBuilder(projectPart);
if (verboseRunLog().isDebugEnabled())
optionsBuilder.add(QLatin1String("-v"));
optionsBuilder.addLanguageOption(fileKind);
optionsBuilder.addOptionsForLanguage(maybeIncludeBorlandExtensions());
optionsBuilder.addToolchainAndProjectDefines();
optionsBuilder.addResourceDirOptions();
optionsBuilder.addHeaderPathOptions();
optionsBuilder.addInjectedHeaderWithCustomQtMacros();
optionsBuilder.addProjectConfigFileInclude();
optionsBuilder.addExtraOptions();
return optionsBuilder.options();
}
private:
LibClangOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart)
: CompilerOptionsBuilder(projectPart)
{
}
bool excludeHeaderPath(const QString &path) const override
{
return path.contains(QLatin1String("lib/gcc/i686-apple-darwin"));
}
void addResourceDirOptions()
{
static const QString resourceDir = getResourceDir();
if (!resourceDir.isEmpty()) {
optionsBuilder.add(QLatin1String("-nostdlibinc"));
optionsBuilder.add(QLatin1String("-I") + resourceDir);
optionsBuilder.add(QLatin1String("-undef"));
add(QLatin1String("-nostdlibinc"));
add(QLatin1String("-I") + resourceDir);
add(QLatin1String("-undef"));
}
}
optionsBuilder.addHeaderPathOptions();
// Inject header file
void addInjectedHeaderWithCustomQtMacros()
{
static const QString injectedHeader = ICore::instance()->resourcePath()
+ QLatin1String("/cplusplus/qt%1-qobjectdefs-injected.h");
......@@ -146,34 +170,27 @@ public:
// builder.addOption(injectedHeader.arg(QLatin1Char('4')));
// }
if (pPart->qtVersion == ProjectPart::Qt5) {
optionsBuilder.add(QLatin1String("-include"));
optionsBuilder.add(injectedHeader.arg(QLatin1Char('5')));
if (m_projectPart->qtVersion == ProjectPart::Qt5) {
add(QLatin1String("-include"));
add(injectedHeader.arg(QLatin1Char('5')));
}
if (!pPart->projectConfigFile.isEmpty()) {
optionsBuilder.add(QLatin1String("-include"));
optionsBuilder.add(pPart->projectConfigFile);
}
optionsBuilder.add(QLatin1String("-fmessage-length=0"));
optionsBuilder.add(QLatin1String("-fdiagnostics-show-note-include-stack"));
optionsBuilder.add(QLatin1String("-fmacro-backtrace-limit=0"));
optionsBuilder.add(QLatin1String("-fretain-comments-from-system-headers"));
// TODO: -Xclang -ferror-limit -Xclang 0 ?
return optionsBuilder.options();
}
private:
LibClangOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart)
: CompilerOptionsBuilder(projectPart)
void addProjectConfigFileInclude()
{
if (!m_projectPart->projectConfigFile.isEmpty()) {
add(QLatin1String("-include"));
add(m_projectPart->projectConfigFile);
}
}
bool excludeHeaderPath(const QString &path) const override
void addExtraOptions()
{
return path.contains(QLatin1String("lib/gcc/i686-apple-darwin"));
add(QLatin1String("-fmessage-length=0"));
add(QLatin1String("-fdiagnostics-show-note-include-stack"));
add(QLatin1String("-fmacro-backtrace-limit=0"));
add(QLatin1String("-fretain-comments-from-system-headers"));
// TODO: -Xclang -ferror-limit -Xclang 0 ?
}
};
......
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