forked from qt-creator/qt-creator
Kits: Reduce magic while improving setup
Task-number: QTCREATORBUG-8576 Task-number: QTCREATORBUG-8081 Change-Id: I9a6675a8ae97517f78bca026c4aa0edca82d606d Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -199,6 +199,11 @@ DebuggerKitInformation::DebuggerItem DebuggerKitInformation::autoDetectItem(cons
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerKitInformation::setup(Kit *k)
|
||||||
|
{
|
||||||
|
setDebuggerItem(k, autoDetectItem(k));
|
||||||
|
}
|
||||||
|
|
||||||
// Check the configuration errors and return a flag mask. Provide a quick check and
|
// Check the configuration errors and return a flag mask. Provide a quick check and
|
||||||
// a verbose one with a list of errors.
|
// a verbose one with a list of errors.
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const
|
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const
|
||||||
{ return DebuggerKitInformation::validateDebugger(k); }
|
{ return DebuggerKitInformation::validateDebugger(k); }
|
||||||
|
|
||||||
|
void setup(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
||||||
static bool isValidDebugger(const ProjectExplorer::Kit *k);
|
static bool isValidDebugger(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,21 @@ void Kit::fix()
|
|||||||
i->fix(this);
|
i->fix(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Kit::setup()
|
||||||
|
{
|
||||||
|
KitGuard g(this);
|
||||||
|
QHash<Core::Id, QVariant> data = d->m_data;
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
// Allow for some retries to settle down in a good configuration
|
||||||
|
// This is necessary for the Qt version to pick its preferred tool chain
|
||||||
|
// and that to pick a working debugger afterwards.
|
||||||
|
foreach (KitInformation *i, KitManager::instance()->kitInformation())
|
||||||
|
i->setup(this);
|
||||||
|
if (d->m_data == data)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Kit::displayName() const
|
QString Kit::displayName() const
|
||||||
{
|
{
|
||||||
return d->m_displayName;
|
return d->m_displayName;
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ public:
|
|||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
QList<Task> validate() const;
|
QList<Task> validate() const;
|
||||||
void fix();
|
void fix(); // Fix the individual kit information.
|
||||||
|
void setup(); // Apply advanced magic(TM). Used only once on each kit during initial setup.
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void setDisplayName(const QString &name);
|
void setDisplayName(const QString &name);
|
||||||
|
|||||||
@@ -181,6 +181,23 @@ void ToolChainKitInformation::fix(Kit *k)
|
|||||||
setToolChain(k, 0); // make sure to clear out no longer known tool chains
|
setToolChain(k, 0); // make sure to clear out no longer known tool chains
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolChainKitInformation::setup(Kit *k)
|
||||||
|
{
|
||||||
|
const QString id = k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString();
|
||||||
|
if (id.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ToolChain *tc = ToolChainManager::instance()->findToolChain(id);
|
||||||
|
if (tc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ID is not found: Might be an ABI string...
|
||||||
|
foreach (ToolChain *current, ToolChainManager::instance()->toolChains()) {
|
||||||
|
if (current->targetAbi().toString() == id)
|
||||||
|
return setToolChain(k, current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
|
KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
|
||||||
{
|
{
|
||||||
return new Internal::ToolChainInformationConfigWidget(k);
|
return new Internal::ToolChainInformationConfigWidget(k);
|
||||||
@@ -209,20 +226,8 @@ ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
|
|||||||
{
|
{
|
||||||
if (!k)
|
if (!k)
|
||||||
return 0;
|
return 0;
|
||||||
const QString id = k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString();
|
return ToolChainManager::instance()
|
||||||
if (id.isEmpty())
|
->findToolChain(k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString());
|
||||||
return 0;
|
|
||||||
|
|
||||||
ToolChain *tc = ToolChainManager::instance()->findToolChain(id);
|
|
||||||
if (tc)
|
|
||||||
return tc;
|
|
||||||
|
|
||||||
// ID is not found: Might be an ABI string...
|
|
||||||
foreach (ToolChain *current, ToolChainManager::instance()->toolChains()) {
|
|
||||||
if (current->targetAbi().toString() == id)
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc)
|
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc)
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
|
|
||||||
QList<Task> validate(const Kit *k) const;
|
QList<Task> validate(const Kit *k) const;
|
||||||
void fix(Kit *k);
|
void fix(Kit *k);
|
||||||
|
void setup(Kit *k);
|
||||||
|
|
||||||
KitConfigWidget *createConfigWidget(Kit *k) const;
|
KitConfigWidget *createConfigWidget(Kit *k) const;
|
||||||
|
|
||||||
|
|||||||
@@ -148,9 +148,11 @@ void KitManager::restoreKits()
|
|||||||
QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME));
|
QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME));
|
||||||
if (kitFile.exists()) {
|
if (kitFile.exists()) {
|
||||||
KitList system = restoreKits(Utils::FileName(kitFile));
|
KitList system = restoreKits(Utils::FileName(kitFile));
|
||||||
// make sure we mark these as autodetected!
|
// make sure we mark these as autodetected and run additional setup logic
|
||||||
foreach (Kit *k, system.kits)
|
foreach (Kit *k, system.kits) {
|
||||||
k->setAutoDetected(true);
|
k->setAutoDetected(true);
|
||||||
|
k->setup();
|
||||||
|
}
|
||||||
|
|
||||||
// SDK kits are always considered to be up for validation since they might have been
|
// SDK kits are always considered to be up for validation since they might have been
|
||||||
// extended with additional information by creator in the meantime:
|
// extended with additional information by creator in the meantime:
|
||||||
@@ -202,6 +204,8 @@ void KitManager::restoreKits()
|
|||||||
defaultKit->setAutoDetected(false);
|
defaultKit->setAutoDetected(false);
|
||||||
defaultKit->setIconPath(QLatin1String(":///DESKTOP///"));
|
defaultKit->setIconPath(QLatin1String(":///DESKTOP///"));
|
||||||
|
|
||||||
|
defaultKit->setup();
|
||||||
|
|
||||||
addKit(defaultKit);
|
addKit(defaultKit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,12 @@ public:
|
|||||||
virtual bool visibleIn(Kit *) { return true; }
|
virtual bool visibleIn(Kit *) { return true; }
|
||||||
virtual QVariant defaultValue(Kit *) const = 0;
|
virtual QVariant defaultValue(Kit *) const = 0;
|
||||||
|
|
||||||
|
// called to find issues with the kit
|
||||||
virtual QList<Task> validate(const Kit *) const = 0;
|
virtual QList<Task> validate(const Kit *) const = 0;
|
||||||
|
// called to fix issues with this kitinformation. Does not modify the rest of the kit.
|
||||||
virtual void fix(Kit *) { return; }
|
virtual void fix(Kit *) { return; }
|
||||||
|
// called on initial setup of a kit.
|
||||||
|
virtual void setup(Kit *) { return; }
|
||||||
|
|
||||||
virtual ItemList toUserOutput(Kit *) const = 0;
|
virtual ItemList toUserOutput(Kit *) const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -322,12 +322,14 @@ Kit *KitModel::markForAddition(Kit *baseKit)
|
|||||||
beginInsertRows(index(m_manualRoot), pos, pos);
|
beginInsertRows(index(m_manualRoot), pos, pos);
|
||||||
|
|
||||||
KitNode *node = createNode(m_manualRoot, 0);
|
KitNode *node = createNode(m_manualRoot, 0);
|
||||||
if (baseKit) {
|
|
||||||
Kit *k = node->widget->workingCopy();
|
Kit *k = node->widget->workingCopy();
|
||||||
KitGuard g(k);
|
KitGuard g(k);
|
||||||
|
if (baseKit) {
|
||||||
k->copyFrom(baseKit);
|
k->copyFrom(baseKit);
|
||||||
k->setAutoDetected(false); // Make sure we have a manual kit!
|
k->setAutoDetected(false); // Make sure we have a manual kit!
|
||||||
k->setDisplayName(tr("Clone of %1").arg(k->displayName()));
|
k->setDisplayName(tr("Clone of %1").arg(k->displayName()));
|
||||||
|
} else {
|
||||||
|
k->setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_defaultNode)
|
if (!m_defaultNode)
|
||||||
@@ -335,7 +337,7 @@ Kit *KitModel::markForAddition(Kit *baseKit)
|
|||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
return node->widget->workingCopy();
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex KitModel::index(KitNode *node, int column) const
|
QModelIndex KitModel::index(KitNode *node, int column) const
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ QList<ProjectExplorer::Task> QmakeKitInformation::validate(const ProjectExplorer
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeKitInformation::fix(ProjectExplorer::Kit *k)
|
void QmakeKitInformation::setup(ProjectExplorer::Kit *k)
|
||||||
{
|
{
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||||
if (!version)
|
if (!version)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
QVariant defaultValue(ProjectExplorer::Kit *k) const;
|
QVariant defaultValue(ProjectExplorer::Kit *k) const;
|
||||||
|
|
||||||
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const;
|
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const;
|
||||||
void fix(ProjectExplorer::Kit *k);
|
void setup(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
|
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user