forked from qt-creator/qt-creator
ProjectExplorer: introduce Toolchain::priority
Can be used to prefer certain toolchain types over other if different toolchains matches the same abi. Change-Id: Ie1c62e8abfc98e8cda7f999c4df487799c8d4f13 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -502,11 +502,13 @@ void ToolChainKitAspect::setup(Kit *k)
|
||||
[abi, l](const ToolChain *t) {
|
||||
return t->targetAbi().toString() == abi && t->language() == l;
|
||||
});
|
||||
Utils::sort(possibleTcs, [](const ToolChain *tc1, const ToolChain *tc2) {
|
||||
return tc1->hostPrefersToolchain() && !tc2->hostPrefersToolchain();
|
||||
});
|
||||
if (!possibleTcs.isEmpty())
|
||||
setToolChain(k, possibleTcs.first());
|
||||
ToolChain *bestTc = nullptr;
|
||||
for (ToolChain *tc : possibleTcs) {
|
||||
if (!bestTc || tc->priority() > bestTc->priority())
|
||||
bestTc = tc;
|
||||
}
|
||||
if (bestTc)
|
||||
setToolChain(k, bestTc);
|
||||
else
|
||||
clearToolChain(k, l);
|
||||
}
|
||||
|
@@ -1746,6 +1746,11 @@ bool ClangClToolChain::operator==(const ToolChain &other) const
|
||||
return m_clangPath == clangClTc->m_clangPath;
|
||||
}
|
||||
|
||||
int ClangClToolChain::priority() const
|
||||
{
|
||||
return MsvcToolChain::priority() - 1;
|
||||
}
|
||||
|
||||
Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
const Utils::Environment &env) const
|
||||
{
|
||||
@@ -2050,6 +2055,11 @@ bool MsvcToolChain::operator==(const ToolChain &other) const
|
||||
&& m_varsBatArg == msvcTc->m_varsBatArg;
|
||||
}
|
||||
|
||||
int MsvcToolChain::priority() const
|
||||
{
|
||||
return hostPrefersToolchain() ? PriorityHigh : PriorityNormal;
|
||||
}
|
||||
|
||||
void MsvcToolChain::cancelMsvcToolChainDetection()
|
||||
{
|
||||
envModThreadPool()->clear();
|
||||
|
@@ -98,6 +98,8 @@ public:
|
||||
|
||||
bool isJobCountSupported() const override { return false; }
|
||||
|
||||
int priority() const override;
|
||||
|
||||
static void cancelMsvcToolChainDetection();
|
||||
static Utils::optional<QString> generateEnvironmentSettings(const Utils::Environment &env,
|
||||
const QString &batchFile,
|
||||
@@ -187,6 +189,8 @@ public:
|
||||
|
||||
bool operator==(const ToolChain &) const override;
|
||||
|
||||
int priority() const override;
|
||||
|
||||
private:
|
||||
QString m_clangPath;
|
||||
};
|
||||
|
@@ -172,6 +172,14 @@ public:
|
||||
static Utils::LanguageVersion cxxLanguageVersion(const QByteArray &cplusplusMacroValue);
|
||||
static Utils::LanguageVersion languageVersion(const Utils::Id &language, const Macros ¯os);
|
||||
|
||||
enum Priority {
|
||||
PriorityLow = 0,
|
||||
PriorityNormal = 10,
|
||||
PriorityHigh = 20,
|
||||
};
|
||||
|
||||
virtual int priority() const { return PriorityNormal; }
|
||||
|
||||
protected:
|
||||
explicit ToolChain(Utils::Id typeId);
|
||||
|
||||
|
@@ -240,7 +240,7 @@ void QtKitAspect::fix(Kit *k)
|
||||
return true;
|
||||
if (!tc1ExactMatch && tc2ExactMatch)
|
||||
return false;
|
||||
return tc1->hostPrefersToolchain() && !tc2->hostPrefersToolchain();
|
||||
return tc1->priority() > tc2->priority();
|
||||
});
|
||||
|
||||
const QList<ToolChain *> goodTcs = Utils::filtered(possibleTcs,
|
||||
|
Reference in New Issue
Block a user