forked from qt-creator/qt-creator
GCC: Auto-detect also cross-compilers on linux
Change-Id: I925980d2b345a9f9e3ff11f369938eb8d216f1d5 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
7f4696235b
commit
7fd827e762
@@ -42,6 +42,7 @@
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <QLineEdit>
|
||||
@@ -920,10 +921,29 @@ ToolChain *GccToolChainFactory::create(Core::Id language)
|
||||
QList<ToolChain *> GccToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
||||
{
|
||||
QList<ToolChain *> tcs;
|
||||
QList<ToolChain *> known = alreadyKnown;
|
||||
tcs.append(autoDetectToolchains("g++", Abi::hostAbi(), Constants::CXX_LANGUAGE_ID,
|
||||
Constants::GCC_TOOLCHAIN_TYPEID, alreadyKnown));
|
||||
tcs.append(autoDetectToolchains("gcc", Abi::hostAbi(), Constants::C_LANGUAGE_ID,
|
||||
Constants::GCC_TOOLCHAIN_TYPEID, alreadyKnown));
|
||||
known.append(tcs);
|
||||
if (HostOsInfo::isLinuxHost()) {
|
||||
for (const QString &dir : QStringList({ "/usr/bin", "/usr/local/bin" })) {
|
||||
QDir binDir(dir);
|
||||
for (const QString &entry : binDir.entryList({"*-g++"}, QDir::Files | QDir::Executable)) {
|
||||
tcs.append(autoDetectToolchains(entry, Abi(), Constants::CXX_LANGUAGE_ID,
|
||||
Constants::GCC_TOOLCHAIN_TYPEID, known));
|
||||
known.append(tcs);
|
||||
}
|
||||
for (const QString &entry : binDir.entryList({"*-gcc"}, QDir::Files | QDir::Executable)) {
|
||||
if (entry.endsWith("c89-gcc") || entry.endsWith("c99-gcc"))
|
||||
continue;
|
||||
tcs.append(autoDetectToolchains(entry, Abi(), Constants::C_LANGUAGE_ID,
|
||||
Constants::GCC_TOOLCHAIN_TYPEID, known));
|
||||
known.append(tcs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tcs;
|
||||
}
|
||||
@@ -972,10 +992,11 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &comp
|
||||
const FileName compilerPath = systemEnvironment.searchInPath(compiler);
|
||||
if (compilerPath.isEmpty())
|
||||
return result;
|
||||
const FileName canonicalPath = FileUtils::canonicalPath(compilerPath);
|
||||
|
||||
result = Utils::filtered(alreadyKnown, [requiredTypeId, compilerPath](ToolChain *tc) {
|
||||
result = Utils::filtered(alreadyKnown, [requiredTypeId, canonicalPath](ToolChain *tc) {
|
||||
return tc->typeId() == requiredTypeId
|
||||
&& tc->compilerCommand() == compilerPath;
|
||||
&& FileUtils::canonicalPath(tc->compilerCommand()) == canonicalPath;
|
||||
});
|
||||
if (!result.isEmpty()) {
|
||||
for (ToolChain *tc : result) {
|
||||
@@ -987,6 +1008,7 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &comp
|
||||
|
||||
result = autoDetectToolChain(compilerPath, language, requiredAbi);
|
||||
|
||||
if (!requiredAbi.isNull()) {
|
||||
const Abi alternateAbi = Abi(requiredAbi.architecture(), requiredAbi.os(),
|
||||
requiredAbi.osFlavor(), requiredAbi.binaryFormat(), 32);
|
||||
ToolChain *abiTc = Utils::findOrDefault(result, [&requiredAbi, &alternateAbi](const ToolChain *tc) {
|
||||
@@ -997,6 +1019,7 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &comp
|
||||
qDeleteAll(result);
|
||||
result.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user