2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-04-24 15:49:09 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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
|
|
|
|
2013-03-18 14:47:33 +01:00
|
|
|
#include <QFileInfo>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
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
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant SysRootKitInformation::defaultValue(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);
|
|
|
|
|
if (!dir.toFileInfo().isDir() && SysRootKitInformation::hasSysRoot(k)) {
|
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));
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
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);
|
|
|
|
|
|
2013-02-28 15:07:01 +01:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
|
|
|
|
this, SLOT(kitsWereLoaded()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant ToolChainKitInformation::defaultValue(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2013-08-29 13:14:19 +02:00
|
|
|
QList<ToolChain *> tcList = ToolChainManager::toolChains();
|
2012-04-24 15:49:09 +02:00
|
|
|
if (tcList.isEmpty())
|
|
|
|
|
return QString();
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
Abi abi = Abi::hostAbi();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-07-10 12:57:06 +02:00
|
|
|
ToolChain *tc = Utils::findOr(tcList, tcList.first(),
|
|
|
|
|
Utils::equal(&ToolChain::targetAbi, abi));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-07-07 19:02:26 +02:00
|
|
|
return tc->id();
|
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
|
|
|
|
|
|
|
|
const ToolChain* toolchain = toolChain(k);
|
|
|
|
|
if (!toolchain) {
|
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 {
|
|
|
|
|
result << toolchain->validateKit(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2012-10-11 13:47:23 +02:00
|
|
|
if (toolChain(k))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-05-07 14:58:23 +02:00
|
|
|
qWarning("No tool chain set from kit \"%s\".",
|
2012-10-11 13:47:23 +02:00
|
|
|
qPrintable(k->displayName()));
|
|
|
|
|
setToolChain(k, 0); // make sure to clear out no longer known tool chains
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2013-09-09 17:10:41 +02:00
|
|
|
const QString id = k->value(ToolChainKitInformation::id()).toString();
|
2013-01-22 12:47:07 +01:00
|
|
|
if (id.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-29 13:14:19 +02:00
|
|
|
ToolChain *tc = ToolChainManager::findToolChain(id);
|
2013-01-22 12:47:07 +01:00
|
|
|
if (tc)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// ID is not found: Might be an ABI string...
|
2013-08-29 13:14:19 +02:00
|
|
|
foreach (ToolChain *current, ToolChainManager::toolChains()) {
|
2013-01-22 12:47:07 +01:00
|
|
|
if (current->targetAbi().toString() == id)
|
|
|
|
|
return setToolChain(k, current);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
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
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
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
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
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
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Use better strings
|
|
|
|
|
expander->registerVariable("Compiler:Name", tr("Compiler"),
|
|
|
|
|
[this, kit]() -> QString {
|
|
|
|
|
const ToolChain *tc = toolChain(kit);
|
|
|
|
|
return tc ? tc->displayName() : tr("None");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
ToolChain *tc = toolChain(k);
|
|
|
|
|
if (tc)
|
|
|
|
|
return tc->outputParser();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:10:41 +02:00
|
|
|
Core::Id ToolChainKitInformation::id()
|
|
|
|
|
{
|
|
|
|
|
return "PE.Profile.ToolChain";
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
|
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;
|
2013-09-09 17:10:41 +02:00
|
|
|
return ToolChainManager::findToolChain(k->value(ToolChainKitInformation::id()).toString());
|
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
|
|
|
{
|
2013-09-09 17:10:41 +02:00
|
|
|
k->setValue(ToolChainKitInformation::id(), tc ? tc->id() : QString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
|
|
|
|
|
this, SLOT(toolChainRemoved(ProjectExplorer::ToolChain*)));
|
|
|
|
|
connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
|
|
|
|
|
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:59:34 +02:00
|
|
|
void ToolChainKitInformation::toolChainUpdated(ToolChain *tc)
|
2013-02-28 15:07:01 +01:00
|
|
|
{
|
2014-07-25 16:30:34 +02:00
|
|
|
auto matcher = KitMatcher([tc, this](const Kit *k) { return toolChain(k) == tc; });
|
2014-07-23 09:09:20 +02:00
|
|
|
foreach (Kit *k, KitManager::matchingKits(matcher))
|
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
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant DeviceTypeKitInformation::defaultValue(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
|
|
|
}
|
|
|
|
|
|
2014-07-23 09:09:20 +02:00
|
|
|
KitMatcher DeviceTypeKitInformation::deviceTypeMatcher(Core::Id type)
|
|
|
|
|
{
|
|
|
|
|
return std::function<bool(const Kit *)>([type](const Kit *kit) {
|
|
|
|
|
return type.isValid() && deviceTypeId(kit) == type;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 15:15:27 +02:00
|
|
|
Core::FeatureSet DeviceTypeKitInformation::availableFeatures(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
Core::Id id = DeviceTypeKitInformation::deviceTypeId(k);
|
|
|
|
|
Core::FeatureSet result;
|
|
|
|
|
if (id.isValid())
|
|
|
|
|
result |= Core::Feature(Core::Id::fromString(QString::fromLatin1("DeviceType.") + id.toString()));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
2013-02-28 14:06:17 +01:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
|
|
|
|
this, SLOT(kitsWereLoaded()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant DeviceKitInformation::defaultValue(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();
|
2013-07-11 16:04:14 +02:00
|
|
|
connect(dm, SIGNAL(deviceListReplaced()), this, SLOT(devicesChanged()));
|
2013-07-08 16:39:03 +02:00
|
|
|
connect(dm, SIGNAL(deviceAdded(Core::Id)), this, SLOT(devicesChanged()));
|
|
|
|
|
connect(dm, SIGNAL(deviceRemoved(Core::Id)), this, SLOT(devicesChanged()));
|
|
|
|
|
connect(dm, SIGNAL(deviceUpdated(Core::Id)), this, SLOT(deviceUpdated(Core::Id)));
|
2013-02-28 18:29:16 +01:00
|
|
|
|
|
|
|
|
connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
|
|
|
|
this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
|
|
|
|
|
connect(KitManager::instance(), SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)),
|
|
|
|
|
this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant EnvironmentKitInformation::defaultValue(Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
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())
|
|
|
|
|
retVal << qMakePair(QLatin1Literal("Environment"), envValue.toStringList().join(QLatin1Literal("\n")));
|
|
|
|
|
|
|
|
|
|
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
|