Commit 1acd9d30 authored by Alexander Drozdov's avatar Alexander Drozdov

BareMetal: fix Run configuration

Run configuration is broken for remote GDB and hardware debuggers:
just first target can be handled for project.

Task-number: QTCREATORBUG-18434
Change-Id: I3fcff2d906f377dd5a161f74d2c6b21bc5ab943f
Reviewed-by: default avatarAlexander Drozdov <adrozdoff@gmail.com>
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 7293c012
......@@ -131,8 +131,10 @@ QString BareMetalRunConfiguration::defaultDisplayName()
QString BareMetalRunConfiguration::localExecutableFilePath() const
{
const QString targetName = QFileInfo(m_projectFilePath).completeBaseName();
return target()->applicationTargets()
.targetForProject(FileName::fromString(m_projectFilePath)).toString();
.targetFilePath(FileName::fromString(targetName).toString()).toString();
}
QString BareMetalRunConfiguration::arguments() const
......@@ -158,9 +160,10 @@ QString BareMetalRunConfiguration::projectFilePath() const
QString BareMetalRunConfiguration::buildSystemTarget() const
{
const BuildTargetInfoList targets = target()->applicationTargets();
const Utils::FileName projectFilePath = Utils::FileName::fromString(m_projectFilePath);
const Utils::FileName projectFilePath = Utils::FileName::fromString(QFileInfo(m_projectFilePath).path());
const QString targetName = QFileInfo(m_projectFilePath).completeBaseName();
auto bst = std::find_if(targets.list.constBegin(), targets.list.constEnd(),
[&projectFilePath](const BuildTargetInfo &bti) { return bti.projectFilePath == projectFilePath; });
[&projectFilePath,&targetName](const BuildTargetInfo &bti) { return bti.projectFilePath == projectFilePath && bti.targetName == targetName; });
return (bst == targets.list.constEnd()) ? QString() : bst->targetName;
}
......
......@@ -60,8 +60,9 @@ bool BareMetalRunConfigurationFactory::canCreate(Target *parent, Core::Id id) co
{
if (!canHandle(parent))
return false;
const QString targetName = QFileInfo(pathFromId(id)).completeBaseName();
return id == BareMetalCustomRunConfiguration::runConfigId()
|| !parent->applicationTargets().targetForProject(pathFromId(id)).isEmpty();
|| !parent->applicationTargets().targetFilePath(targetName).isEmpty();
}
bool BareMetalRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
......@@ -89,7 +90,7 @@ QList<Core::Id> BareMetalRunConfigurationFactory::availableCreationIds(Target *p
const Core::Id base = Core::Id(BareMetalRunConfiguration::IdPrefix);
foreach (const BuildTargetInfo &bti, parent->applicationTargets().list)
result << base.withSuffix(bti.projectFilePath.toString());
result << base.withSuffix(bti.projectFilePath.toString() + QLatin1Char('/') + bti.targetName);
result << BareMetalCustomRunConfiguration::runConfigId();
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment