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:
Christian Kandeler
2024-10-22 17:36:52 +02:00
parent 1c929363ff
commit 9fd40c2220
10 changed files with 39 additions and 38 deletions

View File

@@ -1459,7 +1459,7 @@ void AndroidConfigurations::updateAutomaticKitList()
ToolchainManager::toolchains([](const Toolchain *tc) {
return tc->isAutoDetected() && tc->typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID;
}),
ToolchainBundle::AutoRegister::On),
ToolchainBundle::HandleMissing::CreateAndRegister),
[](const ToolchainBundle &b) { return b.isCompletelyValid(); });
QList<Kit *> unhandledKits = existingKits;

View File

@@ -265,8 +265,8 @@ Toolchains KitDetectorPrivate::autoDetectToolchains()
toolchain->setDetectionSource(m_sharedId);
}
ToolchainManager::registerToolchains(newToolchains);
const QList<ToolchainBundle> bundles
= ToolchainBundle::collectBundles(newToolchains, ToolchainBundle::AutoRegister::On);
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
newToolchains, ToolchainBundle::HandleMissing::CreateAndRegister);
alreadyKnown.append(newToolchains);
allNewToolchains.append(newToolchains);
}
@@ -358,8 +358,8 @@ void KitDetectorPrivate::autoDetect()
const Toolchains toolchainCandidates = ToolchainManager::toolchains(
[this](const Toolchain *tc) { return tc->detectionSource() == m_sharedId; });
const QList<ToolchainBundle> bundles
= ToolchainBundle::collectBundles(toolchainCandidates, ToolchainBundle::AutoRegister::On);
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
toolchainCandidates, ToolchainBundle::HandleMissing::CreateAndRegister);
// Try to find a matching Qt/Toolchain pair.
bool match = false;

View File

@@ -2136,7 +2136,7 @@ void GccToolchainConfigWidget::updateParentToolchainComboBox()
if (bundle().isAutoDetected() || m_parentToolchainCombo->count() == 0)
parentBundleId = bundleIdFromId(bundle().get(&GccToolchain::parentToolchainId));
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 auto parentBundle
= Utils::findOr(mingwBundles, std::nullopt, [parentBundleId](const ToolchainBundle &b) {

View File

@@ -254,7 +254,7 @@ void KitManager::restoreKits()
QHash<Abi, QHash<LanguageCategory, std::optional<ToolchainBundle>>> uniqueToolchains;
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
ToolchainBundle::AutoRegister::On);
ToolchainBundle::HandleMissing::CreateAndRegister);
for (const ToolchainBundle &bundle : bundles) {
auto &bestBundle
= uniqueToolchains[bundle.targetAbi()][bundle.factory()->languageCategory()];

View File

@@ -1659,7 +1659,7 @@ void ClangClToolchainConfigWidget::applyImpl()
const QString displayedVarsBat = m_varsBatDisplayCombo->currentText();
Toolchains results = detectClangClToolChainInPath(clangClPath, {}, displayedVarsBat);
const QList<ToolchainBundle> bundles
= ToolchainBundle::collectBundles(results, ToolchainBundle::AutoRegister::NotApplicable);
= ToolchainBundle::collectBundles(results, ToolchainBundle::HandleMissing::NotApplicable);
if (bundles.isEmpty()) {
bundle().set(&ClangClToolchain::resetVarsBat);

View File

@@ -915,7 +915,7 @@ void AsyncToolchainDetector::run()
* - 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.
*/
ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister autoRegister)
ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, HandleMissing handleMissing)
: m_toolchains(toolchains)
{
// Check pre-conditions.
@@ -930,7 +930,7 @@ ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister auto
QTC_ASSERT(tc->bundleId() == toolchains.first()->bundleId(), return);
}
addMissingToolchains(autoRegister);
addMissingToolchains(handleMissing);
// Check post-conditions.
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(
const Toolchains &toolchains, AutoRegister autoRegister)
const Toolchains &toolchains, HandleMissing handleMissing)
{
QHash<Id, Toolchains> toolchainsPerBundleId;
for (Toolchain * const tc : toolchains)
@@ -958,12 +958,12 @@ QList<ToolchainBundle> ToolchainBundle::collectBundles(
QList<ToolchainBundle> bundles;
if (const auto unbundled = toolchainsPerBundleId.constFind(Id());
unbundled != toolchainsPerBundleId.constEnd()) {
bundles = bundleUnbundledToolchains(*unbundled, autoRegister);
bundles = bundleUnbundledToolchains(*unbundled, handleMissing);
toolchainsPerBundleId.erase(unbundled);
}
for (const Toolchains &tcs : toolchainsPerBundleId)
bundles.emplaceBack(tcs, autoRegister);
bundles.emplaceBack(tcs, handleMissing);
return bundles;
}
@@ -1010,8 +1010,7 @@ ToolchainBundle::Valid ToolchainBundle::validity() const
return Valid::None;
}
QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(
const Toolchains &unbundled, AutoRegister autoRegister)
QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(const Toolchains &unbundled, HandleMissing handleMissing)
{
QList<ToolchainBundle> bundles;
QHash<Id, QHash<Id, Toolchains>> unbundledByTypeAndLanguage;
@@ -1037,7 +1036,7 @@ QList<ToolchainBundle> ToolchainBundle::bundleUnbundledToolchains(
const Id newBundleId = Id::generate();
for (Toolchain * const tc : nextBundle)
tc->setBundleId(newBundleId);
bundles.emplaceBack(nextBundle, autoRegister);
bundles.emplaceBack(nextBundle, handleMissing);
}
}
@@ -1075,10 +1074,10 @@ ToolchainBundle ToolchainBundle::clone() const
const Id newBundleId = Id::generate();
for (Toolchain * const tc : clones)
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
= Utils::filtered(m_toolchains.first()->factory()->supportedLanguages(), [this](Id lang) {
@@ -1095,12 +1094,12 @@ void ToolchainBundle::addMissingToolchains(AutoRegister autoRegister)
createdToolchains << tc;
}
switch (autoRegister) {
case AutoRegister::On:
switch (handleMissing) {
case HandleMissing::CreateAndRegister:
ToolchainManager::registerToolchains(createdToolchains);
case AutoRegister::Off:
case HandleMissing::CreateOnly:
break;
case AutoRegister::NotApplicable:
case HandleMissing::NotApplicable:
QTC_CHECK(createdToolchains.isEmpty());
break;
}

View File

@@ -230,13 +230,15 @@ public:
// Setting up a bundle may necessitate creating additional toolchains.
// Depending on the context, these should or should not be registered
// 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(
const Toolchains &toolchains, AutoRegister autoRegister);
const Toolchains &toolchains, HandleMissing handleMissing);
template<typename R, class T = Toolchain, typename... A>
R get(R (T:: *getter)(A...) const, A&&... args) const
@@ -315,9 +317,9 @@ public:
}
private:
void addMissingToolchains(AutoRegister autoRegister);
void addMissingToolchains(HandleMissing handleMissing);
static QList<ToolchainBundle> bundleUnbundledToolchains(
const Toolchains &unbundled, AutoRegister autoRegister);
const Toolchains &unbundled, HandleMissing handleMissing);
Toolchains m_toolchains;
};

