forked from qt-creator/qt-creator
ProjectExplorer: Rename ToolchainBundle::AutoRegister
The old name was misleasing as to what would get registered. The new name makes it clear that it's about the missing toolchains. Fixes: QTCREATORBUG-31877 Change-Id: I9f7121bb6fd438c01be558fdb20cfc411f5fa733 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -1459,7 +1459,7 @@ void AndroidConfigurations::updateAutomaticKitList()
|
|||||||
ToolchainManager::toolchains([](const Toolchain *tc) {
|
ToolchainManager::toolchains([](const Toolchain *tc) {
|
||||||
return tc->isAutoDetected() && tc->typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID;
|
return tc->isAutoDetected() && tc->typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID;
|
||||||
}),
|
}),
|
||||||
ToolchainBundle::AutoRegister::On),
|
ToolchainBundle::HandleMissing::CreateAndRegister),
|
||||||
[](const ToolchainBundle &b) { return b.isCompletelyValid(); });
|
[](const ToolchainBundle &b) { return b.isCompletelyValid(); });
|
||||||
|
|
||||||
QList<Kit *> unhandledKits = existingKits;
|
QList<Kit *> unhandledKits = existingKits;
|
||||||
|
@@ -265,8 +265,8 @@ Toolchains KitDetectorPrivate::autoDetectToolchains()
|
|||||||
toolchain->setDetectionSource(m_sharedId);
|
toolchain->setDetectionSource(m_sharedId);
|
||||||
}
|
}
|
||||||
ToolchainManager::registerToolchains(newToolchains);
|
ToolchainManager::registerToolchains(newToolchains);
|
||||||
const QList<ToolchainBundle> bundles
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
= ToolchainBundle::collectBundles(newToolchains, ToolchainBundle::AutoRegister::On);
|
newToolchains, ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
alreadyKnown.append(newToolchains);
|
alreadyKnown.append(newToolchains);
|
||||||
allNewToolchains.append(newToolchains);
|
allNewToolchains.append(newToolchains);
|
||||||
}
|
}
|
||||||
@@ -358,8 +358,8 @@ void KitDetectorPrivate::autoDetect()
|
|||||||
|
|
||||||
const Toolchains toolchainCandidates = ToolchainManager::toolchains(
|
const Toolchains toolchainCandidates = ToolchainManager::toolchains(
|
||||||
[this](const Toolchain *tc) { return tc->detectionSource() == m_sharedId; });
|
[this](const Toolchain *tc) { return tc->detectionSource() == m_sharedId; });
|
||||||
const QList<ToolchainBundle> bundles
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
= ToolchainBundle::collectBundles(toolchainCandidates, ToolchainBundle::AutoRegister::On);
|
toolchainCandidates, ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
|
|
||||||
// Try to find a matching Qt/Toolchain pair.
|
// Try to find a matching Qt/Toolchain pair.
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
@@ -2136,7 +2136,7 @@ void GccToolchainConfigWidget::updateParentToolchainComboBox()
|
|||||||
if (bundle().isAutoDetected() || m_parentToolchainCombo->count() == 0)
|
if (bundle().isAutoDetected() || m_parentToolchainCombo->count() == 0)
|
||||||
parentBundleId = bundleIdFromId(bundle().get(&GccToolchain::parentToolchainId));
|
parentBundleId = bundleIdFromId(bundle().get(&GccToolchain::parentToolchainId));
|
||||||
const QList<ToolchainBundle> mingwBundles = Utils::filtered(
|
const QList<ToolchainBundle> mingwBundles = Utils::filtered(
|
||||||
ToolchainBundle::collectBundles(ToolchainBundle::AutoRegister::NotApplicable),
|
ToolchainBundle::collectBundles(ToolchainBundle::HandleMissing::NotApplicable),
|
||||||
[](const ToolchainBundle &b) { return b.type() == Constants::MINGW_TOOLCHAIN_TYPEID; });
|
[](const ToolchainBundle &b) { return b.type() == Constants::MINGW_TOOLCHAIN_TYPEID; });
|
||||||
const auto parentBundle
|
const auto parentBundle
|
||||||
= Utils::findOr(mingwBundles, std::nullopt, [parentBundleId](const ToolchainBundle &b) {
|
= Utils::findOr(mingwBundles, std::nullopt, [parentBundleId](const ToolchainBundle &b) {
|
||||||
|
@@ -254,7 +254,7 @@ void KitManager::restoreKits()
|
|||||||
QHash<Abi, QHash<LanguageCategory, std::optional<ToolchainBundle>>> uniqueToolchains;
|
QHash<Abi, QHash<LanguageCategory, std::optional<ToolchainBundle>>> uniqueToolchains;
|
||||||
|
|
||||||
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
ToolchainBundle::AutoRegister::On);
|
ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
for (const ToolchainBundle &bundle : bundles) {
|
for (const ToolchainBundle &bundle : bundles) {
|
||||||
auto &bestBundle
|
auto &bestBundle
|
||||||
= uniqueToolchains[bundle.targetAbi()][bundle.factory()->languageCategory()];
|
= uniqueToolchains[bundle.targetAbi()][bundle.factory()->languageCategory()];
|
||||||
|
@@ -1659,7 +1659,7 @@ void ClangClToolchainConfigWidget::applyImpl()
|
|||||||
const QString displayedVarsBat = m_varsBatDisplayCombo->currentText();
|
const QString displayedVarsBat = m_varsBatDisplayCombo->currentText();
|
||||||
Toolchains results = detectClangClToolChainInPath(clangClPath, {}, displayedVarsBat);
|
Toolchains results = detectClangClToolChainInPath(clangClPath, {}, displayedVarsBat);
|
||||||
const QList<ToolchainBundle> bundles
|
const QList<ToolchainBundle> bundles
|
||||||
= ToolchainBundle::collectBundles(results, ToolchainBundle::AutoRegister::NotApplicable);
|
= ToolchainBundle::collectBundles(results, ToolchainBundle::HandleMissing::NotApplicable);
|
||||||
|
|
||||||
if (bundles.isEmpty()) {
|
if (bundles.isEmpty()) {
|
||||||
bundle().set(&ClangClToolchain::resetVarsBat);
|
bundle().set(&ClangClToolchain::resetVarsBat);
|
||||||
|
@@ -915,7 +915,7 @@ void AsyncToolchainDetector::run()
|
|||||||
* - There is exactly one toolchain in the list for every language supported by the factory.
|
* - There is exactly one toolchain in the list for every language supported by the factory.
|
||||||
* - If there is a C compiler, it comes first in the list.
|
* - If there is a C compiler, it comes first in the list.
|
||||||
*/
|
*/
|
||||||
ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister autoRegister)
|
ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, HandleMissing handleMissing)
|
||||||
: m_toolchains(toolchains)
|
: m_toolchains(toolchains)
|
||||||
{
|
{
|
||||||
// Check pre-conditions.
|
// Check pre-conditions.
|
||||||
@@ -930,7 +930,7 @@ ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister auto
|
|||||||
QTC_ASSERT(tc->bundleId() == toolchains.first()->bundleId(), return);
|
QTC_ASSERT(tc->bundleId() == toolchains.first()->bundleId(), return);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMissingToolchains(autoRegister);
|
addMissingToolchains(handleMissing);
|
||||||
|
|
||||||
// Check post-conditions.
|
// Check post-conditions.
|
||||||
QTC_ASSERT(m_toolchains.size() == m_toolchains.first()->factory()->supportedLanguages().size(),
|
QTC_ASSERT(m_toolchains.size() == m_toolchains.first()->factory()->supportedLanguages().size(),
|
||||||
@@ -943,13 +943,13 @@ ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister auto
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ToolchainBundle> ToolchainBundle::collectBundles(AutoRegister autoRegister)
|
QList<ToolchainBundle> ToolchainBundle::collectBundles(HandleMissing handleMissing)
|
||||||
{
|
{
|
||||||
return collectBundles(ToolchainManager::toolchains(), autoRegister);
|
return collectBundles(ToolchainManager::toolchains(), handleMissing);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ToolchainBundle> ToolchainBundle::collectBundles(
|
QList<ToolchainBundle> ToolchainBundle::collectBundles(
|
||||||
const Toolchains &toolchains, AutoRegister autoRegister)
|
const Toolchains &toolchains, HandleMissing handleMissing)
|
||||||
{
|
{
|
||||||
QHash<Id, Toolchains> toolchainsPerBundleId;
|
QHash<Id, Toolchains> toolchainsPerBundleId;
|
||||||
for (Toolchain * const tc : toolchains)
|
for (Toolchain * const tc : toolchains)
|
||||||
@@ -958,12 +958,12 @@ QList<ToolchainBundle> ToolchainBundle::collectBundles(
|
|||||||
QList<ToolchainBundle> bundles;
|
QList<ToolchainBundle> bundles;
|
||||||
if (const auto unbundled = toolchainsPerBundleId.constFind(Id());
|
if (const auto unbundled = toolchainsPerBundleId.constFind(Id());
|
||||||
unbundled != toolchainsPerBundleId.constEnd()) {
|
unbundled != toolchainsPerBundleId.constEnd()) {
|
||||||
bundles = bundleUnbundledToolchains(*unbundled, autoRegister);
|
bundles = bundleUnbundledToolchains(*unbundled, handleMissing);
|
||||||
toolchainsPerBundleId.erase(unbundled);
|
toolchainsPerBundleId.erase(unbundled);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Toolchains &tcs : toolchainsPerBundleId)
|
for (const Toolchains &tcs : toolchainsPerBundleId)
|
||||||
bundles.emplaceBack(tcs, autoRegister);
|
bundles.emplaceBack(tcs, handleMissing);
|
||||||
return bundles;
|
return bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,8 +1010,7 @@ ToolchainBundle::Valid ToolchainBundle::validity() const
|
|||||||
return Valid::None;
|
return Valid::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(
|
QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(const Toolchains &unbundled, HandleMissing handleMissing)
|
||||||
const Toolchains &unbundled, AutoRegister autoRegister)
|
|
||||||
{
|
{
|
||||||
QList<ToolchainBundle> bundles;
|
QList<ToolchainBundle> bundles;
|
||||||
QHash<Id, QHash<Id, Toolchains>> unbundledByTypeAndLanguage;
|
QHash<Id, QHash<Id, Toolchains>> unbundledByTypeAndLanguage;
|
||||||
@@ -1037,7 +1036,7 @@ QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(
|
|||||||
const Id newBundleId = Id::generate();
|
const Id newBundleId = Id::generate();
|
||||||
for (Toolchain * const tc : nextBundle)
|
for (Toolchain * const tc : nextBundle)
|
||||||
tc->setBundleId(newBundleId);
|
tc->setBundleId(newBundleId);
|
||||||
bundles.emplaceBack(nextBundle, autoRegister);
|
bundles.emplaceBack(nextBundle, handleMissing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,10 +1074,10 @@ ToolchainBundle ToolchainBundle::clone() const
|
|||||||
const Id newBundleId = Id::generate();
|
const Id newBundleId = Id::generate();
|
||||||
for (Toolchain * const tc : clones)
|
for (Toolchain * const tc : clones)
|
||||||
tc->setBundleId(newBundleId);
|
tc->setBundleId(newBundleId);
|
||||||
return ToolchainBundle(clones, ToolchainBundle::AutoRegister::NotApplicable);
|
return ToolchainBundle(clones, ToolchainBundle::HandleMissing::NotApplicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolchainBundle::addMissingToolchains(AutoRegister autoRegister)
|
void ToolchainBundle::addMissingToolchains(HandleMissing handleMissing)
|
||||||
{
|
{
|
||||||
const QList<Id> missingLanguages
|
const QList<Id> missingLanguages
|
||||||
= Utils::filtered(m_toolchains.first()->factory()->supportedLanguages(), [this](Id lang) {
|
= Utils::filtered(m_toolchains.first()->factory()->supportedLanguages(), [this](Id lang) {
|
||||||
@@ -1095,12 +1094,12 @@ void ToolchainBundle::addMissingToolchains(AutoRegister autoRegister)
|
|||||||
createdToolchains << tc;
|
createdToolchains << tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (autoRegister) {
|
switch (handleMissing) {
|
||||||
case AutoRegister::On:
|
case HandleMissing::CreateAndRegister:
|
||||||
ToolchainManager::registerToolchains(createdToolchains);
|
ToolchainManager::registerToolchains(createdToolchains);
|
||||||
case AutoRegister::Off:
|
case HandleMissing::CreateOnly:
|
||||||
break;
|
break;
|
||||||
case AutoRegister::NotApplicable:
|
case HandleMissing::NotApplicable:
|
||||||
QTC_CHECK(createdToolchains.isEmpty());
|
QTC_CHECK(createdToolchains.isEmpty());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -230,13 +230,15 @@ public:
|
|||||||
// Setting up a bundle may necessitate creating additional toolchains.
|
// Setting up a bundle may necessitate creating additional toolchains.
|
||||||
// Depending on the context, these should or should not be registered
|
// Depending on the context, these should or should not be registered
|
||||||
// immediately with the ToolchainManager.
|
// immediately with the ToolchainManager.
|
||||||
enum class AutoRegister { On, Off, NotApplicable };
|
// In the case of NotApplicable, the caller promises that no toolchains
|
||||||
|
// will need to be created to ensure a complete bundle.
|
||||||
|
enum class HandleMissing { CreateAndRegister, CreateOnly, NotApplicable };
|
||||||
|
|
||||||
ToolchainBundle(const Toolchains &toolchains, AutoRegister autoRegister);
|
ToolchainBundle(const Toolchains &toolchains, HandleMissing handleMissing);
|
||||||
|
|
||||||
static QList<ToolchainBundle> collectBundles(AutoRegister autoRegister);
|
static QList<ToolchainBundle> collectBundles(HandleMissing handleMissing);
|
||||||
static QList<ToolchainBundle> collectBundles(
|
static QList<ToolchainBundle> collectBundles(
|
||||||
const Toolchains &toolchains, AutoRegister autoRegister);
|
const Toolchains &toolchains, HandleMissing handleMissing);
|
||||||
|
|
||||||
template<typename R, class T = Toolchain, typename... A>
|
template<typename R, class T = Toolchain, typename... A>
|
||||||
R get(R (T:: *getter)(A...) const, A&&... args) const
|
R get(R (T:: *getter)(A...) const, A&&... args) const
|
||||||
@@ -315,9 +317,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addMissingToolchains(AutoRegister autoRegister);
|
void addMissingToolchains(HandleMissing handleMissing);
|
||||||
static QList<ToolchainBundle> bundleUnbundledToolchains(
|
static QList<ToolchainBundle> bundleUnbundledToolchains(
|
||||||
const Toolchains &unbundled, AutoRegister autoRegister);
|
const Toolchains &unbundled, HandleMissing handleMissing);
|
||||||
|
|
||||||
Toolchains m_toolchains;
|
Toolchains m_toolchains;
|
||||||
};
|
};
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
return tc->compilerCommand().isSameDevice(device->rootPath());
|
return tc->compilerCommand().isSameDevice(device->rootPath());
|
||||||
});
|
});
|
||||||
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
|
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
|
||||||
toolchainsForBuildDevice, ToolchainBundle::AutoRegister::On);
|
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
for (const ToolchainBundle &b : bundlesForBuildDevice)
|
for (const ToolchainBundle &b : bundlesForBuildDevice)
|
||||||
rootItem()->appendChild(new ToolchainTreeItem(b));
|
rootItem()->appendChild(new ToolchainTreeItem(b));
|
||||||
rootItem()->appendChild(new ToolchainTreeItem);
|
rootItem()->appendChild(new ToolchainTreeItem);
|
||||||
@@ -321,7 +321,7 @@ static void setToolchainsFromAbis(Kit *k, const LanguagesAndAbis &abisByLanguage
|
|||||||
|
|
||||||
// Get bundles.
|
// Get bundles.
|
||||||
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
ToolchainBundle::AutoRegister::On);
|
ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
|
|
||||||
// Set a matching bundle for each LanguageCategory/Abi pair, if possible.
|
// Set a matching bundle for each LanguageCategory/Abi pair, if possible.
|
||||||
for (auto it = abisByCategory.cbegin(); it != abisByCategory.cend(); ++it) {
|
for (auto it = abisByCategory.cbegin(); it != abisByCategory.cend(); ++it) {
|
||||||
|
@@ -267,7 +267,7 @@ public:
|
|||||||
m_container->setWidget(m_widgetStack);
|
m_container->setWidget(m_widgetStack);
|
||||||
|
|
||||||
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
ToolchainBundle::AutoRegister::On);
|
ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
for (const ToolchainBundle &b : bundles)
|
for (const ToolchainBundle &b : bundles)
|
||||||
insertBundle(b);
|
insertBundle(b);
|
||||||
|
|
||||||
@@ -400,8 +400,8 @@ void ToolChainOptionsWidget::handleToolchainsRegistered(const Toolchains &toolch
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ToolchainBundle> bundles
|
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
= ToolchainBundle::collectBundles(toolchains, ToolchainBundle::AutoRegister::On);
|
toolchains, ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
for (const ToolchainBundle &bundle : bundles)
|
for (const ToolchainBundle &bundle : bundles)
|
||||||
insertBundle(bundle);
|
insertBundle(bundle);
|
||||||
updateState();
|
updateState();
|
||||||
@@ -524,7 +524,7 @@ void ToolChainOptionsWidget::redetectToolchains()
|
|||||||
|
|
||||||
// Step 4: Create new bundles and add items for them.
|
// Step 4: Create new bundles and add items for them.
|
||||||
const QList<ToolchainBundle> newBundles
|
const QList<ToolchainBundle> newBundles
|
||||||
= ToolchainBundle::collectBundles(toAdd, ToolchainBundle::AutoRegister::Off);
|
= ToolchainBundle::collectBundles(toAdd, ToolchainBundle::HandleMissing::CreateOnly);
|
||||||
for (const ToolchainBundle &bundle : newBundles)
|
for (const ToolchainBundle &bundle : newBundles)
|
||||||
m_toAddList << insertBundle(bundle, true);
|
m_toAddList << insertBundle(bundle, true);
|
||||||
}
|
}
|
||||||
@@ -611,7 +611,7 @@ void ToolChainOptionsWidget::createToolchains(ToolchainFactory *factory, const Q
|
|||||||
toolchains << tc;
|
toolchains << tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ToolchainBundle bundle(toolchains, ToolchainBundle::AutoRegister::Off);
|
const ToolchainBundle bundle(toolchains, ToolchainBundle::HandleMissing::CreateOnly);
|
||||||
ExtendedToolchainTreeItem * const item = insertBundle(bundle, true);
|
ExtendedToolchainTreeItem * const item = insertBundle(bundle, true);
|
||||||
m_toAddList << item;
|
m_toAddList << item;
|
||||||
m_toolChainView->setCurrentIndex(m_sortModel.mapFromSource(m_model.indexForItem(item)));
|
m_toolChainView->setCurrentIndex(m_sortModel.mapFromSource(m_model.indexForItem(item)));
|
||||||
|
@@ -184,7 +184,7 @@ void QtKitAspectFactory::fix(Kit *k)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
|
||||||
ToolchainBundle::AutoRegister::On);
|
ToolchainBundle::HandleMissing::CreateAndRegister);
|
||||||
using ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
using ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
||||||
bundles = Utils::filtered(bundles, [version](const ToolchainBundle &b) {
|
bundles = Utils::filtered(bundles, [version](const ToolchainBundle &b) {
|
||||||
if (!b.isCompletelyValid() || !b.factory()->languageCategory().contains(CXX_LANGUAGE_ID))
|
if (!b.isCompletelyValid() || !b.factory()->languageCategory().contains(CXX_LANGUAGE_ID))
|
||||||
|
Reference in New Issue
Block a user