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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
bool CMakeProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||||
{
|
{
|
||||||
if (!CMakeKitInformation::cmakeTool(k)) {
|
if (!CMakeKitInformation::cmakeTool(k)) {
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
bool requiresTargetPanel() const final;
|
bool requiresTargetPanel() const final;
|
||||||
bool knowsAllBuildExecutables() 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 runCMake();
|
||||||
void runCMakeAndScanProjectTree();
|
void runCMakeAndScanProjectTree();
|
||||||
|
@@ -159,7 +159,7 @@ void NimProject::updateProject()
|
|||||||
emitParsingFinished(true);
|
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));
|
auto tc = dynamic_cast<NimToolChain*>(ToolChainKitInformation::toolChain(k, Constants::C_NIMLANGUAGE_ID));
|
||||||
if (!tc) {
|
if (!tc) {
|
||||||
|
@@ -42,7 +42,7 @@ public:
|
|||||||
explicit NimProject(const Utils::FileName &fileName);
|
explicit NimProject(const Utils::FileName &fileName);
|
||||||
|
|
||||||
bool needsConfiguration() const override;
|
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;
|
Utils::FileNameList nimFiles() const;
|
||||||
QVariantMap toMap() const override;
|
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));
|
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(k);
|
||||||
Q_UNUSED(errorMessage);
|
Q_UNUSED(errorMessage);
|
||||||
|
@@ -123,7 +123,7 @@ public:
|
|||||||
Target *activeTarget() const;
|
Target *activeTarget() const;
|
||||||
Target *target(Core::Id id) const;
|
Target *target(Core::Id id) const;
|
||||||
Target *target(Kit *k) 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);
|
Target *createTarget(Kit *k);
|
||||||
static bool copySteps(Target *sourceTarget, Target *newTarget);
|
static bool copySteps(Target *sourceTarget, Target *newTarget);
|
||||||
|
@@ -588,7 +588,7 @@ void QmakeProject::buildFinished(bool success)
|
|||||||
m_qmakeVfs->invalidateContents();
|
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);
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||||
if (!version && errorMessage)
|
if (!version && errorMessage)
|
||||||
|
@@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
QmakeProFile *rootProFile() const;
|
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;
|
QmakeProFileNode *rootProjectNode() const final;
|
||||||
|
|
||||||
|
@@ -277,20 +277,51 @@ void QmlProject::refreshTargetDirectory()
|
|||||||
updateDeploymentData(target);
|
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);
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = tr("No Qt version set in kit.");
|
*errorMessage = tr("No Qt version set in kit.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) {
|
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) {
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = tr("Qt version is too old.");
|
*errorMessage = tr("Qt version is too old.");
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,43 +336,10 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
|||||||
|
|
||||||
if (!activeTarget()) {
|
if (!activeTarget()) {
|
||||||
// find a kit that matches prerequisites (prefer default one)
|
// find a kit that matches prerequisites (prefer default one)
|
||||||
QList<Kit*> kits = KitManager::kits(
|
const QList<Kit*> kits = KitManager::kits([this](const Kit *k) { return supportsKit(k, nullptr); });
|
||||||
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;
|
|
||||||
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!kits.isEmpty()) {
|
if (!kits.isEmpty()) {
|
||||||
Kit *kit = 0;
|
Kit *kit = kits.contains(KitManager::defaultKit()) ? KitManager::defaultKit() : kits.first();
|
||||||
if (kits.contains(KitManager::defaultKit()))
|
|
||||||
kit = KitManager::defaultKit();
|
|
||||||
else
|
|
||||||
kit = kits.first();
|
|
||||||
addTarget(createTarget(kit));
|
addTarget(createTarget(kit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ public:
|
|||||||
explicit QmlProject(const Utils::FileName &filename);
|
explicit QmlProject(const Utils::FileName &filename);
|
||||||
~QmlProject() override;
|
~QmlProject() override;
|
||||||
|
|
||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
bool supportsKit(const ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||||
|
|
||||||
bool validProjectFile() const;
|
bool validProjectFile() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user