forked from qt-creator/qt-creator
CppTools: Apply SkipBuiltIn also to toolchain defines
The only place where Yes is used is the compilation DB, which doesn't need these defines anyway. Also add -fPIC for Qt compatibility. This reduces the compile_commands.json file for Qt Creator from 180M to 33M. Change-Id: Idd3b363c3a143b1d79f97962c4ff9ee61d7767a4 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
cc1e03a649
commit
f07396b86f
@@ -43,14 +43,14 @@ namespace CppTools {
|
||||
|
||||
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart,
|
||||
UseSystemHeader useSystemHeader,
|
||||
SkipBuiltIn skipBuiltInHeaderPaths,
|
||||
SkipBuiltIn skipBuiltInHeaderPathsAndDefines,
|
||||
QString clangVersion,
|
||||
QString clangResourceDirectory)
|
||||
: m_projectPart(projectPart)
|
||||
, m_useSystemHeader(useSystemHeader)
|
||||
, m_clangVersion(clangVersion)
|
||||
, m_clangResourceDirectory(clangResourceDirectory)
|
||||
, m_skipBuiltInHeaderPaths(skipBuiltInHeaderPaths)
|
||||
, m_skipBuiltInHeaderPathsAndDefines(skipBuiltInHeaderPathsAndDefines)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ QStringList CompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind,
|
||||
undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
addDefineFunctionMacrosMsvc();
|
||||
|
||||
addGlobalUndef();
|
||||
addToolchainFlags();
|
||||
addPrecompiledHeaderOptions(pchUsage);
|
||||
addHeaderPathOptions();
|
||||
addProjectConfigFileInclude();
|
||||
@@ -305,7 +305,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
m_options.append(includes);
|
||||
m_options.append(systemIncludes);
|
||||
|
||||
if (m_skipBuiltInHeaderPaths == SkipBuiltIn::Yes)
|
||||
if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::Yes)
|
||||
return;
|
||||
|
||||
// Exclude all built-in includes except Clang resource directory.
|
||||
@@ -351,7 +351,8 @@ void CompilerOptionsBuilder::addPrecompiledHeaderOptions(PchUsage pchUsage)
|
||||
|
||||
void CompilerOptionsBuilder::addToolchainAndProjectMacros()
|
||||
{
|
||||
addMacros(m_projectPart.toolChainMacros);
|
||||
if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::No)
|
||||
addMacros(m_projectPart.toolChainMacros);
|
||||
addMacros(m_projectPart.projectMacros);
|
||||
}
|
||||
|
||||
@@ -634,12 +635,15 @@ void CompilerOptionsBuilder::addWrappedQtHeadersIncludePath(QStringList &list)
|
||||
}
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilder::addGlobalUndef()
|
||||
void CompilerOptionsBuilder::addToolchainFlags()
|
||||
{
|
||||
// In case of MSVC we need builtin clang defines to correctly handle clang includes
|
||||
if (m_projectPart.toolchainType != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID
|
||||
&& m_projectPart.toolchainType != ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) {
|
||||
add("-undef");
|
||||
&& m_projectPart.toolchainType != ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) {
|
||||
if (m_skipBuiltInHeaderPathsAndDefines == SkipBuiltIn::No)
|
||||
add("-undef");
|
||||
else
|
||||
add("-fPIC");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
CompilerOptionsBuilder(const ProjectPart &projectPart,
|
||||
UseSystemHeader useSystemHeader = UseSystemHeader::No,
|
||||
SkipBuiltIn skipBuiltInHeaderPaths = SkipBuiltIn::No,
|
||||
SkipBuiltIn skipBuiltInHeaderPathsAndDefines = SkipBuiltIn::No,
|
||||
QString clangVersion = QString(),
|
||||
QString clangResourceDirectory = QString());
|
||||
virtual ~CompilerOptionsBuilder() {}
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
// Add options based on project part
|
||||
void addWordWidth();
|
||||
void addGlobalUndef();
|
||||
void addToolchainFlags();
|
||||
void addHeaderPathOptions();
|
||||
void addPrecompiledHeaderOptions(PchUsage pchUsage);
|
||||
virtual void addToolchainAndProjectMacros();
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
QString m_clangVersion;
|
||||
QString m_clangResourceDirectory;
|
||||
|
||||
SkipBuiltIn m_skipBuiltInHeaderPaths;
|
||||
SkipBuiltIn m_skipBuiltInHeaderPathsAndDefines;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
Reference in New Issue
Block a user