diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-02-21 16:20:05 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-02-23 10:43:41 +0000 |
commit | 16d1561794c0b022c0c848f537e10685295bdc8e (patch) | |
tree | e5aa40c9eb35484fe5754d7bd634ce4a933a804e | |
parent | 4adf04c79fec078e5d8b3806a5f8e6a2c9c30eb1 (diff) | |
download | qt-creator-16d1561794c0b022c0c848f537e10685295bdc8e.tar.gz |
Improve detection of toolchain and debugger for desktop kits
In the situation where a cross-compilation tool chain has the same ABI
as the host.
Prefer toolchains and debuggers in PATH if the ABI matches. This is just
a short-term hack. It is not fail-safe, because either both tool chains
could be found somewhere in the PATH, or the "right" desktop tool chain
could not be in PATH, but manually added.
Anyhow, in many default setups this should improve the result. (In case
of failure the user can still change the kit manually.)
A better long term solution would be to make our ABI settings more
flexible.
Change-Id: I6ec5aaf45ef0b983cd949895dacdd5190f786219
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-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); } } } |