2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qmakekitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qmakekitconfigwidget.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2012-12-17 16:26:14 +01:00
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
namespace QmakeProjectManager {
|
2013-08-29 13:14:19 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QmakeKitInformation::QmakeKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
setObjectName(QLatin1String("QmakeKitInformation"));
|
2013-09-09 17:10:41 +02:00
|
|
|
setId(QmakeKitInformation::id());
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(24000);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant QmakeKitInformation::defaultValue(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2012-06-20 15:43:01 +02:00
|
|
|
return QString();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
QList<Task> QmakeKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
QList<Task> result;
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
FileName mkspec = QmakeKitInformation::mkspec(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!version && !mkspec.isEmpty())
|
2013-08-29 13:14:19 +02:00
|
|
|
result << Task(Task::Warning, tr("No Qt version set, so mkspec is ignored."),
|
|
|
|
|
FileName(), -1, Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (version && !version->hasMkspec(mkspec))
|
2013-08-29 13:14:19 +02:00
|
|
|
result << Task(Task::Error, tr("Mkspec not found for Qt version."),
|
|
|
|
|
FileName(), -1, Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
void QmakeKitInformation::setup(Kit *k)
|
2012-12-17 16:26:14 +01:00
|
|
|
{
|
|
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
|
if (!version)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
FileName spec = QmakeKitInformation::mkspec(k);
|
2012-12-17 16:26:14 +01:00
|
|
|
if (spec.isEmpty())
|
|
|
|
|
spec = version->mkspec();
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
2012-12-17 16:26:14 +01:00
|
|
|
|
2013-08-15 13:17:18 +02:00
|
|
|
if (!tc || (!tc->suggestedMkspecList().empty() && !tc->suggestedMkspecList().contains(spec))) {
|
2013-08-29 13:14:19 +02:00
|
|
|
ToolChain *possibleTc = 0;
|
|
|
|
|
foreach (ToolChain *current, ToolChainManager::toolChains()) {
|
2013-03-05 13:17:47 +01:00
|
|
|
if (version->qtAbis().contains(current->targetAbi())) {
|
|
|
|
|
possibleTc = current;
|
|
|
|
|
if (current->suggestedMkspecList().contains(spec))
|
|
|
|
|
break;
|
2012-12-17 16:26:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-08-29 13:14:19 +02:00
|
|
|
ToolChainKitInformation::setToolChain(k, possibleTc);
|
2012-12-17 16:26:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
KitConfigWidget *QmakeKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return new Internal::QmakeKitConfigWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
KitInformation::ItemList QmakeKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
return ItemList() << qMakePair(tr("mkspec"), mkspec(k).toUserOutput());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-27 15:53:47 +02:00
|
|
|
void QmakeKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const
|
|
|
|
|
{
|
|
|
|
|
expander->registerVariable("Qmake:mkspec", tr("Mkspec configured for qmake by the Kit."),
|
|
|
|
|
[this, kit]() -> QString {
|
|
|
|
|
return QmakeKitInformation::mkspec(kit).toUserOutput();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
Core::Id QmakeKitInformation::id()
|
|
|
|
|
{
|
|
|
|
|
return "QtPM4.mkSpecInformation";
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
FileName QmakeKitInformation::mkspec(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2013-08-29 13:14:19 +02:00
|
|
|
return FileName();
|
2013-09-09 17:10:41 +02:00
|
|
|
return FileName::fromString(k->value(QmakeKitInformation::id()).toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
FileName QmakeKitInformation::effectiveMkspec(const Kit *k)
|
2012-06-20 15:43:01 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2013-08-29 13:14:19 +02:00
|
|
|
return FileName();
|
|
|
|
|
FileName spec = mkspec(k);
|
2012-06-20 15:43:01 +02:00
|
|
|
if (spec.isEmpty())
|
2012-09-03 18:31:44 +02:00
|
|
|
return defaultMkspec(k);
|
2012-06-20 15:43:01 +02:00
|
|
|
return spec;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
void QmakeKitInformation::setMkspec(Kit *k, const FileName &fn)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
k->setValue(QmakeKitInformation::id(), fn == defaultMkspec(k) ? QString() : fn.toString());
|
2012-06-20 15:43:01 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
FileName QmakeKitInformation::defaultMkspec(const Kit *k)
|
2012-06-20 15:43:01 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2012-06-20 15:43:01 +02:00
|
|
|
if (!version) // No version, so no qmake
|
2013-08-29 13:14:19 +02:00
|
|
|
return FileName();
|
2012-06-20 15:43:01 +02:00
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
return version->mkspecFor(ToolChainKitInformation::toolChain(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace QmakeProjectManager
|