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 "kitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "devicesupport/desktopdevice.h"
|
|
|
|
|
#include "devicesupport/devicemanager.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kit.h"
|
|
|
|
|
#include "kitinformationconfigwidget.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "toolchain.h"
|
|
|
|
|
#include "toolchainmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <projectexplorer/abi.h>
|
2014-10-22 10:00:07 +02:00
|
|
|
#include <ssh/sshconnection.h>
|
|
|
|
|
|
2014-07-07 19:02:26 +02:00
|
|
|
#include <utils/algorithm.h>
|
2014-10-22 10:00:07 +02:00
|
|
|
#include <utils/macroexpander.h>
|
2013-02-28 14:06:17 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2016-04-15 11:03:33 +02:00
|
|
|
#include <QDir>
|
2013-03-18 14:47:33 +01:00
|
|
|
#include <QFileInfo>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2017-03-17 15:33:07 +02:00
|
|
|
const char KITINFORMATION_ID_V1[] = "PE.Profile.ToolChain";
|
|
|
|
|
const char KITINFORMATION_ID_V2[] = "PE.Profile.ToolChains";
|
|
|
|
|
const char KITINFORMATION_ID_V3[] = "PE.Profile.ToolChainsV3";
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
2014-08-01 12:05:03 +02:00
|
|
|
// SysRootKitInformation:
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
SysRootKitInformation::SysRootKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("SysRootInformation"));
|
2013-09-09 17:10:41 +02:00
|
|
|
setId(SysRootKitInformation::id());
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(31000);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant SysRootKitInformation::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-04-24 15:49:09 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> SysRootKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
2012-09-03 18:31:44 +02:00
|
|
|
const Utils::FileName dir = SysRootKitInformation::sysRoot(k);
|
2016-04-15 11:03:33 +02:00
|
|
|
if (dir.isEmpty())
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
const QFileInfo fi = dir.toFileInfo();
|
|
|
|
|
|
|
|
|
|
if (!fi.exists()) {
|
|
|
|
|
result << Task(Task::Error, tr("Sys Root \"%1\" does not exist in the file system.").arg(dir.toUserOutput()),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
} else if (!fi.isDir()) {
|
2012-07-27 15:43:00 +02:00
|
|
|
result << Task(Task::Error, tr("Sys Root \"%1\" is not a directory.").arg(dir.toUserOutput()),
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2016-04-15 11:03:33 +02:00
|
|
|
} else if (QDir(dir.toString()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) {
|
|
|
|
|
result << Task(Task::Error, tr("Sys Root \"%1\" is empty.").arg(dir.toUserOutput()),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2012-07-27 15:43:00 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return new Internal::SysRootInformationConfigWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList SysRootKitInformation::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("Sys Root"), sysRoot(k).toUserOutput());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-22 12:21:01 +01:00
|
|
|
void SysRootKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const
|
|
|
|
|
{
|
|
|
|
|
expander->registerFileVariables("SysRoot", tr("Sys Root"), [this, kit]() -> QString {
|
|
|
|
|
return SysRootKitInformation::sysRoot(kit).toString();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
Core::Id SysRootKitInformation::id()
|
|
|
|
|
{
|
|
|
|
|
return "PE.Profile.SysRoot";
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
bool SysRootKitInformation::hasSysRoot(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (k)
|
2013-09-09 17:10:41 +02:00
|
|
|
return !k->value(SysRootKitInformation::id()).toString().isEmpty();
|
2012-06-28 21:29:46 +02:00
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Utils::FileName SysRootKitInformation::sysRoot(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return Utils::FileName();
|
2013-09-09 17:10:41 +02:00
|
|
|
return Utils::FileName::fromString(k->value(SysRootKitInformation::id()).toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void SysRootKitInformation::setSysRoot(Kit *k, const Utils::FileName &v)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2016-01-20 15:26:25 +01:00
|
|
|
if (k)
|
|
|
|
|
k->setValue(SysRootKitInformation::id(), v.toString());
|
2013-07-24 16:22:37 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
2014-08-01 12:05:03 +02:00
|
|
|
// ToolChainKitInformation:
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChainKitInformation::ToolChainKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("ToolChainInformation"));
|
2013-09-09 17:10:41 +02:00
|
|
|
setId(ToolChainKitInformation::id());
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(30000);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
|
|
|
|
this, &ToolChainKitInformation::kitsWereLoaded);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-20 16:24:32 +02:00
|
|
|
// language id -> tool chain id
|
2016-12-16 00:43:14 +01:00
|
|
|
static QMap<Core::Id, QByteArray> defaultToolChainIds()
|
2016-07-20 16:24:32 +02:00
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
QMap<Core::Id, QByteArray> toolChains;
|
2016-09-14 11:48:46 +02:00
|
|
|
const Abi abi = Abi::hostAbi();
|
2017-01-11 16:12:32 +01:00
|
|
|
QList<ToolChain *> tcList = ToolChainManager::toolChains(Utils::equal(&ToolChain::targetAbi, abi));
|
2016-12-16 00:43:14 +01:00
|
|
|
foreach (Core::Id l, ToolChainManager::allLanguages()) {
|
2016-07-20 16:24:32 +02:00
|
|
|
ToolChain *tc = Utils::findOrDefault(tcList, Utils::equal(&ToolChain::language, l));
|
|
|
|
|
toolChains.insert(l, tc ? tc->id() : QByteArray());
|
|
|
|
|
}
|
|
|
|
|
return toolChains;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QVariant defaultToolChainValue()
|
|
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
const QMap<Core::Id, QByteArray> toolChains = defaultToolChainIds();
|
2016-07-20 16:24:32 +02:00
|
|
|
QVariantMap result;
|
|
|
|
|
auto end = toolChains.end();
|
|
|
|
|
for (auto it = toolChains.begin(); it != end; ++it) {
|
2016-12-16 00:43:14 +01:00
|
|
|
result.insert(it.key().toString(), it.value());
|
2016-07-20 16:24:32 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant ToolChainKitInformation::defaultValue(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2016-07-20 16:24:32 +02:00
|
|
|
return defaultToolChainValue();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> ToolChainKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
2013-03-21 12:27:18 +01:00
|
|
|
|
2016-07-12 16:27:45 +02:00
|
|
|
const QList<ToolChain*> tcList = toolChains(k);
|
|
|
|
|
if (tcList.isEmpty()) {
|
2012-09-03 18:31:44 +02:00
|
|
|
result << Task(Task::Error, ToolChainKitInformation::msgNoToolChainInTarget(),
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2013-03-21 12:27:18 +01:00
|
|
|
} else {
|
2016-07-12 16:33:19 +02:00
|
|
|
QSet<Abi> targetAbis;
|
|
|
|
|
foreach (ToolChain *tc, tcList) {
|
|
|
|
|
targetAbis.insert(tc->targetAbi());
|
2016-07-12 16:27:45 +02:00
|
|
|
result << tc->validateKit(k);
|
2016-07-12 16:33:19 +02:00
|
|
|
}
|
|
|
|
|
if (targetAbis.count() != 1) {
|
|
|
|
|
result << Task(Task::Error, tr("Compilers produce code for different ABIs."),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-20 16:24:32 +02:00
|
|
|
void ToolChainKitInformation::upgrade(Kit *k)
|
|
|
|
|
{
|
2017-03-17 15:33:07 +02:00
|
|
|
const Core::Id oldIdV1 = KITINFORMATION_ID_V1;
|
|
|
|
|
const Core::Id oldIdV2 = KITINFORMATION_ID_V2;
|
2016-12-16 00:43:14 +01:00
|
|
|
|
2016-07-20 16:24:32 +02:00
|
|
|
// upgrade <=4.1 to 4.2 (keep old settings around for now)
|
2016-12-16 00:43:14 +01:00
|
|
|
{
|
|
|
|
|
const QVariant oldValue = k->value(oldIdV1);
|
|
|
|
|
const QVariant value = k->value(oldIdV2);
|
|
|
|
|
if (value.isNull() && !oldValue.isNull()) {
|
|
|
|
|
QVariantMap newValue;
|
|
|
|
|
if (oldValue.type() == QVariant::Map) {
|
|
|
|
|
// Used between 4.1 and 4.2:
|
|
|
|
|
newValue = oldValue.toMap();
|
|
|
|
|
} else {
|
|
|
|
|
// Used up to 4.1:
|
|
|
|
|
newValue.insert(Deprecated::Toolchain::languageId(Deprecated::Toolchain::Cxx), oldValue.toString());
|
|
|
|
|
|
|
|
|
|
const Core::Id typeId = DeviceTypeKitInformation::deviceTypeId(k);
|
|
|
|
|
if (typeId == Constants::DESKTOP_DEVICE_TYPE) {
|
|
|
|
|
// insert default C compiler which did not exist before
|
|
|
|
|
newValue.insert(Deprecated::Toolchain::languageId(Deprecated::Toolchain::C),
|
|
|
|
|
defaultToolChainIds().value(Core::Id(Constants::C_LANGUAGE_ID)));
|
|
|
|
|
}
|
2016-09-14 11:48:46 +02:00
|
|
|
}
|
2016-12-16 00:43:14 +01:00
|
|
|
k->setValue(oldIdV2, newValue);
|
|
|
|
|
k->setSticky(oldIdV2, k->isSticky(oldIdV1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// upgrade 4.2 to 4.3 (keep old settings around for now)
|
|
|
|
|
{
|
|
|
|
|
const QVariant oldValue = k->value(oldIdV2);
|
|
|
|
|
const QVariant value = k->value(ToolChainKitInformation::id());
|
|
|
|
|
if (value.isNull() && !oldValue.isNull()) {
|
|
|
|
|
QVariantMap newValue = oldValue.toMap();
|
|
|
|
|
QVariantMap::iterator it = newValue.find(Deprecated::Toolchain::languageId(Deprecated::Toolchain::C));
|
|
|
|
|
if (it != newValue.end())
|
|
|
|
|
newValue.insert(Core::Id(Constants::C_LANGUAGE_ID).toString(), it.value());
|
|
|
|
|
it = newValue.find(Deprecated::Toolchain::languageId(Deprecated::Toolchain::Cxx));
|
|
|
|
|
if (it != newValue.end())
|
|
|
|
|
newValue.insert(Core::Id(Constants::CXX_LANGUAGE_ID).toString(), it.value());
|
|
|
|
|
k->setValue(ToolChainKitInformation::id(), newValue);
|
|
|
|
|
k->setSticky(ToolChainKitInformation::id(), k->isSticky(oldIdV2));
|
2016-07-20 16:24:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-01-23 16:30:06 +01:00
|
|
|
|
|
|
|
|
// upgrade 4.3-temporary-master-state to 4.3:
|
|
|
|
|
{
|
|
|
|
|
const QVariantMap valueMap = k->value(ToolChainKitInformation::id()).toMap();
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
for (const QString &key : valueMap.keys()) {
|
|
|
|
|
const int pos = key.lastIndexOf('.');
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
result.insert(key.mid(pos + 1), valueMap.value(key));
|
|
|
|
|
else
|
|
|
|
|
result.insert(key, valueMap.value(key));
|
|
|
|
|
}
|
|
|
|
|
k->setValue(ToolChainKitInformation::id(), result);
|
|
|
|
|
}
|
2016-07-20 16:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
void ToolChainKitInformation::fix(Kit *k)
|
|
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
QTC_ASSERT(ToolChainManager::isLoaded(), return);
|
2016-12-16 00:43:14 +01:00
|
|
|
foreach (const Core::Id& l, ToolChainManager::allLanguages()) {
|
2016-07-12 16:27:45 +02:00
|
|
|
if (!toolChain(k, l)) {
|
2016-12-09 13:53:09 +01:00
|
|
|
qWarning("No tool chain set up in kit \"%s\" for \"%s\".",
|
|
|
|
|
qPrintable(k->displayName()),
|
2016-12-16 00:43:14 +01:00
|
|
|
qPrintable(ToolChainManager::displayNameOfLanguageId(l)));
|
2016-12-12 17:13:29 +01:00
|
|
|
clearToolChain(k, l); // make sure to clear out no longer known tool chains
|
2016-07-12 16:27:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-11 13:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
static Core::Id findLanguage(const QString &ls)
|
|
|
|
|
{
|
|
|
|
|
QString lsUpper = ls.toUpper();
|
|
|
|
|
return Utils::findOrDefault(ToolChainManager::allLanguages(),
|
|
|
|
|
[lsUpper](Core::Id l) { return lsUpper == l.toString().toUpper(); });
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 12:47:07 +01:00
|
|
|
void ToolChainKitInformation::setup(Kit *k)
|
|
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
QTC_ASSERT(ToolChainManager::isLoaded(), return);
|
2016-07-20 17:17:09 +02:00
|
|
|
const QVariantMap value = k->value(ToolChainKitInformation::id()).toMap();
|
2016-07-15 13:15:27 +02:00
|
|
|
|
|
|
|
|
for (auto i = value.constBegin(); i != value.constEnd(); ++i) {
|
2016-12-16 00:43:14 +01:00
|
|
|
Core::Id l = findLanguage(i.key());
|
|
|
|
|
|
|
|
|
|
if (!l.isValid())
|
2016-07-15 13:15:27 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const QByteArray id = i.value().toByteArray();
|
|
|
|
|
ToolChain *tc = ToolChainManager::findToolChain(id);
|
|
|
|
|
if (tc)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// ID is not found: Might be an ABI string...
|
|
|
|
|
const QString abi = QString::fromUtf8(id);
|
2017-01-11 16:12:32 +01:00
|
|
|
tc = ToolChainManager::toolChain([abi, l](const ToolChain *t) {
|
2016-07-15 13:15:27 +02:00
|
|
|
return t->targetAbi().toString() == abi && t->language() == l;
|
|
|
|
|
});
|
2016-12-12 17:13:29 +01:00
|
|
|
if (tc)
|
|
|
|
|
setToolChain(k, tc);
|
|
|
|
|
else
|
|
|
|
|
clearToolChain(k, l);
|
2013-01-22 12:47:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return new Internal::ToolChainInformationConfigWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString ToolChainKitInformation::displayNamePostfix(const Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID);
|
2012-08-07 13:09:56 +02:00
|
|
|
return tc ? tc->displayName() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList ToolChainKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID);
|
2012-08-24 08:31:01 +02:00
|
|
|
return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None"));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (tc)
|
|
|
|
|
tc->addToEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 17:46:19 +01:00
|
|
|
void ToolChainKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const
|
|
|
|
|
{
|
2016-07-15 11:15:27 +02:00
|
|
|
// Compatibility with Qt Creator < 4.2:
|
2014-11-17 17:46:19 +01:00
|
|
|
expander->registerVariable("Compiler:Name", tr("Compiler"),
|
|
|
|
|
[this, kit]() -> QString {
|
2016-12-16 00:43:14 +01:00
|
|
|
const ToolChain *tc = toolChain(kit, Constants::CXX_LANGUAGE_ID);
|
2014-11-17 17:46:19 +01:00
|
|
|
return tc ? tc->displayName() : tr("None");
|
|
|
|
|
});
|
2016-03-16 11:56:28 +01:00
|
|
|
|
|
|
|
|
expander->registerVariable("Compiler:Executable", tr("Path to the compiler executable"),
|
|
|
|
|
[this, kit]() -> QString {
|
2016-12-16 00:43:14 +01:00
|
|
|
const ToolChain *tc = toolChain(kit, Constants::CXX_LANGUAGE_ID);
|
2016-03-16 11:56:28 +01:00
|
|
|
return tc ? tc->compilerCommand().toString() : QString();
|
|
|
|
|
});
|
2016-07-15 11:15:27 +02:00
|
|
|
|
|
|
|
|
expander->registerPrefix("Compiler:Name", tr("Compiler for different languages"),
|
|
|
|
|
[this, kit](const QString &ls) -> QString {
|
2016-12-16 00:43:14 +01:00
|
|
|
const ToolChain *tc = toolChain(kit, findLanguage(ls));
|
2016-07-15 11:15:27 +02:00
|
|
|
return tc ? tc->displayName() : tr("None");
|
|
|
|
|
});
|
|
|
|
|
expander->registerPrefix("Compiler:Executable", tr("Compiler executable for different languages"),
|
|
|
|
|
[this, kit](const QString &ls) -> QString {
|
2016-12-16 00:43:14 +01:00
|
|
|
const ToolChain *tc = toolChain(kit, findLanguage(ls));
|
2016-07-15 11:15:27 +02:00
|
|
|
return tc ? tc->compilerCommand().toString() : QString();
|
|
|
|
|
});
|
2014-11-17 17:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
|
|
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = toolChain(k, Constants::CXX_LANGUAGE_ID);
|
2012-11-02 12:45:09 +01:00
|
|
|
if (tc)
|
|
|
|
|
return tc->outputParser();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 00:26:51 +01:00
|
|
|
QSet<Core::Id> ToolChainKitInformation::availableFeatures(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
QSet<Core::Id> result;
|
|
|
|
|
for (ToolChain *tc : toolChains(k))
|
|
|
|
|
result.insert(tc->typeId().withPrefix("ToolChain."));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
Core::Id ToolChainKitInformation::id()
|
|
|
|
|
{
|
2017-03-17 15:33:07 +02:00
|
|
|
return KITINFORMATION_ID_V3;
|
2013-09-09 17:10:41 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *ToolChainKitInformation::toolChain(const Kit *k, Core::Id language)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
QTC_ASSERT(ToolChainManager::isLoaded(), return 0);
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return 0;
|
2016-07-20 16:24:32 +02:00
|
|
|
QVariantMap value = k->value(ToolChainKitInformation::id()).toMap();
|
2016-12-16 00:43:14 +01:00
|
|
|
const QByteArray id = value.value(language.toString(), QByteArray()).toByteArray();
|
2016-07-12 16:27:45 +02:00
|
|
|
return ToolChainManager::findToolChain(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ToolChain *> ToolChainKitInformation::toolChains(const Kit *k)
|
|
|
|
|
{
|
2016-07-20 16:24:32 +02:00
|
|
|
const QVariantMap value = k->value(ToolChainKitInformation::id()).toMap();
|
2016-07-12 16:27:45 +02:00
|
|
|
const QList<ToolChain *> tcList
|
2016-12-16 00:43:14 +01:00
|
|
|
= Utils::transform(ToolChainManager::allLanguages().toList(),
|
|
|
|
|
[&value](Core::Id l) -> ToolChain * {
|
|
|
|
|
return ToolChainManager::findToolChain(value.value(l.toString()).toByteArray());
|
2016-07-12 16:27:45 +02:00
|
|
|
});
|
|
|
|
|
return Utils::filtered(tcList, [](ToolChain *tc) { return tc; });
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2016-07-12 16:27:45 +02:00
|
|
|
QTC_ASSERT(tc, return);
|
2016-12-12 17:13:29 +01:00
|
|
|
QVariantMap result = k->value(ToolChainKitInformation::id()).toMap();
|
2016-12-16 00:43:14 +01:00
|
|
|
result.insert(tc->language().toString(), tc->id());
|
|
|
|
|
|
2016-12-12 17:13:29 +01:00
|
|
|
k->setValue(id(), result);
|
2016-07-12 16:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
void ToolChainKitInformation::clearToolChain(Kit *k, Core::Id language)
|
2016-07-12 16:27:45 +02:00
|
|
|
{
|
2016-12-16 00:43:14 +01:00
|
|
|
QTC_ASSERT(language.isValid(), return);
|
2016-07-12 16:27:45 +02:00
|
|
|
|
2016-07-20 16:24:32 +02:00
|
|
|
QVariantMap result = k->value(ToolChainKitInformation::id()).toMap();
|
2016-12-16 00:43:14 +01:00
|
|
|
result.insert(language.toString(), QByteArray());
|
2016-07-12 16:27:45 +02:00
|
|
|
k->setValue(id(), result);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-13 10:40:05 +02:00
|
|
|
Abi ToolChainKitInformation::targetAbi(const Kit *k)
|
|
|
|
|
{
|
|
|
|
|
QList<ToolChain *> tcList = toolChains(k);
|
|
|
|
|
// Find the best possible ABI for all the tool chains...
|
|
|
|
|
Abi cxxAbi;
|
|
|
|
|
QHash<Abi, int> abiCount;
|
|
|
|
|
foreach (ToolChain *tc, tcList) {
|
|
|
|
|
Abi ta = tc->targetAbi();
|
2016-12-16 00:43:14 +01:00
|
|
|
if (tc->language() == Core::Id(Constants::CXX_LANGUAGE_ID))
|
2016-07-13 10:40:05 +02:00
|
|
|
cxxAbi = tc->targetAbi();
|
|
|
|
|
abiCount[ta] = (abiCount.contains(ta) ? abiCount[ta] + 1 : 1);
|
|
|
|
|
}
|
|
|
|
|
QVector<Abi> candidates;
|
|
|
|
|
int count = -1;
|
|
|
|
|
candidates.reserve(tcList.count());
|
|
|
|
|
for (auto i = abiCount.begin(); i != abiCount.end(); ++i) {
|
|
|
|
|
if (i.value() > count) {
|
|
|
|
|
candidates.clear();
|
|
|
|
|
candidates.append(i.key());
|
|
|
|
|
count = i.value();
|
|
|
|
|
} else if (i.value() == count) {
|
|
|
|
|
candidates.append(i.key());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Found a good candidate:
|
|
|
|
|
if (candidates.isEmpty())
|
|
|
|
|
return Abi::hostAbi();
|
|
|
|
|
if (candidates.contains(cxxAbi)) // Use Cxx compiler as a tie breaker
|
|
|
|
|
return cxxAbi;
|
|
|
|
|
return candidates.at(0); // Use basically a random Abi...
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString ToolChainKitInformation::msgNoToolChainInTarget()
|
2012-07-27 15:43:00 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
return tr("No compiler set in kit.");
|
2012-07-27 15:43:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-28 15:07:01 +01:00
|
|
|
void ToolChainKitInformation::kitsWereLoaded()
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *k, KitManager::kits())
|
2013-02-28 15:07:01 +01:00
|
|
|
fix(k);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(ToolChainManager::instance(), &ToolChainManager::toolChainRemoved,
|
|
|
|
|
this, &ToolChainKitInformation::toolChainRemoved);
|
|
|
|
|
connect(ToolChainManager::instance(), &ToolChainManager::toolChainUpdated,
|
|
|
|
|
this, &ToolChainKitInformation::toolChainUpdated);
|
2013-02-28 15:07:01 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:59:34 +02:00
|
|
|
void ToolChainKitInformation::toolChainUpdated(ToolChain *tc)
|
2013-02-28 15:07:01 +01:00
|
|
|
{
|
2017-01-11 17:29:30 +01:00
|
|
|
for (Kit *k : KitManager::kits([tc, this](const Kit *k) { return toolChain(k, tc->language()) == tc; }))
|
2013-02-28 15:07:01 +01:00
|
|
|
notifyAboutUpdate(k);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:59:34 +02:00
|
|
|
void ToolChainKitInformation::toolChainRemoved(ToolChain *tc)
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
2013-02-28 15:07:01 +01:00
|
|
|
Q_UNUSED(tc);
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *k, KitManager::kits())
|
2013-02-28 15:07:01 +01:00
|
|
|
fix(k);
|
2012-10-17 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
2014-08-01 12:05:03 +02:00
|
|
|
// DeviceTypeKitInformation:
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
DeviceTypeKitInformation::DeviceTypeKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("DeviceTypeInformation"));
|
2013-09-09 17:10:41 +02:00
|
|
|
setId(DeviceTypeKitInformation::id());
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(33000);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant DeviceTypeKitInformation::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-04-24 15:49:09 +02:00
|
|
|
return QByteArray(Constants::DESKTOP_DEVICE_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> DeviceTypeKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
Q_UNUSED(k);
|
|
|
|
|
return QList<Task>();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return new Internal::DeviceTypeInformationConfigWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id type = deviceTypeId(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QString typeDisplayName = tr("Unknown device type");
|
|
|
|
|
if (type.isValid()) {
|
2014-05-08 11:58:23 +02:00
|
|
|
IDeviceFactory *factory = ExtensionSystem::PluginManager::getObject<IDeviceFactory>(
|
|
|
|
|
[&type](IDeviceFactory *factory) {
|
|
|
|
|
return factory->availableCreationIds().contains(type);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (factory)
|
|
|
|
|
typeDisplayName = factory->displayNameForId(type);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
return ItemList() << qMakePair(tr("Device type"), typeDisplayName);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
const Core::Id DeviceTypeKitInformation::id()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return "PE.Profile.DeviceType";
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
const Core::Id DeviceTypeKitInformation::deviceTypeId(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return k ? Core::Id::fromSetting(k->value(DeviceTypeKitInformation::id())) : Core::Id();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
void DeviceTypeKitInformation::setDeviceTypeId(Kit *k, Core::Id type)
|
2013-07-24 16:22:37 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
k->setValue(DeviceTypeKitInformation::id(), type.toSetting());
|
2013-07-24 16:22:37 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-11 17:25:58 +01:00
|
|
|
Kit::Predicate DeviceTypeKitInformation::deviceTypePredicate(Core::Id type)
|
2014-07-23 09:09:20 +02:00
|
|
|
{
|
2017-01-11 17:25:58 +01:00
|
|
|
return [type](const Kit *kit) { return type.isValid() && deviceTypeId(kit) == type; };
|
2014-07-23 09:09:20 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-27 16:14:14 +01:00
|
|
|
QSet<Core::Id> DeviceTypeKitInformation::supportedPlatforms(const Kit *k) const
|
|
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
return {deviceTypeId(k)};
|
2015-11-27 16:14:14 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-27 11:31:35 +01:00
|
|
|
QSet<Core::Id> DeviceTypeKitInformation::availableFeatures(const Kit *k) const
|
2014-07-29 15:15:27 +02:00
|
|
|
{
|
|
|
|
|
Core::Id id = DeviceTypeKitInformation::deviceTypeId(k);
|
|
|
|
|
if (id.isValid())
|
2017-02-22 15:09:35 +01:00
|
|
|
return {id.withPrefix("DeviceType.")};
|
2015-11-27 16:14:14 +01:00
|
|
|
return QSet<Core::Id>();
|
2014-07-29 15:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
2014-08-01 12:05:03 +02:00
|
|
|
// DeviceKitInformation:
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
DeviceKitInformation::DeviceKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("DeviceInformation"));
|
2013-09-09 17:10:41 +02:00
|
|
|
setId(DeviceKitInformation::id());
|
2013-08-28 18:57:25 +02:00
|
|
|
setPriority(32000);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
|
|
|
|
this, &DeviceKitInformation::kitsWereLoaded);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant DeviceKitInformation::defaultValue(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
Core::Id type = DeviceTypeKitInformation::deviceTypeId(k);
|
2014-08-01 13:06:21 +02:00
|
|
|
// Use default device if that is compatible:
|
2012-10-11 18:17:15 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceManager::instance()->defaultDevice(type);
|
2014-08-01 13:06:21 +02:00
|
|
|
if (dev && dev->isCompatibleWith(k))
|
|
|
|
|
return dev->id().toString();
|
|
|
|
|
// Use any other device that is compatible:
|
|
|
|
|
for (int i = 0; i < DeviceManager::instance()->deviceCount(); ++i) {
|
|
|
|
|
dev = DeviceManager::instance()->deviceAt(i);
|
|
|
|
|
if (dev && dev->isCompatibleWith(k))
|
|
|
|
|
return dev->id().toString();
|
|
|
|
|
}
|
|
|
|
|
// Fail: No device set up.
|
|
|
|
|
return QString();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> DeviceKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<Task> result;
|
2012-10-11 18:17:15 +02:00
|
|
|
if (dev.isNull())
|
2013-02-12 15:36:59 +01:00
|
|
|
result.append(Task(Task::Warning, tr("No device set."),
|
2012-10-11 18:17:15 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2014-08-01 13:06:21 +02:00
|
|
|
else if (!dev->isCompatibleWith(k))
|
|
|
|
|
result.append(Task(Task::Error, tr("Device is incompatible with this kit."),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
void DeviceKitInformation::fix(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2014-08-01 13:06:21 +02:00
|
|
|
if (!dev.isNull() && !dev->isCompatibleWith(k)) {
|
|
|
|
|
qWarning("Device is no longer compatible with kit \"%s\", removing it.",
|
|
|
|
|
qPrintable(k->displayName()));
|
2013-11-29 12:17:53 +01:00
|
|
|
setDeviceId(k, Core::Id());
|
|
|
|
|
}
|
2013-02-28 14:06:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceKitInformation::setup(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return);
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2014-08-01 13:06:21 +02:00
|
|
|
if (!dev.isNull() && dev->isCompatibleWith(k))
|
2013-02-28 14:06:17 +01:00
|
|
|
return;
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
setDeviceId(k, Core::Id::fromSetting(defaultValue(k)));
|
2012-10-11 13:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return new Internal::DeviceInformationConfigWidget(k, this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString DeviceKitInformation::displayNamePostfix(const Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr dev = device(k);
|
2012-08-07 13:09:56 +02:00
|
|
|
return dev.isNull() ? QString() : dev->displayName();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList DeviceKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr dev = device(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return ItemList() << qMakePair(tr("Device"), dev.isNull() ? tr("Unconfigured") : dev->displayName());
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 10:00:07 +02:00
|
|
|
void DeviceKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const
|
|
|
|
|
{
|
|
|
|
|
expander->registerVariable("Device:HostAddress", tr("Host address"),
|
2014-10-22 22:39:54 +02:00
|
|
|
[this, kit]() -> QString {
|
2014-10-22 10:00:07 +02:00
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
return device ? device->sshParameters().host : QString();
|
|
|
|
|
});
|
|
|
|
|
expander->registerVariable("Device:SshPort", tr("SSH port"),
|
2014-10-22 22:39:54 +02:00
|
|
|
[this, kit]() -> QString {
|
2014-10-22 10:00:07 +02:00
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
return device ? QString::number(device->sshParameters().port) : QString();
|
|
|
|
|
});
|
|
|
|
|
expander->registerVariable("Device:UserName", tr("User name"),
|
2014-10-22 22:39:54 +02:00
|
|
|
[this, kit]() -> QString {
|
2014-10-22 10:00:07 +02:00
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
return device ? device->sshParameters().userName : QString();
|
|
|
|
|
});
|
|
|
|
|
expander->registerVariable("Device:KeyFile", tr("Private key file"),
|
2014-10-22 22:39:54 +02:00
|
|
|
[this, kit]() -> QString {
|
2014-10-22 10:00:07 +02:00
|
|
|
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
return device ? device->sshParameters().privateKeyFile : QString();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
Core::Id DeviceKitInformation::id()
|
|
|
|
|
{
|
|
|
|
|
return "PE.Profile.Device";
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr DeviceKitInformation::device(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-02-28 14:06:17 +01:00
|
|
|
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return IDevice::ConstPtr());
|
2013-02-28 17:07:05 +01:00
|
|
|
return DeviceManager::instance()->find(deviceId(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id DeviceKitInformation::deviceId(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
return k ? Core::Id::fromSetting(k->value(DeviceKitInformation::id())) : Core::Id();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void DeviceKitInformation::setDevice(Kit *k, IDevice::ConstPtr dev)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-01-18 12:29:40 +01:00
|
|
|
setDeviceId(k, dev ? dev->id() : Core::Id());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
void DeviceKitInformation::setDeviceId(Kit *k, Core::Id id)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
k->setValue(DeviceKitInformation::id(), id.toSetting());
|
2013-07-24 16:22:37 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-28 14:06:17 +01:00
|
|
|
void DeviceKitInformation::kitsWereLoaded()
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *k, KitManager::kits())
|
2013-02-28 14:06:17 +01:00
|
|
|
fix(k);
|
|
|
|
|
|
2013-07-08 16:39:03 +02:00
|
|
|
DeviceManager *dm = DeviceManager::instance();
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(dm, &DeviceManager::deviceListReplaced, this, &DeviceKitInformation::devicesChanged);
|
|
|
|
|
connect(dm, &DeviceManager::deviceAdded, this, &DeviceKitInformation::devicesChanged);
|
|
|
|
|
connect(dm, &DeviceManager::deviceRemoved, this, &DeviceKitInformation::devicesChanged);
|
|
|
|
|
connect(dm, &DeviceManager::deviceUpdated, this, &DeviceKitInformation::deviceUpdated);
|
|
|
|
|
|
|
|
|
|
connect(KitManager::instance(), &KitManager::kitUpdated,
|
|
|
|
|
this, &DeviceKitInformation::kitUpdated);
|
|
|
|
|
connect(KitManager::instance(), &KitManager::unmanagedKitUpdated,
|
|
|
|
|
this, &DeviceKitInformation::kitUpdated);
|
2013-02-28 14:06:17 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
void DeviceKitInformation::deviceUpdated(Core::Id id)
|
2013-02-28 14:06:17 +01:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *k, KitManager::kits()) {
|
2012-10-17 17:27:17 +02:00
|
|
|
if (deviceId(k) == id)
|
|
|
|
|
notifyAboutUpdate(k);
|
2013-02-28 14:06:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-28 18:29:16 +01:00
|
|
|
void DeviceKitInformation::kitUpdated(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
setup(k); // Set default device if necessary
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-08 16:39:03 +02:00
|
|
|
void DeviceKitInformation::devicesChanged()
|
2013-02-28 14:06:17 +01:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *k, KitManager::kits())
|
2013-02-28 18:29:16 +01:00
|
|
|
setup(k); // Set default device if necessary
|
2012-10-17 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-22 21:12:34 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// EnvironmentKitInformation:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
EnvironmentKitInformation::EnvironmentKitInformation()
|
|
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("EnvironmentKitInformation"));
|
|
|
|
|
setId(EnvironmentKitInformation::id());
|
|
|
|
|
setPriority(29000);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-04 17:49:28 +01:00
|
|
|
QVariant EnvironmentKitInformation::defaultValue(const Kit *k) const
|
2014-07-22 21:12:34 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(k)
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Task> EnvironmentKitInformation::validate(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
|
|
|
|
const QVariant variant = k->value(EnvironmentKitInformation::id());
|
|
|
|
|
if (!variant.isNull() && !variant.canConvert(QVariant::List)) {
|
|
|
|
|
result.append(Task(Task::Error, tr("The environment setting value is invalid."),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentKitInformation::fix(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
const QVariant variant = k->value(EnvironmentKitInformation::id());
|
|
|
|
|
if (!variant.isNull() && !variant.canConvert(QVariant::List)) {
|
|
|
|
|
qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName()));
|
|
|
|
|
setEnvironmentChanges(k, QList<Utils::EnvironmentItem>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const
|
|
|
|
|
{
|
|
|
|
|
const QVariant envValue = k->value(EnvironmentKitInformation::id());
|
|
|
|
|
if (envValue.isValid())
|
|
|
|
|
env.modify(Utils::EnvironmentItem::fromStringList(envValue.toStringList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KitConfigWidget *EnvironmentKitInformation::createConfigWidget(Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
return new Internal::KitEnvironmentConfigWidget(k, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KitInformation::ItemList EnvironmentKitInformation::toUserOutput(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
ItemList retVal;
|
|
|
|
|
QVariant envValue = k->value(EnvironmentKitInformation::id());
|
|
|
|
|
if (envValue.isValid())
|
2016-02-04 18:27:16 +01:00
|
|
|
retVal << qMakePair(QLatin1Literal("Environment"), envValue.toStringList().join(QLatin1Literal("<br>")));
|
2014-07-22 21:12:34 +02:00
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id EnvironmentKitInformation::id()
|
|
|
|
|
{
|
|
|
|
|
return "PE.Profile.Environment";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Utils::EnvironmentItem> EnvironmentKitInformation::environmentChanges(const Kit *k)
|
|
|
|
|
{
|
|
|
|
|
if (k)
|
|
|
|
|
return Utils::EnvironmentItem::fromStringList(k->value(EnvironmentKitInformation::id()).toStringList());
|
|
|
|
|
return QList<Utils::EnvironmentItem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EnvironmentKitInformation::setEnvironmentChanges(Kit *k, const QList<Utils::EnvironmentItem> &changes)
|
|
|
|
|
{
|
|
|
|
|
if (k)
|
|
|
|
|
k->setValue(EnvironmentKitInformation::id(), Utils::EnvironmentItem::toStringList(changes));
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace ProjectExplorer
|