forked from qt-creator/qt-creator
QmlProject: Unify selection of supported kits
Change-Id: Ic33e9688d823bd09664e5dc74fe5253cb5fcbc58 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
7f226bc48f
commit
8ae505f30e
@@ -376,7 +376,7 @@ bool CMakeProject::knowsAllBuildExecutables() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
bool CMakeProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
{
|
||||
if (!CMakeKitInformation::cmakeTool(k)) {
|
||||
if (errorMessage)
|
||||
|
@@ -72,7 +72,7 @@ public:
|
||||
bool requiresTargetPanel() const final;
|
||||
bool knowsAllBuildExecutables() const final;
|
||||
|
||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const final;
|
||||
bool supportsKit(const ProjectExplorer::Kit *k, QString *errorMessage = 0) const final;
|
||||
|
||||
void runCMake();
|
||||
void runCMakeAndScanProjectTree();
|
||||
|
@@ -159,7 +159,7 @@ void NimProject::updateProject()
|
||||
emitParsingFinished(true);
|
||||
}
|
||||
|
||||
bool NimProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
bool NimProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
{
|
||||
auto tc = dynamic_cast<NimToolChain*>(ToolChainKitInformation::toolChain(k, Constants::C_NIMLANGUAGE_ID));
|
||||
if (!tc) {
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
explicit NimProject(const Utils::FileName &fileName);
|
||||
|
||||
bool needsConfiguration() const override;
|
||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||
bool supportsKit(const ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||
Utils::FileNameList nimFiles() const;
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
|
@@ -329,7 +329,7 @@ Target *Project::target(Kit *k) const
|
||||
return Utils::findOrDefault(d->m_targets, Utils::equal(&Target::kit, k));
|
||||
}
|
||||
|
||||
bool Project::supportsKit(Kit *k, QString *errorMessage) const
|
||||
bool Project::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
{
|
||||
Q_UNUSED(k);
|
||||
Q_UNUSED(errorMessage);
|
||||
|
@@ -123,7 +123,7 @@ public:
|
||||
Target *activeTarget() const;
|
||||
Target *target(Core::Id id) const;
|
||||
Target *target(Kit *k) const;
|
||||
virtual bool supportsKit(Kit *k, QString *errorMessage = nullptr) const;
|
||||
virtual bool supportsKit(const Kit *k, QString *errorMessage = nullptr) const;
|
||||
|
||||
Target *createTarget(Kit *k);
|
||||
static bool copySteps(Target *sourceTarget, Target *newTarget);
|
||||
|
@@ -588,7 +588,7 @@ void QmakeProject::buildFinished(bool success)
|
||||
m_qmakeVfs->invalidateContents();
|
||||
}
|
||||
|
||||
bool QmakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
bool QmakeProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
{
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!version && errorMessage)
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
QmakeProFile *rootProFile() const;
|
||||
|
||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
||||
bool supportsKit(const ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
||||
|
||||
QmakeProFileNode *rootProjectNode() const final;
|
||||
|
||||
|
@@ -277,20 +277,51 @@ void QmlProject::refreshTargetDirectory()
|
||||
updateDeploymentData(target);
|
||||
}
|
||||
|
||||
bool QmlProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
bool QmlProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
{
|
||||
if (!k->isValid()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Kit is not valid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
||||
if (dev.isNull()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Kit has no device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!version) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("No Qt version set in kit.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Qt version is too old.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
if (version->type() != QtSupport::Constants::DESKTOPQT) {
|
||||
if (static_cast<QtSupport::DesktopQtVersion *>(version)->qmlsceneCommand().isEmpty()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Qt version has no qmlscene command.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Non-desktop Qt on a desktop device? We don't support that.
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Non-desktop Qt is used with a Desktop device.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If not a desktop device, don't check the Qt version for qmlscene.
|
||||
// The device is responsible for providing it and we assume qmlscene can be found
|
||||
// in $PATH if it's not explicitly given.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -305,43 +336,10 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
||||
|
||||
if (!activeTarget()) {
|
||||
// find a kit that matches prerequisites (prefer default one)
|
||||
QList<Kit*> kits = KitManager::kits(
|
||||
std::function<bool(const Kit *)>([](const Kit *k) -> bool {
|
||||
if (!k->isValid())
|
||||
return false;
|
||||
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
||||
if (dev.isNull())
|
||||
return false;
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!version || version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0))
|
||||
return false;
|
||||
|
||||
if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
if (version->type() != QLatin1String(QtSupport::Constants::DESKTOPQT)) {
|
||||
return !static_cast<QtSupport::DesktopQtVersion *>(version)
|
||||
->qmlsceneCommand().isEmpty();
|
||||
} else {
|
||||
// Non-desktop Qt on a desktop device? We don't support that.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If not a desktop device, don't check the Qt version for qmlscene.
|
||||
// The device is responsible for providing it and we assume qmlscene can be found
|
||||
// in $PATH if it's not explicitly given.
|
||||
return true;
|
||||
|
||||
})
|
||||
);
|
||||
const QList<Kit*> kits = KitManager::kits([this](const Kit *k) { return supportsKit(k, nullptr); });
|
||||
|
||||
if (!kits.isEmpty()) {
|
||||
Kit *kit = 0;
|
||||
if (kits.contains(KitManager::defaultKit()))
|
||||
kit = KitManager::defaultKit();
|
||||
else
|
||||
kit = kits.first();
|
||||
Kit *kit = kits.contains(KitManager::defaultKit()) ? KitManager::defaultKit() : kits.first();
|
||||
addTarget(createTarget(kit));
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
explicit QmlProject(const Utils::FileName &filename);
|
||||
~QmlProject() override;
|
||||
|
||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||
bool supportsKit(const ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||
|
||||
bool validProjectFile() const;
|
||||
|
||||
|
Reference in New Issue
Block a user