Commit 3fbeca21 authored by Tim Sander's avatar Tim Sander

add baremetal plugin

This patch adds the baremetal plugin. The baremetal plugin is for
debugging small targets with hardware debugger where the remote linux
plugin does not fit. It adds a new kit and device class of type
baremetal. The device allows entering custom gdb commands. Currently only
qmake builds are possible. To use this with smaller devices without qt
a fake-qt installation is needed. CMake and qbs is currently not
supported.

Change-Id: I86816f897a2e9ed8b95e3184387969cedf8a14d7
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent ee1bac2e
<plugin name=\"BareMetal\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\" experimental=\"true\">
<vendor>Tim Sander</vendor>
<copyright>Copyright (C) 2013 Tim Sander</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Digia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
</license>
<description>This plugin adds a target for bare metal development.</description>
<category>Device Support</category>
<url></url>
$$dependencyList
</plugin>
QT += network
PROVIDER = Sander
include(../../qtcreatorplugin.pri)
# BareMetal files
SOURCES += baremetalplugin.cpp \
baremetaldevice.cpp \
baremetaldeployconfigurationfactory.cpp \
baremetaldeployconfiguration.cpp \
baremetalrunconfigurationfactory.cpp \
baremetalrunconfiguration.cpp \
baremetalrunconfigurationwidget.cpp \
baremetaldeploystepfactory.cpp \
baremetalgdbcommandsdeploystep.cpp \
baremetalruncontrolfactory.cpp \
baremetaldeviceconfigurationwizardpages.cpp \
baremetaldeviceconfigurationwizard.cpp \
baremetaldeviceconfigurationwidget.cpp \
baremetaldeviceconfigurationfactory.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 \
baremetaldeviceconfigurationwidget.h \
baremetaldeviceconfigurationwizard.h \
baremetaldeviceconfigurationwizardpages.h
FORMS += \
baremetaldeviceconfigurationwizardsetuppage.ui \
baremetaldeviceconfigurationwidget.ui
QTC_PLUGIN_NAME = BareMetal
QTC_LIB_DEPENDS += \
# nothing here at this time
QTC_PLUGIN_DEPENDS += \
coreplugin \
debugger \
projectexplorer \
qtsupport
QTC_PLUGIN_RECOMMENDS += \
# optional plugin dependencies. nothing here at this time
/****************************************************************************
**
** 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 BAREMETALCONSTANTS_H
#define BAREMETALCONSTANTS_H
namespace BareMetal {
namespace Constants {
const char BareMetalOsType[] = "BareMetalOsType";
const char ACTION_ID[] = "BareMetal.Action";
const char MENU_ID[] = "BareMetal.Menu";
} // namespace BareMetal
} // namespace Constants
#endif // BAREMETALCONSTANTS_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.
**
****************************************************************************/
#include "baremetaldeploystepfactory.h"
#include <baremetaldeployconfiguration.h>
#include <baremetalgdbcommandsdeploystep.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
BareMetalDeployStepFactory::BareMetalDeployStepFactory(QObject *parent) :
IBuildStepFactory(parent)
{
}
QList<Core::Id> BareMetalDeployStepFactory::availableCreationIds(BuildStepList *parent) const
{
QList<Core::Id> ids;
if (!qobject_cast<BareMetalDeployConfiguration *>(parent->parent()))
return ids;
ids << BareMetalGdbCommandsDeployStep::stepId();
return ids;
}
QString BareMetalDeployStepFactory::displayNameForId(const Core::Id id) const
{
if (id == BareMetalGdbCommandsDeployStep::stepId())
return BareMetalGdbCommandsDeployStep::displayName();
return QString();
}
bool BareMetalDeployStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
BuildStep *BareMetalDeployStepFactory::create(BuildStepList *parent, const Core::Id id)
{
QTC_ASSERT(canCreate(parent, id), return 0);
if (id == BareMetalGdbCommandsDeployStep::stepId())
return new BareMetalGdbCommandsDeployStep(parent, id);
return 0;
}
bool BareMetalDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
{
return canCreate(parent, idFromMap(map));
}
BuildStep *BareMetalDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
{
QTC_ASSERT(canRestore(parent, map), return 0);
BuildStep * const step = create(parent, idFromMap(map));
if (!step->fromMap(map)) {
delete step;
return 0;
}
return step;
}
bool BareMetalDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const
{
return canCreate(parent, product->id());
}
BuildStep *BareMetalDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
{
if (BareMetalGdbCommandsDeployStep * const other = qobject_cast<BareMetalGdbCommandsDeployStep *>(product))
return new BareMetalGdbCommandsDeployStep(parent, other);
return 0;
}
} // namespace Internal
} // namepsace 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 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
/****************************************************************************
**
** 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 "baremetaldevice.h"
#include "baremetaldeviceconfigurationwidget.h"
#include <coreplugin/id.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
BareMetalDevice::Ptr BareMetalDevice::create()
{
return Ptr(new BareMetalDevice);
}
BareMetalDevice::Ptr BareMetalDevice::create(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
{
return Ptr(new BareMetalDevice(name, type, machineType, origin, id));
}
BareMetalDevice::IDevice::Ptr BareMetalDevice::clone() const
{
return Ptr(new BareMetalDevice(*this));
}
QString BareMetalDevice::displayType() const
{
return tr("Bare Metal");