forked from qt-creator/qt-creator
CompilationDatabase: Asjust the sysroot and target handling
If the sysroot option is found - set it as a kit sysroot (only in CompilationDatabase project where we have a cloned kit which does not affect the other existing kits). In other cases use the backup for the sysroot from the toolchain (can exist for clang toolchains based on mingw). Provide target when searching builtin include paths for clang. Fixes: QTCREATORBUG-22339 Change-Id: Ibe07c2e490ba4f7e0d259e6df698d641dbfd0298 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
Ivan Donchevskii
parent
a5148b5363
commit
cc9d246b02
@@ -302,13 +302,13 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
|||||||
|
|
||||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||||
|
|
||||||
return [env, compilerCommand, headerPathsCache, languageId]
|
return [env, compilerCommand, headerPathsCache, languageId](const QStringList &flags,
|
||||||
(const QStringList &flags, const QString &fileName) {
|
const QString &fileName,
|
||||||
|
const QString &) {
|
||||||
Q_UNUSED(flags)
|
Q_UNUSED(flags)
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(fileName)
|
||||||
|
|
||||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, languageId,
|
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, languageId, env.toStringList());
|
||||||
env.toStringList());
|
|
||||||
headerPathsCache->insert({}, paths);
|
headerPathsCache->insert({}, paths);
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
@@ -318,7 +318,7 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
|||||||
HeaderPaths IarToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
HeaderPaths IarToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||||
const FileName &fileName) const
|
const FileName &fileName) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString());
|
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IarToolChain::addToEnvironment(Environment &env) const
|
void IarToolChain::addToEnvironment(Environment &env) const
|
||||||
|
@@ -315,8 +315,8 @@ ToolChain::BuiltInHeaderPathsRunner KeilToolchain::createBuiltInHeaderPathsRunne
|
|||||||
|
|
||||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||||
|
|
||||||
return [compilerCommand, headerPathsCache]
|
return [compilerCommand,
|
||||||
(const QStringList &flags, const QString &fileName) {
|
headerPathsCache](const QStringList &flags, const QString &fileName, const QString &) {
|
||||||
Q_UNUSED(flags)
|
Q_UNUSED(flags)
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(fileName)
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ ToolChain::BuiltInHeaderPathsRunner KeilToolchain::createBuiltInHeaderPathsRunne
|
|||||||
HeaderPaths KeilToolchain::builtInHeaderPaths(const QStringList &cxxFlags,
|
HeaderPaths KeilToolchain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||||
const FileName &fileName) const
|
const FileName &fileName) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString());
|
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeilToolchain::addToEnvironment(Environment &env) const
|
void KeilToolchain::addToEnvironment(Environment &env) const
|
||||||
|
@@ -298,13 +298,13 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
|||||||
|
|
||||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||||
|
|
||||||
return [env, compilerCommand, headerPathsCache, languageId, abi]
|
return [env, compilerCommand, headerPathsCache, languageId, abi](const QStringList &flags,
|
||||||
(const QStringList &flags, const QString &fileName) {
|
const QString &fileName,
|
||||||
|
const QString &) {
|
||||||
Q_UNUSED(flags)
|
Q_UNUSED(flags)
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(fileName)
|
||||||
|
|
||||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, env.toStringList(),
|
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, env.toStringList(), abi);
|
||||||
abi);
|
|
||||||
headerPathsCache->insert({}, paths);
|
headerPathsCache->insert({}, paths);
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
@@ -314,7 +314,7 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
|||||||
HeaderPaths SdccToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
HeaderPaths SdccToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||||
const FileName &fileName) const
|
const FileName &fileName) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString());
|
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdccToolChain::addToEnvironment(Environment &env) const
|
void SdccToolChain::addToEnvironment(Environment &env) const
|
||||||
|
@@ -92,6 +92,11 @@ bool isGccCompiler(const QString &compilerName)
|
|||||||
|| (compilerName.contains("g++") && !compilerName.contains("clang"));
|
|| (compilerName.contains("g++") && !compilerName.contains("clang"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isClCompatibleCompiler(const QString &compilerName)
|
||||||
|
{
|
||||||
|
return compilerName.endsWith("cl");
|
||||||
|
}
|
||||||
|
|
||||||
Core::Id getCompilerId(QString compilerName)
|
Core::Id getCompilerId(QString compilerName)
|
||||||
{
|
{
|
||||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||||
@@ -99,9 +104,9 @@ Core::Id getCompilerId(QString compilerName)
|
|||||||
compilerName.chop(4);
|
compilerName.chop(4);
|
||||||
if (isGccCompiler(compilerName))
|
if (isGccCompiler(compilerName))
|
||||||
return ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
return ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
||||||
|
if (isClCompatibleCompiler(compilerName))
|
||||||
// Default is clang-cl
|
|
||||||
return ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID;
|
return ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID;
|
||||||
|
return ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID;
|
||||||
}
|
}
|
||||||
if (isGccCompiler(compilerName))
|
if (isGccCompiler(compilerName))
|
||||||
return ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
|
return ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
|
||||||
@@ -196,8 +201,7 @@ void addDriverModeFlagIfNeeded(const ToolChain *toolchain,
|
|||||||
|
|
||||||
CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile,
|
CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile,
|
||||||
Kit *kit,
|
Kit *kit,
|
||||||
ToolChain *&cToolchain,
|
CppTools::KitInfo &kitInfo,
|
||||||
ToolChain *&cxxToolchain,
|
|
||||||
const QString &workingDir,
|
const QString &workingDir,
|
||||||
const Utils::FileName &fileName,
|
const Utils::FileName &fileName,
|
||||||
QStringList flags)
|
QStringList flags)
|
||||||
@@ -212,7 +216,8 @@ CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile,
|
|||||||
flags,
|
flags,
|
||||||
headerPaths,
|
headerPaths,
|
||||||
macros,
|
macros,
|
||||||
fileKind);
|
fileKind,
|
||||||
|
kitInfo.sysRootPath);
|
||||||
|
|
||||||
CppTools::RawProjectPart rpp;
|
CppTools::RawProjectPart rpp;
|
||||||
rpp.setProjectFileLocation(projectFile.toString());
|
rpp.setProjectFileLocation(projectFile.toString());
|
||||||
@@ -224,21 +229,23 @@ CppTools::RawProjectPart makeRawProjectPart(const Utils::FileName &projectFile,
|
|||||||
|
|
||||||
if (fileKind == CppTools::ProjectFile::Kind::CHeader
|
if (fileKind == CppTools::ProjectFile::Kind::CHeader
|
||||||
|| fileKind == CppTools::ProjectFile::Kind::CSource) {
|
|| fileKind == CppTools::ProjectFile::Kind::CSource) {
|
||||||
if (!cToolchain) {
|
if (!kitInfo.cToolChain) {
|
||||||
cToolchain = toolchainFromFlags(kit, originalFlags,
|
kitInfo.cToolChain = toolchainFromFlags(kit,
|
||||||
|
originalFlags,
|
||||||
ProjectExplorer::Constants::C_LANGUAGE_ID);
|
ProjectExplorer::Constants::C_LANGUAGE_ID);
|
||||||
ToolChainKitAspect::setToolChain(kit, cToolchain);
|
ToolChainKitAspect::setToolChain(kit, kitInfo.cToolChain);
|
||||||
}
|
}
|
||||||
addDriverModeFlagIfNeeded(cToolchain, flags, originalFlags);
|
addDriverModeFlagIfNeeded(kitInfo.cToolChain, flags, originalFlags);
|
||||||
rpp.setFlagsForC({cToolchain, flags});
|
rpp.setFlagsForC({kitInfo.cToolChain, flags});
|
||||||
} else {
|
} else {
|
||||||
if (!cxxToolchain) {
|
if (!kitInfo.cxxToolChain) {
|
||||||
cxxToolchain = toolchainFromFlags(kit, originalFlags,
|
kitInfo.cxxToolChain = toolchainFromFlags(kit,
|
||||||
|
originalFlags,
|
||||||
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
ToolChainKitAspect::setToolChain(kit, cxxToolchain);
|
ToolChainKitAspect::setToolChain(kit, kitInfo.cxxToolChain);
|
||||||
}
|
}
|
||||||
addDriverModeFlagIfNeeded(cxxToolchain, flags, originalFlags);
|
addDriverModeFlagIfNeeded(kitInfo.cxxToolChain, flags, originalFlags);
|
||||||
rpp.setFlagsForCxx({cxxToolchain, flags});
|
rpp.setFlagsForCxx({kitInfo.cxxToolChain, flags});
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpp;
|
return rpp;
|
||||||
@@ -433,8 +440,7 @@ void CompilationDatabaseProject::buildTreeAndProjectParts(const Utils::FileName
|
|||||||
|
|
||||||
CppTools::RawProjectPart rpp = makeRawProjectPart(projectFile,
|
CppTools::RawProjectPart rpp = makeRawProjectPart(projectFile,
|
||||||
m_kit.get(),
|
m_kit.get(),
|
||||||
kitInfo.cToolChain,
|
kitInfo,
|
||||||
kitInfo.cxxToolChain,
|
|
||||||
entry.workingDir,
|
entry.workingDir,
|
||||||
entry.fileName,
|
entry.fileName,
|
||||||
entry.flags);
|
entry.flags);
|
||||||
|
@@ -98,7 +98,8 @@ void filteredFlags(const QString &fileName,
|
|||||||
QStringList &flags,
|
QStringList &flags,
|
||||||
HeaderPaths &headerPaths,
|
HeaderPaths &headerPaths,
|
||||||
Macros ¯os,
|
Macros ¯os,
|
||||||
CppTools::ProjectFile::Kind &fileKind)
|
CppTools::ProjectFile::Kind &fileKind,
|
||||||
|
QString &sysRoot)
|
||||||
{
|
{
|
||||||
if (flags.empty())
|
if (flags.empty())
|
||||||
return;
|
return;
|
||||||
@@ -182,6 +183,12 @@ void filteredFlags(const QString &fileName,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flag.startsWith("--sysroot=")) {
|
||||||
|
if (sysRoot.isEmpty())
|
||||||
|
sysRoot = flag.mid(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((flag.startsWith("-std=") || flag.startsWith("/std:"))
|
if ((flag.startsWith("-std=") || flag.startsWith("/std:"))
|
||||||
&& fileKind == CppTools::ProjectFile::Unclassified) {
|
&& fileKind == CppTools::ProjectFile::Unclassified) {
|
||||||
const bool cpp = (flag.contains("c++") || flag.contains("gnu++"));
|
const bool cpp = (flag.contains("c++") || flag.contains("gnu++"));
|
||||||
|
@@ -45,7 +45,8 @@ void filteredFlags(const QString &fileName,
|
|||||||
QStringList &flags,
|
QStringList &flags,
|
||||||
QVector<ProjectExplorer::HeaderPath> &headerPaths,
|
QVector<ProjectExplorer::HeaderPath> &headerPaths,
|
||||||
QVector<ProjectExplorer::Macro> ¯os,
|
QVector<ProjectExplorer::Macro> ¯os,
|
||||||
CppTools::ProjectFile::Kind &fileKind);
|
CppTools::ProjectFile::Kind &fileKind,
|
||||||
|
QString &sysRoot);
|
||||||
|
|
||||||
QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache);
|
QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache);
|
||||||
|
|
||||||
|
@@ -182,7 +182,9 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
|||||||
// Header paths
|
// Header paths
|
||||||
if (tcInfo.headerPathsRunner) {
|
if (tcInfo.headerPathsRunner) {
|
||||||
const ProjectExplorer::HeaderPaths builtInHeaderPaths
|
const ProjectExplorer::HeaderPaths builtInHeaderPaths
|
||||||
= tcInfo.headerPathsRunner(flags.commandLineFlags, tcInfo.sysRootPath);
|
= tcInfo.headerPathsRunner(flags.commandLineFlags,
|
||||||
|
tcInfo.sysRootPath,
|
||||||
|
tcInfo.targetTriple);
|
||||||
|
|
||||||
ProjectExplorer::HeaderPaths &headerPaths = part->headerPaths;
|
ProjectExplorer::HeaderPaths &headerPaths = part->headerPaths;
|
||||||
for (const ProjectExplorer::HeaderPath &header : builtInHeaderPaths) {
|
for (const ProjectExplorer::HeaderPath &header : builtInHeaderPaths) {
|
||||||
|
@@ -169,7 +169,7 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
|
|||||||
const HeaderPaths builtInHeaderPaths = m_builtInHeaderPaths;
|
const HeaderPaths builtInHeaderPaths = m_builtInHeaderPaths;
|
||||||
|
|
||||||
// This runner must be thread-safe!
|
// This runner must be thread-safe!
|
||||||
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &) {
|
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &, const QString &) {
|
||||||
HeaderPaths flagHeaderPaths;
|
HeaderPaths flagHeaderPaths;
|
||||||
for (const QString &cxxFlag : cxxFlags) {
|
for (const QString &cxxFlag : cxxFlags) {
|
||||||
if (cxxFlag.startsWith(QLatin1String("-I"))) {
|
if (cxxFlag.startsWith(QLatin1String("-I"))) {
|
||||||
@@ -184,7 +184,7 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
|
|||||||
HeaderPaths CustomToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
HeaderPaths CustomToolChain::builtInHeaderPaths(const QStringList &cxxFlags,
|
||||||
const FileName &fileName) const
|
const FileName &fileName) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString());
|
return createBuiltInHeaderPathsRunner()(cxxFlags, fileName.toString(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomToolChain::addToEnvironment(Environment &env) const
|
void CustomToolChain::addToEnvironment(Environment &env) const
|
||||||
|
@@ -569,33 +569,34 @@ void GccToolChain::initExtraHeaderPathsFunction(ExtraHeaderPathsFunction &&extra
|
|||||||
m_extraHeaderPathsFunction = std::move(extraHeaderPathsFunction);
|
m_extraHeaderPathsFunction = std::move(extraHeaderPathsFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner() const
|
HeaderPaths GccToolChain::builtInHeaderPaths(const Utils::Environment &env,
|
||||||
|
const Utils::FileName &compilerCommand,
|
||||||
|
const QStringList &platformCodeGenFlags,
|
||||||
|
OptionsReinterpreter reinterpretOptions,
|
||||||
|
std::shared_ptr<Cache<HeaderPaths>> headerCache,
|
||||||
|
Core::Id languageId,
|
||||||
|
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||||
|
const QStringList &flags,
|
||||||
|
const QString &sysRoot,
|
||||||
|
const QString &originalTargetTriple)
|
||||||
{
|
{
|
||||||
// Using a clean environment breaks ccache/distcc/etc.
|
QStringList arguments = gccPrepareArguments(flags,
|
||||||
Environment env = Environment::systemEnvironment();
|
sysRoot,
|
||||||
addToEnvironment(env);
|
platformCodeGenFlags,
|
||||||
|
languageId,
|
||||||
|
reinterpretOptions);
|
||||||
|
|
||||||
const Utils::FileName compilerCommand = m_compilerCommand;
|
// Must be clang case only.
|
||||||
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
|
if (!originalTargetTriple.isEmpty())
|
||||||
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
|
arguments << "-target" << originalTargetTriple;
|
||||||
QTC_CHECK(reinterpretOptions);
|
|
||||||
std::shared_ptr<Cache<HeaderPaths>> headerCache = m_headerPathsCache;
|
|
||||||
Core::Id languageId = language();
|
|
||||||
|
|
||||||
// This runner must be thread-safe!
|
|
||||||
return [env, compilerCommand, platformCodeGenFlags, reinterpretOptions, headerCache, languageId,
|
|
||||||
extraHeaderPathsFunction = m_extraHeaderPathsFunction]
|
|
||||||
(const QStringList &flags, const QString &sysRoot) {
|
|
||||||
|
|
||||||
QStringList arguments = gccPrepareArguments(flags, sysRoot, platformCodeGenFlags,
|
|
||||||
languageId, reinterpretOptions);
|
|
||||||
|
|
||||||
const Utils::optional<HeaderPaths> cachedPaths = headerCache->check(arguments);
|
const Utils::optional<HeaderPaths> cachedPaths = headerCache->check(arguments);
|
||||||
if (cachedPaths)
|
if (cachedPaths)
|
||||||
return cachedPaths.value();
|
return cachedPaths.value();
|
||||||
|
|
||||||
HeaderPaths paths = gccHeaderPaths(findLocalCompiler(compilerCommand, env),
|
HeaderPaths paths = gccHeaderPaths(findLocalCompiler(compilerCommand, env),
|
||||||
arguments, env.toStringList());
|
arguments,
|
||||||
|
env.toStringList());
|
||||||
extraHeaderPathsFunction(paths);
|
extraHeaderPathsFunction(paths);
|
||||||
headerCache->insert(arguments, paths);
|
headerCache->insert(arguments, paths);
|
||||||
|
|
||||||
@@ -603,18 +604,48 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
|
|||||||
for (const HeaderPath &hp : paths) {
|
for (const HeaderPath &hp : paths) {
|
||||||
qCDebug(gccLog) << compilerCommand.toUserOutput()
|
qCDebug(gccLog) << compilerCommand.toUserOutput()
|
||||||
<< (languageId == Constants::CXX_LANGUAGE_ID ? ": C++ [" : ": C [")
|
<< (languageId == Constants::CXX_LANGUAGE_ID ? ": C++ [" : ": C [")
|
||||||
<< arguments.join(", ") << "]"
|
<< arguments.join(", ") << "]" << hp.path;
|
||||||
<< hp.path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner() const
|
||||||
|
{
|
||||||
|
// Using a clean environment breaks ccache/distcc/etc.
|
||||||
|
Environment env = Environment::systemEnvironment();
|
||||||
|
addToEnvironment(env);
|
||||||
|
|
||||||
|
// This runner must be thread-safe!
|
||||||
|
return [env,
|
||||||
|
compilerCommand = m_compilerCommand,
|
||||||
|
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||||
|
reinterpretOptions = m_optionsReinterpreter,
|
||||||
|
headerCache = m_headerPathsCache,
|
||||||
|
languageId = language(),
|
||||||
|
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||||
|
const QString &sysRoot,
|
||||||
|
const QString &) {
|
||||||
|
return builtInHeaderPaths(env,
|
||||||
|
compilerCommand,
|
||||||
|
platformCodeGenFlags,
|
||||||
|
reinterpretOptions,
|
||||||
|
headerCache,
|
||||||
|
languageId,
|
||||||
|
extraHeaderPathsFunction,
|
||||||
|
flags,
|
||||||
|
sysRoot,
|
||||||
|
/*target=*/""); // Target must be empty for gcc.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderPaths GccToolChain::builtInHeaderPaths(const QStringList &flags,
|
HeaderPaths GccToolChain::builtInHeaderPaths(const QStringList &flags,
|
||||||
const FileName &sysRoot) const
|
const FileName &sysRootPath) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(flags, sysRoot.toString());
|
return createBuiltInHeaderPathsRunner()(flags,
|
||||||
|
sysRootPath.isEmpty() ? sysRoot()
|
||||||
|
: sysRootPath.toString(),
|
||||||
|
originalTargetTriple());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GccToolChain::addCommandPathToEnvironment(const FileName &command, Environment &env)
|
void GccToolChain::addCommandPathToEnvironment(const FileName &command, Environment &env)
|
||||||
@@ -1398,6 +1429,35 @@ QString ClangToolChain::sysRoot() const
|
|||||||
return mingwCompiler.parentDir().parentDir().toString();
|
return mingwCompiler.parentDir().parentDir().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolChain::BuiltInHeaderPathsRunner ClangToolChain::createBuiltInHeaderPathsRunner() const
|
||||||
|
{
|
||||||
|
// Using a clean environment breaks ccache/distcc/etc.
|
||||||
|
Environment env = Environment::systemEnvironment();
|
||||||
|
addToEnvironment(env);
|
||||||
|
|
||||||
|
// This runner must be thread-safe!
|
||||||
|
return [env,
|
||||||
|
compilerCommand = m_compilerCommand,
|
||||||
|
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||||
|
reinterpretOptions = m_optionsReinterpreter,
|
||||||
|
headerCache = m_headerPathsCache,
|
||||||
|
languageId = language(),
|
||||||
|
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||||
|
const QString &sysRoot,
|
||||||
|
const QString &target) {
|
||||||
|
return builtInHeaderPaths(env,
|
||||||
|
compilerCommand,
|
||||||
|
platformCodeGenFlags,
|
||||||
|
reinterpretOptions,
|
||||||
|
headerCache,
|
||||||
|
languageId,
|
||||||
|
extraHeaderPathsFunction,
|
||||||
|
flags,
|
||||||
|
sysRoot,
|
||||||
|
target);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<ToolChainConfigWidget> ClangToolChain::createConfigurationWidget()
|
std::unique_ptr<ToolChainConfigWidget> ClangToolChain::createConfigurationWidget()
|
||||||
{
|
{
|
||||||
return std::make_unique<ClangToolChainConfigWidget>(this);
|
return std::make_unique<ClangToolChainConfigWidget>(this);
|
||||||
|
@@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override;
|
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override;
|
||||||
HeaderPaths builtInHeaderPaths(const QStringList &flags,
|
HeaderPaths builtInHeaderPaths(const QStringList &flags,
|
||||||
const Utils::FileName &sysRoot) const override;
|
const Utils::FileName &sysRootPath) const override;
|
||||||
|
|
||||||
void addToEnvironment(Utils::Environment &env) const override;
|
void addToEnvironment(Utils::Environment &env) const override;
|
||||||
QString makeCommand(const Utils::Environment &environment) const override;
|
QString makeCommand(const Utils::Environment &environment) const override;
|
||||||
@@ -151,6 +151,17 @@ protected:
|
|||||||
using ExtraHeaderPathsFunction = std::function<void(HeaderPaths &)>;
|
using ExtraHeaderPathsFunction = std::function<void(HeaderPaths &)>;
|
||||||
void initExtraHeaderPathsFunction(ExtraHeaderPathsFunction &&extraHeaderPathsFunction) const;
|
void initExtraHeaderPathsFunction(ExtraHeaderPathsFunction &&extraHeaderPathsFunction) const;
|
||||||
|
|
||||||
|
static HeaderPaths builtInHeaderPaths(const Utils::Environment &env,
|
||||||
|
const Utils::FileName &compilerCommand,
|
||||||
|
const QStringList &platformCodeGenFlags,
|
||||||
|
OptionsReinterpreter reinterpretOptions,
|
||||||
|
std::shared_ptr<Cache<HeaderPaths>> headerCache,
|
||||||
|
Core::Id languageId,
|
||||||
|
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||||
|
const QStringList &flags,
|
||||||
|
const QString &sysRoot,
|
||||||
|
const QString &originalTargetTriple);
|
||||||
|
|
||||||
static HeaderPaths gccHeaderPaths(const Utils::FileName &gcc, const QStringList &args,
|
static HeaderPaths gccHeaderPaths(const Utils::FileName &gcc, const QStringList &args,
|
||||||
const QStringList &env);
|
const QStringList &env);
|
||||||
|
|
||||||
@@ -179,12 +190,16 @@ private:
|
|||||||
Core::Id languageId,
|
Core::Id languageId,
|
||||||
OptionsReinterpreter reinterpretOptions);
|
OptionsReinterpreter reinterpretOptions);
|
||||||
|
|
||||||
|
protected:
|
||||||
Utils::FileName m_compilerCommand;
|
Utils::FileName m_compilerCommand;
|
||||||
QStringList m_platformCodeGenFlags;
|
QStringList m_platformCodeGenFlags;
|
||||||
QStringList m_platformLinkerFlags;
|
QStringList m_platformLinkerFlags;
|
||||||
|
|
||||||
OptionsReinterpreter m_optionsReinterpreter = [](const QStringList &v) { return v; };
|
OptionsReinterpreter m_optionsReinterpreter = [](const QStringList &v) { return v; };
|
||||||
|
mutable std::shared_ptr<Cache<HeaderPaths>> m_headerPathsCache;
|
||||||
|
mutable ExtraHeaderPathsFunction m_extraHeaderPathsFunction = [](HeaderPaths &) {};
|
||||||
|
|
||||||
|
private:
|
||||||
Abi m_targetAbi;
|
Abi m_targetAbi;
|
||||||
mutable QList<Abi> m_supportedAbis;
|
mutable QList<Abi> m_supportedAbis;
|
||||||
mutable QString m_originalTargetTriple;
|
mutable QString m_originalTargetTriple;
|
||||||
@@ -192,8 +207,6 @@ private:
|
|||||||
mutable QString m_version;
|
mutable QString m_version;
|
||||||
|
|
||||||
mutable std::shared_ptr<Cache<MacroInspectionReport, 64>> m_predefinedMacrosCache;
|
mutable std::shared_ptr<Cache<MacroInspectionReport, 64>> m_predefinedMacrosCache;
|
||||||
mutable std::shared_ptr<Cache<HeaderPaths>> m_headerPathsCache;
|
|
||||||
mutable ExtraHeaderPathsFunction m_extraHeaderPathsFunction = [](HeaderPaths &) {};
|
|
||||||
|
|
||||||
friend class Internal::GccToolChainConfigWidget;
|
friend class Internal::GccToolChainConfigWidget;
|
||||||
friend class Internal::GccToolChainFactory;
|
friend class Internal::GccToolChainFactory;
|
||||||
@@ -226,6 +239,8 @@ public:
|
|||||||
QString originalTargetTriple() const override;
|
QString originalTargetTriple() const override;
|
||||||
QString sysRoot() const override;
|
QString sysRoot() const override;
|
||||||
|
|
||||||
|
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override;
|
||||||
|
|
||||||
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
||||||
|
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
|
@@ -1131,7 +1131,7 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
|
|||||||
Utils::Environment env(m_lastEnvironment);
|
Utils::Environment env(m_lastEnvironment);
|
||||||
addToEnvironment(env);
|
addToEnvironment(env);
|
||||||
|
|
||||||
return [this, env](const QStringList &, const QString &) {
|
return [this, env](const QStringList &, const QString &, const QString &) {
|
||||||
QMutexLocker locker(m_headerPathsMutex);
|
QMutexLocker locker(m_headerPathsMutex);
|
||||||
if (m_headerPaths.isEmpty()) {
|
if (m_headerPaths.isEmpty()) {
|
||||||
foreach (const QString &path,
|
foreach (const QString &path,
|
||||||
@@ -1146,7 +1146,7 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
|
|||||||
HeaderPaths MsvcToolChain::builtInHeaderPaths(const QStringList &cxxflags,
|
HeaderPaths MsvcToolChain::builtInHeaderPaths(const QStringList &cxxflags,
|
||||||
const Utils::FileName &sysRoot) const
|
const Utils::FileName &sysRoot) const
|
||||||
{
|
{
|
||||||
return createBuiltInHeaderPathsRunner()(cxxflags, sysRoot.toString());
|
return createBuiltInHeaderPathsRunner()(cxxflags, sysRoot.toString(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MsvcToolChain::addToEnvironment(Utils::Environment &env) const
|
void MsvcToolChain::addToEnvironment(Utils::Environment &env) const
|
||||||
|
@@ -126,8 +126,8 @@ public:
|
|||||||
virtual Macros predefinedMacros(const QStringList &cxxflags) const = 0;
|
virtual Macros predefinedMacros(const QStringList &cxxflags) const = 0;
|
||||||
|
|
||||||
// A BuiltInHeaderPathsRunner is created in the ui thread and runs in another thread.
|
// A BuiltInHeaderPathsRunner is created in the ui thread and runs in another thread.
|
||||||
using BuiltInHeaderPathsRunner = std::function<HeaderPaths(const QStringList &cxxflags,
|
using BuiltInHeaderPathsRunner = std::function<HeaderPaths(
|
||||||
const QString &sysRoot)>;
|
const QStringList &cxxflags, const QString &sysRoot, const QString &originalTargetTriple)>;
|
||||||
virtual BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const = 0;
|
virtual BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const = 0;
|
||||||
virtual HeaderPaths builtInHeaderPaths(const QStringList &cxxflags,
|
virtual HeaderPaths builtInHeaderPaths(const QStringList &cxxflags,
|
||||||
const Utils::FileName &sysRoot) const = 0;
|
const Utils::FileName &sysRoot) const = 0;
|
||||||
|
Reference in New Issue
Block a user