diff options
-rw-r--r-- | src/plugins/debugger/debuggeritem.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerkitinformation.cpp | 9 | ||||
-rw-r--r-- | src/plugins/qmakeprojectmanager/qmakekitinformation.cpp | 22 |
3 files changed, 26 insertions, 7 deletions
diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h index 5526c52130..7dbdf5949d 100644 --- a/src/plugins/debugger/debuggeritem.h +++ b/src/plugins/debugger/debuggeritem.h @@ -88,7 +88,7 @@ public: void setAbis(const QList<ProjectExplorer::Abi> &abis); void setAbi(const ProjectExplorer::Abi &abi); - enum MatchLevel { DoesNotMatch, MatchesSomewhat, MatchesWell, MatchesPerfectly }; + enum MatchLevel { DoesNotMatch, MatchesSomewhat, MatchesWell, MatchesPerfectly, MatchesPerfectlyInPath }; MatchLevel matchTarget(const ProjectExplorer::Abi &targetAbi) const; QStringList abiNames() const; diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index d5ab9d0aae..21360c000a 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -101,13 +101,20 @@ void DebuggerKitInformation::setup(Kit *k) DebuggerItem bestItem; DebuggerItem::MatchLevel bestLevel = DebuggerItem::DoesNotMatch; - + const Environment systemEnvironment = Environment::systemEnvironment(); foreach (const DebuggerItem &item, DebuggerItemManager::debuggers()) { DebuggerItem::MatchLevel level = DebuggerItem::DoesNotMatch; if (rawId.isNull()) { // Initial setup of a kit. level = item.matchTarget(tcAbi); + // Hack to prefer a debugger from PATH (e.g. autodetected) over other matches. + // This improves the situation a bit if a cross-compilation tool chain has the + // same ABI as the host. + if (level == DebuggerItem::MatchesPerfectly + && systemEnvironment.path().contains(item.command().parentDir().toString())) { + level = DebuggerItem::MatchesPerfectlyInPath; + } } else if (rawId.type() == QVariant::String) { // New structure. if (item.id() == rawId) { diff --git a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp index 57550e2e52..5e1244768a 100644 --- a/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp +++ b/src/plugins/qmakeprojectmanager/qmakekitinformation.cpp @@ -92,11 +92,23 @@ void QmakeKitInformation::setup(Kit *k) && version->qtAbis().contains(t->targetAbi()); }); if (!possibleTcs.isEmpty()) { - ToolChain *possibleTc - = Utils::findOr(possibleTcs, possibleTcs.last(), - [&spec](const ToolChain *t) { return t->suggestedMkspecList().contains(spec); }); - if (possibleTc) - ToolChainKitInformation::setAllToolChainsToMatch(k, possibleTc); + const QList<ToolChain *> goodTcs = Utils::filtered(possibleTcs, + [&spec](const ToolChain *t) { + return t->suggestedMkspecList().contains(spec); + }); + // Hack to prefer a tool chain from PATH (e.g. autodetected) over other matches. + // This improves the situation a bit if a cross-compilation tool chain has the + // same ABI as the host. + const Environment systemEnvironment = Environment::systemEnvironment(); + ToolChain *bestTc = Utils::findOrDefault(goodTcs, + [&systemEnvironment](const ToolChain *t) { + return systemEnvironment.path().contains(t->compilerCommand().parentDir().toString()); + }); + if (!bestTc) { + bestTc = goodTcs.isEmpty() ? possibleTcs.last() : goodTcs.last(); + } + if (bestTc) + ToolChainKitInformation::setAllToolChainsToMatch(k, bestTc); } } } |