2013-09-12 18:46:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-09-12 18:46:35 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
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.
|
2013-09-12 18:46:35 +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.
|
2013-09-12 18:46:35 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "baremetalrunconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include "baremetalrunconfigurationwidget.h"
|
|
|
|
|
|
|
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
|
|
|
|
#include <projectexplorer/deploymentdata.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2015-12-15 17:05:51 +01:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2013-09-12 18:46:35 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace BareMetal {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
|
|
|
|
|
const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
|
|
|
|
|
|
|
|
|
|
|
2014-06-19 19:14:56 +02:00
|
|
|
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *other)
|
|
|
|
|
: RunConfiguration(parent, other),
|
|
|
|
|
m_projectFilePath(other->m_projectFilePath),
|
|
|
|
|
m_workingDirectory(other->m_workingDirectory)
|
2013-09-12 18:46:35 +02:00
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent,
|
|
|
|
|
const Core::Id id,
|
|
|
|
|
const QString &projectFilePath)
|
2014-06-19 19:14:56 +02:00
|
|
|
: RunConfiguration(parent, id),
|
|
|
|
|
m_projectFilePath(projectFilePath)
|
2013-09-12 18:46:35 +02:00
|
|
|
{
|
2015-12-15 17:05:51 +01:00
|
|
|
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Arguments")));
|
2013-09-12 18:46:35 +02:00
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BareMetalRunConfiguration::init()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
|
|
|
|
|
2015-06-09 10:46:54 +02:00
|
|
|
connect(target(), &Target::deploymentDataChanged,
|
|
|
|
|
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated);
|
|
|
|
|
connect(target(), &Target::applicationTargetsChanged,
|
|
|
|
|
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated);
|
|
|
|
|
connect(target(), &Target::kitChanged,
|
|
|
|
|
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated); // Handles device changes, etc.
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
return new BareMetalRunConfigurationWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OutputFormatter *BareMetalRunConfiguration::createOutputFormatter() const
|
|
|
|
|
{
|
|
|
|
|
return new QtSupport::QtOutputFormatter(target()->project());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap BareMetalRunConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(RunConfiguration::toMap());
|
2014-05-02 12:53:36 +02:00
|
|
|
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
2014-06-19 19:14:56 +02:00
|
|
|
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(m_projectFilePath));
|
|
|
|
|
map.insert(QLatin1String(WorkingDirectoryKey), m_workingDirectory);
|
2013-09-12 18:46:35 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!RunConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-05-02 12:53:36 +02:00
|
|
|
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
2014-06-19 19:14:56 +02:00
|
|
|
m_projectFilePath
|
2013-09-12 18:46:35 +02:00
|
|
|
= QDir::cleanPath(dir.filePath(map.value(QLatin1String(ProFileKey)).toString()));
|
2014-06-19 19:14:56 +02:00
|
|
|
m_workingDirectory = map.value(QLatin1String(WorkingDirectoryKey)).toString();
|
2013-09-12 18:46:35 +02:00
|
|
|
|
|
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalRunConfiguration::defaultDisplayName()
|
|
|
|
|
{
|
2014-06-19 19:14:56 +02:00
|
|
|
if (!m_projectFilePath.isEmpty())
|
2013-09-12 18:46:35 +02:00
|
|
|
//: %1 is the name of the project run via hardware debugger
|
2014-06-19 19:14:56 +02:00
|
|
|
return tr("%1 (via GDB server or hardware debugger)").arg(QFileInfo(m_projectFilePath).completeBaseName());
|
2013-09-12 18:46:35 +02:00
|
|
|
//: Bare Metal run configuration default run name
|
2013-10-04 13:51:53 +02:00
|
|
|
return tr("Run on GDB server or hardware debugger");
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalRunConfiguration::localExecutableFilePath() const
|
|
|
|
|
{
|
2017-06-22 23:11:49 +10:00
|
|
|
const QString targetName = QFileInfo(m_projectFilePath).completeBaseName();
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
return target()->applicationTargets()
|
2017-06-22 23:11:49 +10:00
|
|
|
.targetFilePath(FileName::fromString(targetName).toString()).toString();
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalRunConfiguration::arguments() const
|
|
|
|
|
{
|
2015-12-15 17:05:51 +01:00
|
|
|
return extraAspect<ArgumentsAspect>()->arguments();
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalRunConfiguration::workingDirectory() const
|
|
|
|
|
{
|
2014-06-19 19:14:56 +02:00
|
|
|
return m_workingDirectory;
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BareMetalRunConfiguration::setWorkingDirectory(const QString &wd)
|
|
|
|
|
{
|
2014-06-19 19:14:56 +02:00
|
|
|
m_workingDirectory = wd;
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalRunConfiguration::projectFilePath() const
|
|
|
|
|
{
|
2014-06-19 19:14:56 +02:00
|
|
|
return m_projectFilePath;
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-27 14:28:49 +01:00
|
|
|
QString BareMetalRunConfiguration::buildSystemTarget() const
|
|
|
|
|
{
|
|
|
|
|
const BuildTargetInfoList targets = target()->applicationTargets();
|
2017-06-22 23:11:49 +10:00
|
|
|
const Utils::FileName projectFilePath = Utils::FileName::fromString(QFileInfo(m_projectFilePath).path());
|
|
|
|
|
const QString targetName = QFileInfo(m_projectFilePath).completeBaseName();
|
2017-01-27 14:28:49 +01:00
|
|
|
auto bst = std::find_if(targets.list.constBegin(), targets.list.constEnd(),
|
2017-06-22 23:11:49 +10:00
|
|
|
[&projectFilePath,&targetName](const BuildTargetInfo &bti) { return bti.projectFilePath == projectFilePath && bti.targetName == targetName; });
|
2017-01-27 14:28:49 +01:00
|
|
|
return (bst == targets.list.constEnd()) ? QString() : bst->targetName;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
|
|
|
|
|
{
|
|
|
|
|
emit targetInformationChanged();
|
2017-01-27 14:26:58 +01:00
|
|
|
emit enabledChanged();
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-06 01:05:28 +01:00
|
|
|
const char *BareMetalRunConfiguration::IdPrefix = "BareMetal";
|
2013-09-12 18:46:35 +02:00
|
|
|
|
2014-06-19 19:14:56 +02:00
|
|
|
} // namespace Internal
|
2013-09-12 18:46:35 +02:00
|
|
|
} // namespace BareMetal
|
|
|
|
|
|