View File

@@ -50,7 +50,7 @@ public:
return tc->compilerCommand().isSameDevice(device->rootPath());
});
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
toolchainsForBuildDevice, ToolchainBundle::AutoRegister::On);
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
for (const ToolchainBundle &b : bundlesForBuildDevice)
rootItem()->appendChild(new ToolchainTreeItem(b));
rootItem()->appendChild(new ToolchainTreeItem);
@@ -321,7 +321,7 @@ static void setToolchainsFromAbis(Kit *k, const LanguagesAndAbis &abisByLanguage
// Get bundles.
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
ToolchainBundle::AutoRegister::On);
ToolchainBundle::HandleMissing::CreateAndRegister);
// Set a matching bundle for each LanguageCategory/Abi pair, if possible.
for (auto it = abisByCategory.cbegin(); it != abisByCategory.cend(); ++it) {

View File

@@ -267,7 +267,7 @@ public:
m_container->setWidget(m_widgetStack);
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
ToolchainBundle::AutoRegister::On);
ToolchainBundle::HandleMissing::CreateAndRegister);
for (const ToolchainBundle &b : bundles)
insertBundle(b);
@@ -400,8 +400,8 @@ void ToolChainOptionsWidget::handleToolchainsRegistered(const Toolchains &toolch
return;
}
const QList<ToolchainBundle> bundles
= ToolchainBundle::collectBundles(toolchains, ToolchainBundle::AutoRegister::On);
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
toolchains, ToolchainBundle::HandleMissing::CreateAndRegister);
for (const ToolchainBundle &bundle : bundles)
insertBundle(bundle);
updateState();
@@ -524,7 +524,7 @@ void ToolChainOptionsWidget::redetectToolchains()
// Step 4: Create new bundles and add items for them.
const QList<ToolchainBundle> newBundles
= ToolchainBundle::collectBundles(toAdd, ToolchainBundle::AutoRegister::Off);
= ToolchainBundle::collectBundles(toAdd, ToolchainBundle::HandleMissing::CreateOnly);
for (const ToolchainBundle &bundle : newBundles)
m_toAddList << insertBundle(bundle, true);
}
@@ -611,7 +611,7 @@ void ToolChainOptionsWidget::createToolchains(ToolchainFactory *factory, const Q
toolchains << tc;
}
const ToolchainBundle bundle(toolchains, ToolchainBundle::AutoRegister::Off);
const ToolchainBundle bundle(toolchains, ToolchainBundle::HandleMissing::CreateOnly);
ExtendedToolchainTreeItem * const item = insertBundle(bundle, true);
m_toAddList << item;
m_toolChainView->setCurrentIndex(m_sortModel.mapFromSource(m_model.indexForItem(item)));

View File

@@ -184,7 +184,7 @@ void QtKitAspectFactory::fix(Kit *k)
return;
QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
ToolchainBundle::AutoRegister::On);
ToolchainBundle::HandleMissing::CreateAndRegister);
using ProjectExplorer::Constants::CXX_LANGUAGE_ID;
bundles = Utils::filtered(bundles, [version](const ToolchainBundle &b) {
if (!b.isCompletelyValid() || !b.factory()->languageCategory().contains(CXX_LANGUAGE_ID))