Commit 6506b2e1 authored by Tim Sander's avatar Tim Sander Committed by Tobias Hunger
Browse files

Cleanup baremetal

The cleanup goes by the comments found in
https://codereview.qt-project.org/#change,65366,patchset=6


It removes code and comments identified as unneeded.
It also further minimizes the impact on code outside the
plugin dir.

Change-Id: I22bfe9654d0fb6e0bb8f0018ecbe326cda804223
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 6e9985a7
......@@ -6,12 +6,9 @@ include(../../qtcreatorplugin.pri)
SOURCES += baremetalplugin.cpp \
baremetaldevice.cpp \
baremetaldeployconfigurationfactory.cpp \
baremetaldeployconfiguration.cpp \
baremetalrunconfigurationfactory.cpp \
baremetalrunconfiguration.cpp \
baremetalrunconfigurationwidget.cpp \
baremetaldeploystepfactory.cpp \
baremetalgdbcommandsdeploystep.cpp \
baremetalruncontrolfactory.cpp \
baremetaldeviceconfigurationwizardpages.cpp \
......@@ -22,12 +19,9 @@ SOURCES += baremetalplugin.cpp \
HEADERS += baremetalplugin.h \
baremetalconstants.h \
baremetaldevice.h \
baremetaldeployconfigurationfactory.h \
baremetaldeployconfiguration.h \
baremetalrunconfigurationfactory.h \
baremetalrunconfiguration.h \
baremetalrunconfigurationwidget.h \
baremetaldeploystepfactory.h \
baremetalgdbcommandsdeploystep.h \
baremetalruncontrolfactory.h \
baremetaldeviceconfigurationfactory.h \
......
......@@ -14,9 +14,6 @@ QtcPlugin {
files: [
"baremetalconstants.h",
"baremetaldeployconfiguration.cpp", "baremetaldeployconfiguration.h",
"baremetaldeployconfigurationfactory.cpp", "baremetaldeployconfigurationfactory.h",
"baremetaldeploystepfactory.cpp", "baremetaldeploystepfactory.h",
"baremetaldevice.cpp", "baremetaldevice.h",
"baremetaldeviceconfigurationfactory.cpp", "baremetaldeviceconfigurationfactory.h",
"baremetaldeviceconfigurationwidget.cpp", "baremetaldeviceconfigurationwidget.h",
......
/****************************************************************************
**
** Copyright (C) 2013 Tim Sander <tim@krieglstein.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "baremetaldeployconfiguration.h"
using namespace ProjectExplorer;
namespace BareMetal {
BareMetalDeployConfiguration::BareMetalDeployConfiguration(Target *target,
const Core::Id id, const QString &defaultDisplayName) :
DeployConfiguration(target, id)
{
setDefaultDisplayName(defaultDisplayName);
}
BareMetalDeployConfiguration::BareMetalDeployConfiguration(Target *target, BareMetalDeployConfiguration *source):
DeployConfiguration(target, source)
{ }
NamedWidget *BareMetalDeployConfiguration::createConfigWidget()
{
return 0;
}
} // namespace BareMetal
/****************************************************************************
**
** Copyright (C) 2013 Tim Sander <tim@krieglstein.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BAREMETALDEPLOYCONFIGURATION_H
#define BAREMETALDEPLOYCONFIGURATION_H
#include "baremetaldeployconfiguration.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h>
namespace BareMetal {
namespace Internal {
class BareMetalDeployConfigurationFactory;
} // namespace Internal
class BareMetalDeployConfiguration : public ProjectExplorer::DeployConfiguration
{
Q_OBJECT
public:
BareMetalDeployConfiguration(ProjectExplorer::Target *target, const Core::Id id,
const QString &defaultDisplayName);
BareMetalDeployConfiguration(ProjectExplorer::Target *target,
BareMetalDeployConfiguration *source);
ProjectExplorer::NamedWidget *createConfigWidget();
template<class T> T *earlierBuildStep(const ProjectExplorer::BuildStep *laterBuildStep) const
{
foreach (const ProjectExplorer::BuildStep *step, stepList()->steps()) {
if (step == laterBuildStep)
return 0;
if (T * const step = dynamic_cast<T *>(step))
return step;
}
return 0;
}
private:
friend class Internal::BareMetalDeployConfigurationFactory;
};
} // namespace BareMetal
#endif // BAREMETALDEPLOYCONFIGURATION_H
/****************************************************************************
**
** Copyright (C) 2013 Tim Sander <tim@krieglstein.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <QCoreApplication>
#include "baremetaldeployconfigurationfactory.h"
#include "baremetalconstants.h"
#include "baremetaldeployconfiguration.h"
#include <projectexplorer/abi.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
namespace {
QString genericBareMetalDisplayName() {
return QCoreApplication::translate("BareMetal","Run on gdbserver/Hardware Debugger");
}
} // anonymous namespace
BareMetalDeployConfigurationFactory::BareMetalDeployConfigurationFactory(QObject *parent) :
DeployConfigurationFactory(parent)
{
setObjectName(QLatin1String("BareMetalDeployConfiguration"));
}
QList<Core::Id> BareMetalDeployConfigurationFactory::availableCreationIds(Target *parent) const
{
QList<Core::Id> ids;
if (!parent->project()->supportsKit(parent->kit()))
return ids;
ToolChain *tc
= ToolChainKitInformation::toolChain(parent->kit());
if (!tc || tc->targetAbi().os() != Abi::LinuxOS) //FIXME
return ids;
const Core::Id devType = DeviceTypeKitInformation::deviceTypeId(parent->kit());
if (devType == Constants::BareMetalOsType)
ids << genericDeployConfigurationId();
return ids;
}
QString BareMetalDeployConfigurationFactory::displayNameForId(const Core::Id id) const
{
if (id == genericDeployConfigurationId())
return genericBareMetalDisplayName();
return QString();
}
bool BareMetalDeployConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
DeployConfiguration *BareMetalDeployConfigurationFactory::create(Target *parent, const Core::Id id)
{
QTC_ASSERT(canCreate(parent, id), return 0);
DeployConfiguration * const dc = new BareMetalDeployConfiguration(parent,id,genericBareMetalDisplayName());
//FIXME dc->stepList()->insertStep(0, Step);
return dc;
}
bool BareMetalDeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
{
return canCreate(parent,idFromMap(map));
}
DeployConfiguration *BareMetalDeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
{
if (!canRestore(parent,map))
return 0;
Core::Id id = idFromMap(map);
BareMetalDeployConfiguration * const dc = new BareMetalDeployConfiguration(parent, id, genericBareMetalDisplayName());
if (!dc->fromMap(map)) {
delete dc;
return 0;
}
return dc;
}
DeployConfiguration *BareMetalDeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product)
{
if (!canClone(parent, product))
return 0;
return new BareMetalDeployConfiguration(parent,
qobject_cast<BareMetalDeployConfiguration*>(product));
}
Core::Id BareMetalDeployConfigurationFactory::genericDeployConfigurationId()
{
return Core::Id("DeployToBareMetal");
}
} // namespace Internal
} // namespace BareMetal
/****************************************************************************
**
** Copyright (C) 2013 Tim Sander <tim@krieglstein.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BAREMETALDEPLOYCONFIGURATIONFACTORY_H
#define BAREMETALDEPLOYCONFIGURATIONFACTORY_H
#include <projectexplorer/deployconfiguration.h>
namespace BareMetal {
namespace Internal {
class BareMetalDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
explicit BareMetalDeployConfigurationFactory(QObject *parent = 0);
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const Core::Id id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::DeployConfiguration *product);
static Core::Id genericDeployConfigurationId();
};
} // namespace Internal
} // namespace BareMetal
#endif // BAREMETALDEPLOYCONFIGURATIONFACTORY_H
/****************************************************************************
**
** Copyright (C) 2013 Tim Sander <tim@krieglstein.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BAREMETALDEPLOYSTEPFACTORY_H
#define BAREMETALDEPLOYSTEPFACTORY_H
#include <projectexplorer/buildstep.h>
namespace BareMetal {
namespace Internal {
class BareMetalDeployStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
explicit BareMetalDeployStepFactory(QObject *parent = 0);
QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
QString displayNameForId(const Core::Id id) const;
bool canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const;
ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const Core::Id id);
bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const;
ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product);
};
} // namespace Internal
} // namespace BareMetal
#endif // BAREMETALDEPLOYSTEPFACTORY_H
......@@ -31,12 +31,15 @@
#include "baremetaldeviceconfigurationwidget.h"
#include <coreplugin/id.h>
#include <utils/qtcassert.h>
#include <QCoreApplication>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
const char GdbCommandsKey[] = "GdbCommands";
BareMetalDevice::Ptr BareMetalDevice::create()
{
return Ptr(new BareMetalDevice);
......@@ -47,6 +50,24 @@ BareMetalDevice::Ptr BareMetalDevice::create(const QString &name, Core::Id type,
return Ptr(new BareMetalDevice(name, type, machineType, origin, id));
}
BareMetalDevice::Ptr BareMetalDevice::create(const BareMetalDevice &other)
{
return Ptr(new BareMetalDevice(other));
}
void BareMetalDevice::fromMap(const QVariantMap &map)
{
IDevice::fromMap(map);
setGdbInitCommands(map.value(QLatin1String(GdbCommandsKey)).toString());
}
QVariantMap BareMetalDevice::toMap() const
{
QVariantMap map = IDevice::toMap();
map.insert(QLatin1String(GdbCommandsKey), getGdbInitCommands());
return map;
}
BareMetalDevice::IDevice::Ptr BareMetalDevice::clone() const
{
return Ptr(new BareMetalDevice(*this));
......@@ -59,7 +80,7 @@ DeviceProcessSignalOperation::Ptr BareMetalDevice::signalOperation() const
QString BareMetalDevice::displayType() const
{
return tr("Bare Metal");
return QCoreApplication::translate("BareMetal::Internal::BareMetalDevice", "Bare Metal");
}
ProjectExplorer::IDeviceWidget *BareMetalDevice::createWidget()
......@@ -69,13 +90,12 @@ ProjectExplorer::IDeviceWidget *BareMetalDevice::createWidget()
QList<Core::Id> BareMetalDevice::actionIds() const
{
return QList<Core::Id>(); //FIXME complete?
return QList<Core::Id>(); // no actions
}
QString BareMetalDevice::displayNameForActionId(Core::Id actionId) const
{
QTC_ASSERT(actionIds().contains(actionId), return QString());
//FIXME return action names here if any
return QString();
}
......@@ -94,6 +114,7 @@ BareMetalDevice::BareMetalDevice(const QString &name, Core::Id type, MachineType
BareMetalDevice::BareMetalDevice(const BareMetalDevice &other)
: IDevice(other)
{
setGdbInitCommands(other.getGdbInitCommands());
}
} //namespace Internal
......
......@@ -38,7 +38,6 @@ namespace Internal {
class BareMetalDevice : public ProjectExplorer::IDevice
{
Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::BareMetalDevice)
public:
typedef QSharedPointer<BareMetalDevice> Ptr;
typedef QSharedPointer<const BareMetalDevice> ConstPtr;
......@@ -46,7 +45,7 @@ public:
static Ptr create();
static Ptr create(const QString &name, Core::Id type, MachineType machineType,
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
static Ptr create(const BareMetalDevice &other);
QString displayType() const;
ProjectExplorer::IDeviceWidget *createWidget();
QList<Core::Id> actionIds() const;
......@@ -56,6 +55,11 @@ public:
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const;
QString getGdbInitCommands() const {return m_gdbInitCommands;}
void setGdbInitCommands(const QString &gdbCommands) { m_gdbInitCommands=gdbCommands; }
virtual void fromMap(const QVariantMap &map);
virtual QVariantMap toMap() const;
protected:
BareMetalDevice() {}
BareMetalDevice(const QString &name, Core::Id type,
......@@ -63,6 +67,7 @@ protected:
BareMetalDevice(const BareMetalDevice &other);
private:
BareMetalDevice &operator=(const BareMetalDevice &);
QString m_gdbInitCommands;
};
} //namespace Internal
......
......@@ -30,13 +30,15 @@
#include "baremetaldeviceconfigurationwidget.h"
#include "ui_baremetaldeviceconfigurationwidget.h"
#include "baremetaldevice.h"
#include <ssh/sshconnection.h>
#include <utils/qtcassert.h>
#include <QLabel>
using namespace QSsh;
namespace BareMetal {
using namespace Internal;
BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
const ProjectExplorer::IDevice::Ptr &deviceConfig, QWidget *parent) :
......@@ -55,9 +57,6 @@ BareMetalDeviceConfigurationWidget::~BareMetalDeviceConfigurationWidget()
delete m_ui;
}
/* using sshParams fields is ugly but otherwise i would have needed to write my own fromMap
* toMap functions */
void BareMetalDeviceConfigurationWidget::hostnameChanged()
{
SshConnectionParameters sshParams = device()->sshParameters();
......@@ -74,9 +73,9 @@ void BareMetalDeviceConfigurationWidget::portChanged()
void BareMetalDeviceConfigurationWidget::gdbInitCommandsChanged()
{
SshConnectionParameters sshParams = device()->sshParameters();
sshParams.userName = m_ui->gdbCommandsTextEdit->toPlainText();
device()->setSshParameters(sshParams);
QSharedPointer<BareMetalDevice> p = qSharedPointerCast<BareMetalDevice>(device());
QTC_ASSERT(!p.isNull(), return);
p->setGdbInitCommands(m_ui->gdbCommandsTextEdit->toPlainText());
}
void BareMetalDeviceConfigurationWidget::updateDeviceFromUi() {
......@@ -87,11 +86,12 @@ void BareMetalDeviceConfigurationWidget::updateDeviceFromUi() {
void BareMetalDeviceConfigurationWidget::initGui()
{
//FIXME reusing SshConnectionParameters is kind of ugly?
SshConnectionParameters sshParams = device()->sshParameters();
m_ui->gdbHostLineEdit->setText(sshParams.host);
m_ui->gdbPortSpinBox->setValue(sshParams.port);
m_ui->gdbCommandsTextEdit->setPlainText(sshParams.userName);
QSharedPointer<BareMetalDevice> p = qSharedPointerCast<BareMetalDevice>(device());
QTC_ASSERT(!p.isNull(), return);
m_ui->gdbCommandsTextEdit->setPlainText(p->getGdbInitCommands());
}
} //namespace BareMetal
......@@ -46,12 +46,12 @@ class BareMetalDeviceConfigrationWizardPrivate
{
public:
BareMetalDeviceConfigrationWizardPrivate(QWidget *parent):
setupPage(parent)
{
}
m_setupPage(parent)
{ }
BareMetalDeviceConfigurationWizardSetupPage setupPage;
BareMetalDeviceConfigurationWizardSetupPage m_setupPage;
};
} //namespace Internal
BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) :
......@@ -59,8 +59,8 @@ BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *
d(new Internal::BareMetalDeviceConfigrationWizardPrivate(this))
{
setWindowTitle(tr("New Bare Metal Device Configuration Setup"));
setPage(Internal::SetupPageId, &d->setupPage);
d->setupPage.setCommitPage(true);
setPage(Internal::SetupPageId, &d->m_setupPage);
d->m_setupPage.setCommitPage(true);
}